Class: Franklin::Config

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

Constant Summary collapse

DEFAULT_CONFIG_FILE =
File.join(Dir.home, ".franklin").freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Config

Returns a new instance of Config.



9
10
11
12
13
14
# File 'lib/franklin/config.rb', line 9

def initialize(data)
  @libraries = data.fetch("libraries").map { |library|
    Library.new(library.fetch("name"), library.fetch("url"))
  }
  @default_type = data["default_type"]
end

Instance Attribute Details

#default_typeObject (readonly)

Returns the value of attribute default_type.



7
8
9
# File 'lib/franklin/config.rb', line 7

def default_type
  @default_type
end

#librariesObject (readonly)

Returns the value of attribute libraries.



7
8
9
# File 'lib/franklin/config.rb', line 7

def libraries
  @libraries
end

Class Method Details

.from_yaml(yaml) ⇒ Object



17
18
19
# File 'lib/franklin/config.rb', line 17

def from_yaml(yaml)
  new(YAML.load(yaml))
end

.load_from_file(file_path = nil) ⇒ Object



21
22
23
# File 'lib/franklin/config.rb', line 21

def load_from_file(file_path = nil)
  from_yaml(File.read(file_path || DEFAULT_CONFIG_FILE))
end