Class: Peto::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Peto::RakeTask
- Defined in:
- lib/peto/rake_task.rb
Instance Attribute Summary collapse
-
#contracts ⇒ Object
Returns the value of attribute contracts.
-
#fail_on_error ⇒ Object
Returns the value of attribute fail_on_error.
-
#failure_message ⇒ Object
Returns the value of attribute failure_message.
-
#name ⇒ Object
Returns the value of attribute name.
-
#output_dir ⇒ Object
Returns the value of attribute output_dir.
Instance Method Summary collapse
-
#initialize(*args) {|_self| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
Constructor Details
#initialize(*args) {|_self| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/peto/rake_task.rb', line 13 def initialize(*args) @contracts ||= [] @output_dir ||= "./" @name ||= :peto @fail_on_error ||= true yield self if block_given? desc("Generate codes by contracts") unless ::Rake.application.last_comment task name do RakeFileUtils.send(:verbose, verbose) do if contracts.empty? puts "No contracts" else begin self.contracts = [contracts] if contracts.class == String contracts.each do |contract| peto = Peto::Master.new peto.load(contract) peto.generate(output_dir) end rescue puts if raise "peto failed" if fail_on_error end end end end end |
Instance Attribute Details
#contracts ⇒ Object
Returns the value of attribute contracts.
7 8 9 |
# File 'lib/peto/rake_task.rb', line 7 def contracts @contracts end |
#fail_on_error ⇒ Object
Returns the value of attribute fail_on_error.
10 11 12 |
# File 'lib/peto/rake_task.rb', line 10 def fail_on_error @fail_on_error end |
#failure_message ⇒ Object
Returns the value of attribute failure_message.
11 12 13 |
# File 'lib/peto/rake_task.rb', line 11 def @failure_message end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/peto/rake_task.rb', line 9 def name @name end |
#output_dir ⇒ Object
Returns the value of attribute output_dir.
8 9 10 |
# File 'lib/peto/rake_task.rb', line 8 def output_dir @output_dir end |