Class: Bridgetown::DefaultsReader
- Inherits:
-
Object
- Object
- Bridgetown::DefaultsReader
- Defined in:
- lib/bridgetown-core/readers/defaults_reader.rb
Instance Attribute Summary collapse
-
#path_defaults ⇒ Object
readonly
Returns the value of attribute path_defaults.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
-
#initialize(site) ⇒ DefaultsReader
constructor
A new instance of DefaultsReader.
- #read ⇒ Object
Constructor Details
#initialize(site) ⇒ DefaultsReader
Returns a new instance of DefaultsReader.
7 8 9 10 |
# File 'lib/bridgetown-core/readers/defaults_reader.rb', line 7 def initialize(site) @site = site @path_defaults = HashWithDotAccess::Hash.new end |
Instance Attribute Details
#path_defaults ⇒ Object (readonly)
Returns the value of attribute path_defaults.
5 6 7 |
# File 'lib/bridgetown-core/readers/defaults_reader.rb', line 5 def path_defaults @path_defaults end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
5 6 7 |
# File 'lib/bridgetown-core/readers/defaults_reader.rb', line 5 def site @site end |
Instance Method Details
#read ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bridgetown-core/readers/defaults_reader.rb', line 12 def read return unless File.directory?(site.source) entries = Dir.chdir(site.source) do Dir["**/_defaults.{yaml,yml,json}"] end entries.each do |entry| path = @site.in_source_dir(entry) @path_defaults[File.dirname(path) + File::SEPARATOR] = YAMLParser.load_file(path) end @path_defaults end |