Class: DebrideToOkuribito::Converter
- Inherits:
-
Object
- Object
- DebrideToOkuribito::Converter
- Defined in:
- lib/debride2okuribito.rb
Constant Summary collapse
- FILE_NAME =
"okuribito.yml".freeze
- HEADING =
["# This configuration was generated by", "# `debride2okuribito %s`", "# on #{Time.now} using debride2okuribito version #{DebrideToOkuribito::VERSION}.", ""] .join("\n").freeze
Instance Method Summary collapse
- #convert_yaml ⇒ Object
-
#initialize(argv) ⇒ Converter
constructor
A new instance of Converter.
- #read_debride ⇒ Object
- #write_yaml(hash) ⇒ Object
Constructor Details
#initialize(argv) ⇒ Converter
Returns a new instance of Converter.
16 17 18 |
# File 'lib/debride2okuribito.rb', line 16 def initialize(argv) @argv = argv.clone.freeze end |
Instance Method Details
#convert_yaml ⇒ Object
20 21 22 23 |
# File 'lib/debride2okuribito.rb', line 20 def convert_yaml hash = read_debride write_yaml(hash) end |
#read_debride ⇒ Object
25 26 27 28 29 |
# File 'lib/debride2okuribito.rb', line 25 def read_debride puts "--- Run debride and convert to yaml..." debride = Debride.run(@argv.dup) debride_to_hash(debride) end |
#write_yaml(hash) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/debride2okuribito.rb', line 31 def write_yaml(hash) yaml = YAML.dump(hash) # Workaround... yaml.gsub!(/^---\n/, "") yaml.gsub!(/^- /, " - ") generate_file(yaml, FILE_NAME) puts "--- 'okuribito.yml' has been generated." end |