Skip to content

Commit 98de95e

Browse files
committed
Make COMMAND options customizable
1 parent 0550d40 commit 98de95e

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

lib/matrixeval/ruby/command_line.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def rest_arguments
3838

3939
def seperator_index
4040
argv.index do |argument|
41-
COMMANDS.include?(argument)
41+
Config.commands.include?(argument)
4242
end
4343
end
4444

lib/matrixeval/ruby/command_line/parse_context_arguments.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def parse!
5050
end
5151

5252
opts.separator ""
53-
opts.separator "Commands: #{COMMANDS.join("/")} (Customizable)"
53+
opts.separator "Commands: #{Config.commands.join("/")} (Customizable)"
5454

5555
opts.separator ""
5656
opts.separator "MatrixEval Options:"

lib/matrixeval/ruby/config.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ def parallel_workers
4949
YAML["parallel_workers"] || "number_of_processors"
5050
end
5151

52+
def commands
53+
cmds = YAML["commands"] || []
54+
COMMANDS + cmds
55+
end
56+
5257
end
5358
end
5459
end

test/matrixeval/ruby/command_line_test.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
class Matrixeval::Ruby::CommandLineTest < MatrixevalTest
66

7+
def setup
8+
Matrixeval::Ruby::Config::YAML.stubs(:yaml).returns({"matrix" => {}})
9+
end
10+
711
def test_init?
812
command = Matrixeval::Ruby::CommandLine.new(["init"])
913
assert command.init?
@@ -13,8 +17,6 @@ def test_init?
1317
end
1418

1519
def test_all?
16-
Matrixeval::Ruby::Config::YAML.stubs(:yaml).returns({"matrix" => {}})
17-
1820
command = Matrixeval::Ruby::CommandLine.new(["--all", "rake", "test"])
1921
assert command.all?
2022

test/matrixeval/ruby/config_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,12 @@ def test_exclusions
8282
assert_equal exclusions, Matrixeval::Ruby::Config.exclusions
8383
end
8484

85+
def test_commands
86+
Matrixeval::Ruby::Config::YAML.stubs(:yaml).returns({})
87+
assert_equal ['rake', 'rspec', 'bundle', 'bash'], Matrixeval::Ruby::Config.commands
88+
89+
Matrixeval::Ruby::Config::YAML.stubs(:yaml).returns({'commands' => ['ls']})
90+
assert_equal ['rake', 'rspec', 'bundle', 'bash', 'ls'], Matrixeval::Ruby::Config.commands
91+
end
92+
8593
end

0 commit comments

Comments
 (0)