Class: DuperVisor::Main
- Inherits:
-
Object
- Object
- DuperVisor::Main
- Defined in:
- lib/dupervisor/main.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#content ⇒ Object
Returns the value of attribute content.
-
#from_format ⇒ Object
Returns the value of attribute from_format.
Instance Method Summary collapse
-
#initialize(config) ⇒ Main
constructor
A new instance of Main.
- #report_error(e) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(config) ⇒ Main
Returns a new instance of Main.
10 11 12 |
# File 'lib/dupervisor/main.rb', line 10 def initialize(config) self.config = config end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
8 9 10 |
# File 'lib/dupervisor/main.rb', line 8 def config @config end |
#content ⇒ Object
Returns the value of attribute content.
8 9 10 |
# File 'lib/dupervisor/main.rb', line 8 def content @content end |
#from_format ⇒ Object
Returns the value of attribute from_format.
8 9 10 |
# File 'lib/dupervisor/main.rb', line 8 def from_format @from_format end |
Instance Method Details
#report_error(e) ⇒ Object
23 24 25 26 |
# File 'lib/dupervisor/main.rb', line 23 def report_error(e) puts ' Error:'.bold.white + ' Unable to parse input.'.bold.red puts 'Details:'.bold.white + " #{e.inspect}".red end |
#run ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/dupervisor/main.rb', line 14 def run config.validate! self.from_format = Detector.new(ARGF.filename).detect self.content = Parser.new(ARGF.read).parse(from_format) Renderer.new(content.parse_result, config.output).render(config.to) rescue DuperVisor::Parser::ParseError => e report_error(e) end |