Class: PodBuilder::Actions::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/pod_builder/actions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, hash) ⇒ Item

Returns a new instance of Item.



23
24
25
26
27
28
29
# File 'lib/pod_builder/actions.rb', line 23

def initialize(name, hash)
  @name = name
  @path = hash.fetch("path", "") 
  @quiet = hash.fetch("quiet", false) 

  raise "\n\nEmpty or missing post #{name} action path\n".red if @path.empty?()
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



21
22
23
# File 'lib/pod_builder/actions.rb', line 21

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



19
20
21
# File 'lib/pod_builder/actions.rb', line 19

def path
  @path
end

#quietObject (readonly)

Returns the value of attribute quiet.



20
21
22
# File 'lib/pod_builder/actions.rb', line 20

def quiet
  @quiet
end

Instance Method Details

#executeObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pod_builder/actions.rb', line 31

def execute()
  cmd = PodBuilder::basepath(path)
  unless File.exist?(cmd)
    raise "\n\nPost #{name} action path '#{cmd}' does not exists!\n".red
  end

  if @quiet
    cmd += " > /dev/null 2>&1"
  end

  puts "Executing post #{name} action".yellow
  `#{cmd}`
end