Class: Texas::Build::Task::Script

Inherits:
Base
  • Object
show all
Defined in:
lib/texas/build/task/script.rb

Instance Attribute Summary

Attributes inherited from Base

#build

Instance Method Summary collapse

Methods inherited from Base

#initialize, #run

Methods included from OutputHelper

#trace, #verbose, #warning

Constructor Details

This class inherits a constructor from Texas::Build::Task::Base

Instance Method Details

#cmd_from_config(key, default_value = nil) ⇒ Object


6
7
8
9
10
# File 'lib/texas/build/task/script.rb', line 6

def cmd_from_config(key, default_value = nil)
  if cmd = build.config.script(key) || default_value
    ERB.new(cmd).result(binding)
  end
end

#execute(cmd) ⇒ Object


12
13
14
15
# File 'lib/texas/build/task/script.rb', line 12

def execute(cmd)
  verbose { TraceInfo.new(:run, "`#{cmd}`", :cyan) }
  execute_in(build.__path__) { `#{cmd}` }
end

#execute_in(path) ⇒ Object


17
18
19
20
21
22
23
# File 'lib/texas/build/task/script.rb', line 17

def execute_in(path)
  old_path = Dir.pwd
  Dir.chdir path
  return_value = yield
  Dir.chdir old_path
  return_value
end