Class: Peto::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/peto/rake_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) {|_self| ... } ⇒ RakeTask

Returns a new instance of RakeTask.

Yields:

  • (_self)

Yield Parameters:



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
43
44
45
46
47
48
# File 'lib/peto/rake_task.rb', line 15

def initialize(*args)
  @contracts ||= []
  @output_dir ||= "./"
  @languages ||= []

  @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
          languages.each do |language|
            self.contracts = [contracts] if contracts.class == String
            contracts.each do |contract|
              peto = Peto::Master.new
              peto.load(contract)
              peto.generate(language, output_dir)
            end
          end
        #rescue
        #  puts failure_message if failure_message
        #  raise "peto failed" if fail_on_error
        end
      end
    end
  end
end

Instance Attribute Details

#contractsObject

Returns the value of attribute contracts.



7
8
9
# File 'lib/peto/rake_task.rb', line 7

def contracts
  @contracts
end

#fail_on_errorObject

Returns the value of attribute fail_on_error.



12
13
14
# File 'lib/peto/rake_task.rb', line 12

def fail_on_error
  @fail_on_error
end

#failure_messageObject

Returns the value of attribute failure_message.



13
14
15
# File 'lib/peto/rake_task.rb', line 13

def failure_message
  @failure_message
end

#languagesObject

Returns the value of attribute languages.



9
10
11
# File 'lib/peto/rake_task.rb', line 9

def languages
  @languages
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/peto/rake_task.rb', line 11

def name
  @name
end

#output_dirObject

Returns the value of attribute output_dir.



8
9
10
# File 'lib/peto/rake_task.rb', line 8

def output_dir
  @output_dir
end