Sha256: dd760edb685be51d36089a36589f166c523c66c98451a90d94bf3780fe453269
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
module GoldenRose module BuildLog class BuildSection attr_reader :name, :path, :errors def initialize(section_logs) @name = section_logs.match(/([a-zA-Z]+(\s[a-zA-Z]+)*)/).to_s @path = match_path(@name, section_logs) @errors = extract_errors(section_logs) end def file @file ||= if path? last_element = @path.split('/').last last_element if last_element.include?('.') end end def directory @directory ||= file? ? @path.gsub(file, '') : @path end def file? !(file.nil? || file.empty?) end def path? !(@path.nil? || @path.empty?) end def errors? !success? end def success? @errors.nil? || @errors.empty? end private def match_path(name, section_logs) path_patern = /(\/\w([[[\w|-]|\s]\+]*\/?)*(\.[a-zA-Z]+)?)/ matched = section_logs.match(/#{name} #{path_patern}/) matched[1] if matched end def extract_errors(section_logs) error_strings = section_logs.scan(/error:.[^\r]*/) return if error_strings.empty? error_strings.map do |err| err.gsub(/error:\s*/, '') end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
golden_rose-1.0.0.pre | lib/golden_rose/build_log/build_section.rb |