Class: Micronaut::RakeTask
- Defined in:
- lib/micronaut/rake_task.rb
Instance Attribute Summary collapse
-
#fail_on_error ⇒ Object
Whether or not to fail Rake when an error occurs (typically when examples fail).
-
#failure_message ⇒ Object
A message to print to stderr when there are failures.
-
#name ⇒ Object
Name of task.
-
#pattern ⇒ Object
Glob pattern to match example files.
-
#rcov ⇒ Object
Use rcov for code coverage? defaults to false.
-
#rcov_opts ⇒ Object
The options to pass to rcov.
-
#ruby_opts ⇒ Object
Array of commandline options to pass to ruby.
-
#verbose ⇒ Object
Use verbose output.
-
#warning ⇒ Object
If true, requests that the specs be run with the warning flag set.
Instance Method Summary collapse
-
#define ⇒ Object
:nodoc:.
-
#examples_to_run ⇒ Object
:nodoc:.
-
#initialize(*args) {|_self| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
Constructor Details
#initialize(*args) {|_self| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/micronaut/rake_task.rb', line 40 def initialize(*args) @name = args.shift || :examples @pattern, @rcov_opts = nil, nil @warning, @rcov = false, false @ruby_opts = [] @fail_on_error = true yield self if block_given? @pattern ||= 'examples/**/*_example.rb' define end |
Instance Attribute Details
#fail_on_error ⇒ Object
Whether or not to fail Rake when an error occurs (typically when examples fail). Defaults to true.
25 26 27 |
# File 'lib/micronaut/rake_task.rb', line 25 def fail_on_error @fail_on_error end |
#failure_message ⇒ Object
A message to print to stderr when there are failures.
28 29 30 |
# File 'lib/micronaut/rake_task.rb', line 28 def @failure_message end |
#name ⇒ Object
Name of task. (default is :examples)
11 12 13 |
# File 'lib/micronaut/rake_task.rb', line 11 def name @name end |
#pattern ⇒ Object
Glob pattern to match example files. (default is ‘examples/*/_example.rb’)
18 19 20 |
# File 'lib/micronaut/rake_task.rb', line 18 def pattern @pattern end |
#rcov ⇒ Object
Use rcov for code coverage? defaults to false
35 36 37 |
# File 'lib/micronaut/rake_task.rb', line 35 def rcov @rcov end |
#rcov_opts ⇒ Object
The options to pass to rcov. Defaults to blank
38 39 40 |
# File 'lib/micronaut/rake_task.rb', line 38 def rcov_opts @rcov_opts end |
#ruby_opts ⇒ Object
Array of commandline options to pass to ruby. Defaults to [].
21 22 23 |
# File 'lib/micronaut/rake_task.rb', line 21 def ruby_opts @ruby_opts end |
#verbose ⇒ Object
Use verbose output. If this is set to true, the task will print the executed spec command to stdout. Defaults to false.
32 33 34 |
# File 'lib/micronaut/rake_task.rb', line 32 def verbose @verbose end |
#warning ⇒ Object
If true, requests that the specs be run with the warning flag set. E.g. warning=true implies “ruby -w” used to run the specs. Defaults to false.
15 16 17 |
# File 'lib/micronaut/rake_task.rb', line 15 def warning @warning end |
Instance Method Details
#define ⇒ Object
:nodoc:
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/micronaut/rake_task.rb', line 52 def define # :nodoc: actual_name = Hash === name ? name.keys.first : name desc("Run all examples") unless ::Rake.application.last_comment task name do RakeFileUtils.send(:verbose, verbose) do if examples_to_run.empty? puts "No examples matching #{pattern} could be found" else cmd_parts = [rcov ? 'rcov' : RUBY] cmd_parts += rcov ? [rcov_opts] : ruby_opts cmd_parts << "-w" if warning cmd_parts += examples_to_run.collect { |fn| %["#{fn}"] } cmd = cmd_parts.join(" ") puts cmd if verbose unless system(cmd) STDERR.puts if raise("Command #{cmd} failed") if fail_on_error end end end end self end |
#examples_to_run ⇒ Object
:nodoc:
78 79 80 |
# File 'lib/micronaut/rake_task.rb', line 78 def examples_to_run # :nodoc: FileList[ pattern ].to_a end |