Class: Shiplane::ChefErrorParser
- Inherits:
-
Object
- Object
- Shiplane::ChefErrorParser
- Defined in:
- lib/capistrano/chef_error_parser.rb
Constant Summary collapse
- ERROR_LINE_REGEXP =
/================================================================================/
- CHEF_ERRORS =
[ /ERROR: Exception handlers complete/, /FATAL: Chef::Exceptions::ChildConvergeError/, ]
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
Class Method Summary collapse
Instance Method Summary collapse
- #first_line ⇒ Object
-
#initialize(error) ⇒ ChefErrorParser
constructor
A new instance of ChefErrorParser.
- #last_line ⇒ Object
- #lines ⇒ Object
- #parse ⇒ Object
Constructor Details
#initialize(error) ⇒ ChefErrorParser
Returns a new instance of ChefErrorParser.
11 12 13 |
# File 'lib/capistrano/chef_error_parser.rb', line 11 def initialize(error) @error = error end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
9 10 11 |
# File 'lib/capistrano/chef_error_parser.rb', line 9 def error @error end |
Class Method Details
.parse(error) ⇒ Object
31 32 33 |
# File 'lib/capistrano/chef_error_parser.rb', line 31 def self.parse(error) new(error).parse end |
Instance Method Details
#first_line ⇒ Object
19 20 21 |
# File 'lib/capistrano/chef_error_parser.rb', line 19 def first_line @first_line ||= lines.index(lines.reverse_each.find{|line| line =~ ERROR_LINE_REGEXP }) || 0 end |
#last_line ⇒ Object
23 24 25 |
# File 'lib/capistrano/chef_error_parser.rb', line 23 def last_line @last_line ||= lines.index{|line| CHEF_ERRORS.any?{ |error| line =~ error } } || -1 end |
#lines ⇒ Object
15 16 17 |
# File 'lib/capistrano/chef_error_parser.rb', line 15 def lines @lines ||= error..split("\n") end |
#parse ⇒ Object
27 28 29 |
# File 'lib/capistrano/chef_error_parser.rb', line 27 def parse lines[first_line..last_line] end |