Skip to content

Commit 2f1d83d

Browse files
committed
Use ruby 3.1 by default and update use of kwargs to support it
1 parent c085c42 commit 2f1d83d

File tree

7 files changed

+32
-28
lines changed

7 files changed

+32
-28
lines changed

.ruby-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.6.5
1+
3.1.0

Gemfile.lock

+17-15
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,31 @@ PATH
77
GEM
88
remote: https://rubygems.org/
99
specs:
10-
byebug (11.1.1)
11-
diff-lcs (1.3)
10+
diff-lcs (1.5.0)
11+
psych (4.0.3)
12+
stringio
1213
rake (12.3.3)
13-
rdoc (6.3.1)
14-
rspec (3.9.0)
15-
rspec-core (~> 3.9.0)
16-
rspec-expectations (~> 3.9.0)
17-
rspec-mocks (~> 3.9.0)
18-
rspec-core (3.9.1)
19-
rspec-support (~> 3.9.1)
20-
rspec-expectations (3.9.1)
14+
rdoc (6.4.0)
15+
psych (>= 4.0.0)
16+
rspec (3.11.0)
17+
rspec-core (~> 3.11.0)
18+
rspec-expectations (~> 3.11.0)
19+
rspec-mocks (~> 3.11.0)
20+
rspec-core (3.11.0)
21+
rspec-support (~> 3.11.0)
22+
rspec-expectations (3.11.0)
2123
diff-lcs (>= 1.2.0, < 2.0)
22-
rspec-support (~> 3.9.0)
23-
rspec-mocks (3.9.1)
24+
rspec-support (~> 3.11.0)
25+
rspec-mocks (3.11.0)
2426
diff-lcs (>= 1.2.0, < 2.0)
25-
rspec-support (~> 3.9.0)
26-
rspec-support (3.9.2)
27+
rspec-support (~> 3.11.0)
28+
rspec-support (3.11.0)
29+
stringio (3.0.1)
2730

2831
PLATFORMS
2932
ruby
3033

3134
DEPENDENCIES
32-
byebug (~> 11)
3335
git-commander!
3436
rake (~> 12.3)
3537
rdoc (~> 6.2)

git-commander.gemspec

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
2222
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2323
spec.require_paths = ["lib"]
2424

25-
spec.add_development_dependency "byebug", "~> 11"
2625
spec.add_development_dependency "rake", "~> 12.3"
2726
spec.add_development_dependency "rdoc", "~> 6.2"
2827
spec.add_development_dependency "rspec", "< 4.0"

lib/git_commander/command.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ class Command
3535
# @yieldparam [Array<Option>] run_options an Array of
3636
# Option instances defined from the above +options+
3737
#
38-
def initialize(name, registry: nil, **options, &block)
38+
def initialize(name, options = {}, &block)
3939
@name = name
4040
@description = options[:description]
4141
@summary = options[:summary]
4242
@block = block_given? ? block : proc {}
43-
@registry = registry || GitCommander::Registry.new
44-
@output = options[:output] || STDOUT
43+
@registry = options[:registry] || GitCommander::Registry.new
44+
@output = options[:output] || $stdout
4545

4646
define_command_options(options)
4747
end
@@ -52,7 +52,7 @@ def initialize(name, registry: nil, **options, &block)
5252
#
5353
def run(run_options = [])
5454
assign_option_values(run_options)
55-
Runner.new(self).run options.map(&:to_h).reduce(:merge)
55+
Runner.new(self).run(options.map(&:to_h).reduce(:merge) || {})
5656
end
5757

5858
# Appends the +message+ to the Command's {#output}
@@ -107,10 +107,10 @@ def add_option(option_type, options = {})
107107

108108
private
109109

110-
def define_command_options(options)
111-
@arguments = options_from_hash(options[:arguments])
112-
@flags = options_from_hash(options[:flags])
113-
@switches = options_from_hash(options[:switches])
110+
def define_command_options(new_options)
111+
@arguments = options_from_hash(new_options[:arguments])
112+
@flags = options_from_hash(new_options[:flags])
113+
@switches = options_from_hash(new_options[:switches])
114114
end
115115

116116
def options_from_hash(hash)

lib/git_commander/command/runner.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def initialize(command)
1717

1818
def run(options = {})
1919
GitCommander.logger.info "Running '#{command.name}' with arguments: #{options.inspect}"
20-
instance_exec(options, &command.block)
20+
instance_exec(**options, &command.block)
2121
end
2222

2323
def say(message)

spec/lib/git_commander/command/loaders/raw_spec.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,16 @@
116116
end
117117
COMMANDS
118118

119-
native_plugin_loader_spy = spy("Native Plugin Loader")
119+
native_plugin_loader_spy = instance_double(GitCommander::Plugin::Loader)
120120
native_plugin_loader_result = GitCommander::LoaderResult.new
121121
native_plugin_loader_result.plugins << GitCommander::Plugin.new(:git, registry: registry)
122122
expect(loader.result.commands).to be_empty
123123
expect(GitCommander::Plugin::Loader).to receive(:new).with(registry).and_return(native_plugin_loader_spy)
124-
expect(native_plugin_loader_spy).to receive(:load).with(:git, {}).and_return(native_plugin_loader_result)
124+
expect(native_plugin_loader_spy).to receive(:load).with(:git).and_return(native_plugin_loader_result)
125125

126126
loader.load(raw_command_string)
127127

128+
expect(loader.result.errors.size).to be_zero
128129
expect(loader.result.plugins.size).to eq 1
129130
expect(loader.result.commands.size).to eq 2
130131

spec/lib/git_commander/plugins/git_spec.rb

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
stub_const "Rugged::Config", fake_rugged_config
1919
stub_const "Rugged::Repository", fake_rugged_repository
2020
allow(fake_rugged_config).to receive(:new).with(git_commander_config_path)
21+
allow(mock_system).to receive(:run)
22+
allow(mock_system).to receive(:say)
2123
allow(loader).to receive(:system).and_return(mock_system)
2224
end
2325

0 commit comments

Comments
 (0)