Class: FYT::Config

Inherits:
Base
  • Object
show all
Defined in:
lib/fyt/config.rb

Overview

reads and prepares a youtube feed for further processing

Instance Method Summary collapse

Methods inherited from Base

#logger

Constructor Details

#initialize(path = nil) ⇒ Config

Returns a new instance of Config.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fyt/config.rb', line 8

def initialize(path = nil)
  path ||= File.join(Dir.home, '.fyt.config.yml')
  @store = YAML::Store.new(path)

  # populate defaults
  @store.transaction do
    @store[:storage_path] ||= 'storage'
    @store[:server_prefix] ||= 'https://localhost:2017'
    @store[:format_options] ||= '22+140'
    @store[:output_format] ||= 'mp4'
    @store[:feeds] ||= []

    @store.commit
  end
end

Instance Method Details

#[](key) ⇒ Object



24
25
26
# File 'lib/fyt/config.rb', line 24

def [](key)
  @store.transaction { @store[key] }
end

#[]=(key, value) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/fyt/config.rb', line 28

def []=(key, value)
  return if value.is_a?(String) && value.size.zero?

  @store.transaction do
    @store[key] = value
  end
end