class Ssource::Command::Show
Public Class Methods
new(argv)
click to toggle source
Calls superclass method
Ssource::Command::new
# File lib/ssource/command/show.rb, line 10 def initialize(argv) self.file_path = argv.shift_argument super end
Public Instance Methods
run()
click to toggle source
# File lib/ssource/command/show.rb, line 15 def run @root = Ssource::Source.from file_path puts sections * "\n\n" end
Private Instance Methods
sections()
click to toggle source
# File lib/ssource/command/show.rb, line 22 def sections [].tap do |sections| @root.pretty_print.each do |key, value| sections << yamlize(value).prepend(key.green) end end end
yamlize(value)
click to toggle source
# File lib/ssource/command/show.rb, line 30 def yamlize(value) yaml = value.to_yaml yaml.gsub!(/^---$/, '') yaml.gsub!(/^--- \[\]$/, '') yaml.gsub!(/^-/, "\n-") yaml end