Class: Dimples::Config
- Inherits:
-
Object
- Object
- Dimples::Config
- Defined in:
- lib/dimples/config.rb
Overview
Configuration settings for a site.
Constant Summary collapse
- SOURCE_PATHS =
{ pages: 'pages', posts: 'posts', layouts: 'layouts', static: 'static' }.freeze
Instance Attribute Summary collapse
-
#build_paths ⇒ Object
Returns the value of attribute build_paths.
-
#generation ⇒ Object
Returns the value of attribute generation.
-
#pagination ⇒ Object
Returns the value of attribute pagination.
-
#site ⇒ Object
Returns the value of attribute site.
-
#source_paths ⇒ Object
Returns the value of attribute source_paths.
Class Method Summary collapse
Instance Method Summary collapse
- #expand_paths(root, paths) ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dimples/config.rb', line 26 def initialize( = {}) = Config.defaults.to_h do |key, value| unless [key].nil? value = case [key] when Hash value.merge!([key]) else [key] end end [key, value] end @source_paths = (File.([:source]), SOURCE_PATHS.dup) @build_paths = (File.([:build]), [:pathnames]) @site = [:site] @pagination = [:pagination] @generation = [:generation] end |
Instance Attribute Details
#build_paths ⇒ Object
Returns the value of attribute build_paths.
13 14 15 |
# File 'lib/dimples/config.rb', line 13 def build_paths @build_paths end |
#generation ⇒ Object
Returns the value of attribute generation.
13 14 15 |
# File 'lib/dimples/config.rb', line 13 def generation @generation end |
#pagination ⇒ Object
Returns the value of attribute pagination.
13 14 15 |
# File 'lib/dimples/config.rb', line 13 def pagination @pagination end |
#site ⇒ Object
Returns the value of attribute site.
13 14 15 |
# File 'lib/dimples/config.rb', line 13 def site @site end |
#source_paths ⇒ Object
Returns the value of attribute source_paths.
13 14 15 |
# File 'lib/dimples/config.rb', line 13 def source_paths @source_paths end |
Class Method Details
.defaults ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dimples/config.rb', line 15 def self.defaults { source: Dir.pwd, build: './site', pathnames: { posts: 'posts', categories: 'categories' }, site: { name: nil, domain: nil }, pagination: { page_prefix: 'page_', per_page: 5 }, generation: { main_feed: true, category_feeds: false } } end |
Instance Method Details
#expand_paths(root, paths) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/dimples/config.rb', line 48 def (root, paths) root = File.(root) paths.transform_values! { |value| File.(File.join(root, value)) } paths.tap { || [:root] = root } end |