Class: ChkBuild::Title
- Inherits:
-
Object
- Object
- ChkBuild::Title
- Defined in:
- lib/chkbuild/title.rb
Instance Attribute Summary collapse
-
#logfile ⇒ Object
readonly
Returns the value of attribute logfile.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #depsuffixed_name ⇒ Object
-
#initialize(target, logfile) ⇒ Title
constructor
A new instance of Title.
- #make_title ⇒ Object
- #run_failure_hooks ⇒ Object
- #run_hooks ⇒ Object
- #run_title_hooks ⇒ Object
- #suffixed_name ⇒ Object
- #suffixes ⇒ Object
- #target_name ⇒ Object
- #update_title(key, val = nil) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(target, logfile) ⇒ Title
Returns a new instance of Title.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/chkbuild/title.rb', line 28 def initialize(target, logfile) @target = target @logfile = logfile @title = {} @title[:version] = @logfile.suffixed_name @title[:dep_versions] = [] @title[:hostname] = "(#{Util.simple_hostname})" @title_order = [:version, :dep_versions, :hostname, :warn, :mark, :status] @logfile.each_secname {|secname| log = @logfile.get_section(secname) lastline = log.chomp("").lastline if /\Afailed\(.*\)\z/ =~ lastline sym = "failure_#{secname}".intern @title_order << sym @title[sym] = lastline end } end |
Instance Attribute Details
#logfile ⇒ Object (readonly)
Returns the value of attribute logfile.
46 47 48 |
# File 'lib/chkbuild/title.rb', line 46 def logfile @logfile end |
Instance Method Details
#[](key) ⇒ Object
104 105 106 |
# File 'lib/chkbuild/title.rb', line 104 def [](key) @title[key] end |
#depsuffixed_name ⇒ Object
52 |
# File 'lib/chkbuild/title.rb', line 52 def depsuffixed_name() @logfile.depsuffixed_name end |
#make_title ⇒ Object
97 98 99 100 101 102 |
# File 'lib/chkbuild/title.rb', line 97 def make_title title_hash = @title @title_order.map {|key| title_hash[key] }.flatten.join(' ').gsub(/\s+/, ' ').strip end |
#run_failure_hooks ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/chkbuild/title.rb', line 72 def run_failure_hooks @target.each_failure_hook {|secname, block| if log = @logfile.get_section(secname) lastline = log.chomp("").lastline if /\Afailed\(.*\)\z/ =~ lastline sym = "failure_#{secname}".intern if newval = block.call(log) @title[sym] = newval end end end } end |
#run_hooks ⇒ Object
57 58 59 60 |
# File 'lib/chkbuild/title.rb', line 57 def run_hooks run_title_hooks run_failure_hooks end |
#run_title_hooks ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/chkbuild/title.rb', line 62 def run_title_hooks @target.each_title_hook {|secname, block| if secname == nil block.call self, @logfile.get_all_log elsif log = @logfile.get_section(secname) block.call self, log end } end |
#suffixed_name ⇒ Object
53 |
# File 'lib/chkbuild/title.rb', line 53 def suffixed_name() @logfile.suffixed_name end |
#suffixes ⇒ Object
55 |
# File 'lib/chkbuild/title.rb', line 55 def suffixes() @logfile.suffixes end |
#target_name ⇒ Object
54 |
# File 'lib/chkbuild/title.rb', line 54 def target_name() @logfile.target_name end |
#update_title(key, val = nil) ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/chkbuild/title.rb', line 86 def update_title(key, val=nil) if val == nil && block_given? val = yield @title[key] return if !val end @title[key] = val unless @title_order.include? key @title_order[-1,0] = [key] end end |
#version ⇒ Object
48 49 50 |
# File 'lib/chkbuild/title.rb', line 48 def version return @title[:version] end |