Skip to content

Loading…

Refactor the show_tasks option code into function and replace #130

Merged
merged 2 commits into from

2 participants

@samphippen

There was very similar code in 3 places in this method, so I broke the similar code up into a function and replaced it in the 3 places it was used.

samphippen added some commits
@samphippen samphippen Refactor the show_tasks option code into function and replace
There was very similar code in 3 places in this function, so I broke it
out into it's own function.

Signed-off-by: Sam Phippen <samphippen@googlemail.com>
e42c52e
@samphippen samphippen Remove a double whitespace I created
Signed-off-by: Sam Phippen <samphippen@googlemail.com>
e19deb0
@samphippen

Weird, I ran that and got this output:

5 (refactor-tasks-options)$ ruby -Ilib/ bin/rake TESTOPTS="--seed=37587"
Run options: --seed=37587

# Running tests:

......................................................................................................................................................................................................................................................................................................................................................................................................................................................

Finished tests in 10.416596s, 42.0483 tests/s, 118.7528 assertions/s.

438 tests, 1237 assertions, 0 failures, 0 errors, 0 skips
6 (refactor-tasks-options)$ 

@samphippen

it also passed without using bin/rake but the systemwide rake.

ruby version: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]

@jimweirich
Owner

Yes, the Travis CI failure was related to the signal propagation code, which apparently only works on some systems.

@samphippen

Ok. Do I need to modify this code?

@jimweirich jimweirich merged commit e19deb0 into jimweirich:master

1 check failed

Details default The Travis build failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 14, 2012
  1. @samphippen

    Refactor the show_tasks option code into function and replace

    samphippen committed
    There was very similar code in 3 places in this function, so I broke it
    out into it's own function.
    
    Signed-off-by: Sam Phippen <samphippen@googlemail.com>
  2. @samphippen

    Remove a double whitespace I created

    samphippen committed
    Signed-off-by: Sam Phippen <samphippen@googlemail.com>
Showing with 17 additions and 17 deletions.
  1. +17 −17 lib/rake/application.rb
View
34 lib/rake/application.rb
@@ -30,6 +30,12 @@ class Application
DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb'].freeze
+ def self.set_tasks_options(show_tasks, value, options)
+ options.show_tasks = show_tasks
+ options.show_task_pattern = Regexp.new(value || '')
+ Rake::TaskManager.record_task_metadata = true
+ end
+
# Initialize a Rake::Application object.
def initialize
super
@@ -296,9 +302,17 @@ def standard_rake_options
],
['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
lambda { |value|
- options.show_tasks = :describe
- options.show_task_pattern = Regexp.new(value || '')
- TaskManager.record_task_metadata = true
+ Rake::Application.set_tasks_options :describe, value, options
+ }
+ ],
+ ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
+ lambda { |value|
+ Rake::Application.set_tasks_options :tasks, value, options
+ }
+ ],
+ ['--where', '-W [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
+ lambda { |value|
+ Rake::Application.set_tasks_options :lines, value, options
}
],
['--dry-run', '-n', "Do a dry run without executing actions.",
@@ -384,13 +398,6 @@ def standard_rake_options
"Use standard project Rakefile search paths, ignore system wide rakefiles.",
lambda { |value| options.ignore_system = true }
],
- ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
- lambda { |value|
- options.show_tasks = :tasks
- options.show_task_pattern = Regexp.new(value || '')
- Rake::TaskManager.record_task_metadata = true
- }
- ],
['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.",
lambda { |value|
options.trace = true
@@ -406,13 +413,6 @@ def standard_rake_options
exit
}
],
- ['--where', '-W [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
- lambda { |value|
- options.show_tasks = :lines
- options.show_task_pattern = Regexp.new(value || '')
- Rake::TaskManager.record_task_metadata = true
- }
- ],
['--no-deprecation-warnings', '-X', "Disable the deprecation warnings.",
lambda { |value|
options.ignore_deprecate = true
Something went wrong with that request. Please try again.