Class: Terminitor::Yaml

Inherits:
Object
  • Object
show all
Defined in:
lib/terminitor/yaml.rb

Overview

This class holds the legacy YAML sytnax for Terminitor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Yaml

Load in the Yaml file…

Parameters:

  • Path (String)

    to termfile



10
11
12
# File 'lib/terminitor/yaml.rb', line 10

def initialize(path)
  @file = YAML.load File.read(path)
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



6
7
8
# File 'lib/terminitor/yaml.rb', line 6

def file
  @file
end

Instance Method Details

#to_hashHash

Returns yaml file as Terminitor formmatted hash

Returns:

  • (Hash)

    Hash format of termfile



16
17
18
19
20
21
22
23
# File 'lib/terminitor/yaml.rb', line 16

def to_hash
  combined = @file.inject({}) do |base, item| 
    item = {item.keys.first => {:commands => item.values.first, :options => {}}}
    base.merge!(item)
    base
  end # merge the array of hashes.
   { :setup => nil, :windows => { 'default' => {:tabs => combined} } }
end