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, step, hash) ⇒ Item

Returns a new instance of Item.



26
27
28
29
30
31
32
33
# File 'lib/pod_builder/actions.rb', line 26

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

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



24
25
26
# File 'lib/pod_builder/actions.rb', line 24

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#quietObject (readonly)

Returns the value of attribute quiet.



23
24
25
# File 'lib/pod_builder/actions.rb', line 23

def quiet
  @quiet
end

Instance Method Details

#executeObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pod_builder/actions.rb', line 35

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

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

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