Class: Ivy::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/ivy/target.rb

Overview

Base class with general logic to call a Ivy ant target

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ant) ⇒ Target

Returns a new instance of Target.



9
10
11
# File 'lib/ivy/target.rb', line 9

def initialize(ant)
  @ant = ant
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



7
8
9
# File 'lib/ivy/target.rb', line 7

def params
  @params
end

Instance Method Details

#execute(*params) ⇒ Object

Executes this ivy target with given parameters returning a result. __params__ can be a single Hash or an Array with or without a Hash as last value. every value in array will be converted to string and set to __true__.

I.e. [:force, 'validate', {'name' => 'Blub'}] results in parameters {'force'=>true, 'validate' => true, 'name'=>'Blub'}



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ivy/target.rb', line 19

def execute(*params)
  @params = {}
  params.pop.each { |key, value| @params[key] = value } if Hash === params.last
  params.each { |key| @params[key.to_s] = true }

  validate
  before_hook
  execute_ivy
  create_return_values
ensure
  after_hook
end