Class: Thor::SpecTask
Instance Attribute Summary collapse
-
#files ⇒ Object
Returns the value of attribute files.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rcov_config ⇒ Object
Returns the value of attribute rcov_config.
-
#rcov_dir ⇒ Object
Returns the value of attribute rcov_dir.
-
#spec_config ⇒ Object
Returns the value of attribute spec_config.
Attributes inherited from Task
#description, #options, #usage
Instance Method Summary collapse
-
#initialize(name, files, config = {}) ⇒ SpecTask
constructor
A new instance of SpecTask.
- #run(instance, args = []) ⇒ Object
Methods inherited from Task
dynamic, #formatted_arguments, #formatted_options, #formatted_usage, #initialize_copy, #short_description
Constructor Details
#initialize(name, files, config = {}) ⇒ SpecTask
Returns a new instance of SpecTask.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/thor/tasks/spec.rb', line 26 def initialize(name, files, config={}) = { :verbose => Thor::Option.parse(:verbose, config.delete(:verbose) || false) } super(name, "#{name.capitalize} task", name, ) @name = name @files = files.map{ |f| %["#{f}"] }.join(" ") @rcov_dir = config.delete(:rdoc_dir) || File.join(Dir.pwd, 'coverage') @rcov_config = config.delete(:rcov) || {} @spec_config = { :format => 'specdoc', :color => true }.merge(config) end |
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
24 25 26 |
# File 'lib/thor/tasks/spec.rb', line 24 def files @files end |
#name ⇒ Object
Returns the value of attribute name.
24 25 26 |
# File 'lib/thor/tasks/spec.rb', line 24 def name @name end |
#rcov_config ⇒ Object
Returns the value of attribute rcov_config.
24 25 26 |
# File 'lib/thor/tasks/spec.rb', line 24 def rcov_config @rcov_config end |
#rcov_dir ⇒ Object
Returns the value of attribute rcov_dir.
24 25 26 |
# File 'lib/thor/tasks/spec.rb', line 24 def rcov_dir @rcov_dir end |
#spec_config ⇒ Object
Returns the value of attribute spec_config.
24 25 26 |
# File 'lib/thor/tasks/spec.rb', line 24 def spec_config @spec_config end |
Instance Method Details
#run(instance, args = []) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/thor/tasks/spec.rb', line 37 def run(instance, args=[]) rcov_opts = Thor::Options.to_switches(rcov_config) spec_opts = Thor::Options.to_switches(spec_config) require 'rbconfig' cmd = RbConfig::CONFIG['ruby_install_name'] << " " if rcov? FileUtils.rm_rf(rcov_dir) cmd << "-S #{where('rcov')} -o #{rcov_dir} #{rcov_opts} " end cmd << [where('spec'), rcov? ? " -- " : nil, files, spec_opts].join(" ") puts cmd if instance..verbose? system(cmd) exit($?.exitstatus) end |