Class: Shenandoah::Tasks
- Inherits:
-
Object
- Object
- Shenandoah::Tasks
- Defined in:
- lib/shenandoah/tasks.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#locator ⇒ Object
Returns the value of attribute locator.
-
#options ⇒ Object
Returns the value of attribute options.
-
#runner ⇒ Object
Returns the value of attribute runner.
Instance Method Summary collapse
- #generate_spec(name) ⇒ Object
-
#initialize(options = {}) ⇒ Tasks
constructor
A new instance of Tasks.
- #run_specs(pattern = nil) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Tasks
Returns a new instance of Tasks.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/shenandoah/tasks.rb', line 10 def initialize( = {}) @options = @locator = if [:locator] [:locator] else default_locator_type.new() end @runner = Shenandoah::Runner.new(@locator) create_serve_task create_shell_task create_run_task create_gen_task unless [:generate_task] == false end |
Instance Attribute Details
#locator ⇒ Object
Returns the value of attribute locator.
8 9 10 |
# File 'lib/shenandoah/tasks.rb', line 8 def locator @locator end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/shenandoah/tasks.rb', line 8 def @options end |
#runner ⇒ Object
Returns the value of attribute runner.
8 9 10 |
# File 'lib/shenandoah/tasks.rb', line 8 def runner @runner end |
Instance Method Details
#generate_spec(name) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/shenandoah/tasks.rb', line 42 def generate_spec(name) raise "Please specify a spec name. E.g., shen:generate[foo]." unless name require 'rails_generator' require 'rails_generator/scripts/generate' ::Rails::Generator::Base::prepend_sources( ::Rails::Generator::PathSource.new( :shenandoah, File.join(File.dirname(__FILE__), '../../rails_generators')) ) # These branches are functionally equivalent. They change the logging # that rails_generator emits to omit the WD when the target is under # the WD. ENV['SHEN_SPEC_PATH'], dest = if @locator.spec_path =~ /^#{FileUtils.pwd}\/?/ [@locator.spec_path.sub(/^#{FileUtils.pwd}\/?/, ''), FileUtils.pwd] else [@locator.spec_path, ''] end ::Rails::Generator::Scripts::Generate.new.run( ['shen_spec', '-t', name], :destination => dest, :quiet => Rake.application..quiet) end |
#run_specs(pattern = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/shenandoah/tasks.rb', line 25 def run_specs(pattern=nil) files = @locator.spec_files if ENV['SHEN_SPEC'] trace "limiting shenandoah specs based on #{ENV['SHEN_SPEC'].inspect}" files = files.select { |f| f =~ /#{ENV['SHEN_SPEC']}/ } end if pattern trace "limiting shenandoah specs based on #{pattern.inspect}" files = files.select { |f| f =~ /#{pattern}/ } end trace "running shenandoah specs\n - #{files.join("\n - ")}" successes = @runner.run_console(files) if (successes.size != files.size) raise "Shenandoah specs failed!" end end |