Class: Heidi::Hook
- Inherits:
-
Object
- Object
- Heidi::Hook
- Defined in:
- lib/heidi/hook.rb
Instance Attribute Summary collapse
-
#build ⇒ Object
readonly
Returns the value of attribute build.
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(build, script) ⇒ Hook
constructor
A new instance of Hook.
- #message ⇒ Object
- #name ⇒ Object
- #output ⇒ Object
- #perform(where = build.build_root) ⇒ Object
Constructor Details
#initialize(build, script) ⇒ Hook
Returns a new instance of Hook.
6 7 8 9 |
# File 'lib/heidi/hook.rb', line 6 def initialize(build, script) @build = build @script = script end |
Instance Attribute Details
#build ⇒ Object (readonly)
Returns the value of attribute build.
5 6 7 |
# File 'lib/heidi/hook.rb', line 5 def build @build end |
Instance Method Details
#failed? ⇒ Boolean
54 55 56 57 58 |
# File 'lib/heidi/hook.rb', line 54 def failed? @res.S?.to_i != 0 rescue false end |
#message ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/heidi/hook.rb', line 38 def @res.err.empty? ? @res.out.empty? ? "No error message given" : @res.out : @res.err end |
#name ⇒ Object
60 61 62 |
# File 'lib/heidi/hook.rb', line 60 def name File.join(File.basename(File.dirname(@script)), File.basename(@script)) end |
#output ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/heidi/hook.rb', line 46 def output @res.out.empty? ? @res.err.empty? ? "No output" : @res.err : @res.out end |
#perform(where = build.build_root) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/heidi/hook.rb', line 11 def perform(where=build.build_root) # before / failure hooks might like this if !File.exists?(where) where = build.root end start = Time.now env = { 'HEIDI_DIR' => build.project.root, 'HEIDI_LOG_DIR' => build.log_root, 'HEIDI_BUILD_DIR' => where, 'HEIDI_BUILD_COMMIT' => build.commit, 'HEIDI_BRANCH' => build.project.branch, 'RUBYOPT' => nil, 'BUNDLE_BIN_PATH' => nil, 'BUNDLE_GEMFILE' => nil, 'GEM_HOME' => nil, 'GEM_PATH' => nil, } shell = SimpleShell.new(where, env) @res = shell.do @script return @res end |