Class: Nanoc::Int::Configuration Private
- Inherits:
-
Object
- Object
- Nanoc::Int::Configuration
- Includes:
- ContractsSupport
- Defined in:
- lib/nanoc/base/entities/configuration.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents the site configuration.
Constant Summary collapse
- NONE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Object.new.freeze
- DEFAULT_DATA_SOURCE_CONFIG =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The default configuration for a data source. A data source’s configuration overrides these options.
{ type: 'filesystem', items_root: '/', layouts_root: '/', config: {}, identifier_type: 'full', }.freeze
- DEFAULT_CONFIG =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The default configuration for a site. A site’s configuration overrides these options: when a Site is created with a configuration that lacks some options, the default value will be taken from ‘DEFAULT_CONFIG`.
{ text_extensions: %w(adoc asciidoc atom css erb haml htm html js less markdown md php rb sass scss txt xhtml xml coffee hb handlebars mustache ms slim rdoc).sort, lib_dirs: %w(lib), commands_dirs: %w(commands), output_dir: 'output', data_sources: [{}], index_filenames: ['index.html'], enable_output_diff: false, prune: { auto_prune: false, exclude: ['.git', '.hg', '.svn', 'CVS'] }, string_pattern_type: 'glob', }.freeze
Instance Method Summary collapse
- #[](key) ⇒ Object private
- #[]=(key, value) ⇒ Object private
- #each ⇒ Object private
- #fetch(key, fallback = NONE, &_block) ⇒ Object private
- #freeze ⇒ Object private
-
#initialize(hash = {}) ⇒ Configuration
constructor
private
Creates a new configuration with the given hash.
- #inspect ⇒ Object private
- #key?(key) ⇒ Boolean private
- #merge(hash) ⇒ Object private
-
#reference ⇒ Object
private
Returns an object that can be used for uniquely identifying objects.
- #to_h ⇒ Object private
- #update(hash) ⇒ Object private
- #with_defaults ⇒ Object private
- #without(key) ⇒ Object private
Methods included from ContractsSupport
Constructor Details
#initialize(hash = {}) ⇒ Configuration
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new configuration with the given hash.
40 41 42 |
# File 'lib/nanoc/base/entities/configuration.rb', line 40 def initialize(hash = {}) @wrapped = hash.__nanoc_symbolize_keys_recursively end |
Instance Method Details
#[](key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 |
# File 'lib/nanoc/base/entities/configuration.rb', line 65 def [](key) @wrapped[key] end |
#[]=(key, value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
83 84 85 |
# File 'lib/nanoc/base/entities/configuration.rb', line 83 def []=(key, value) @wrapped[key] = value end |
#each ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
104 105 106 107 |
# File 'lib/nanoc/base/entities/configuration.rb', line 104 def each @wrapped.each { |k, v| yield(k, v) } self end |
#fetch(key, fallback = NONE, &_block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/nanoc/base/entities/configuration.rb', line 70 def fetch(key, fallback = NONE, &_block) @wrapped.fetch(key) do if !fallback.equal?(NONE) fallback elsif block_given? yield(key) else raise KeyError, "key not found: #{key.inspect}" end end end |
#freeze ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
110 111 112 113 114 |
# File 'lib/nanoc/base/entities/configuration.rb', line 110 def freeze super @wrapped.__nanoc_freeze_recursively self end |
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
123 124 125 |
# File 'lib/nanoc/base/entities/configuration.rb', line 123 def inspect "<#{self.class}>" end |
#key?(key) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
60 61 62 |
# File 'lib/nanoc/base/entities/configuration.rb', line 60 def key?(key) @wrapped.key?(key) end |
#merge(hash) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
88 89 90 |
# File 'lib/nanoc/base/entities/configuration.rb', line 88 def merge(hash) self.class.new(@wrapped.merge(hash.to_h)) end |
#reference ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an object that can be used for uniquely identifying objects.
119 120 121 |
# File 'lib/nanoc/base/entities/configuration.rb', line 119 def reference :config end |
#to_h ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/nanoc/base/entities/configuration.rb', line 55 def to_h @wrapped end |
#update(hash) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
98 99 100 101 |
# File 'lib/nanoc/base/entities/configuration.rb', line 98 def update(hash) @wrapped.update(hash) self end |
#with_defaults ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 48 49 50 51 52 |
# File 'lib/nanoc/base/entities/configuration.rb', line 45 def with_defaults new_wrapped = DEFAULT_CONFIG.merge(@wrapped) new_wrapped[:data_sources] = new_wrapped[:data_sources].map do |ds| DEFAULT_DATA_SOURCE_CONFIG.merge(ds) end self.class.new(new_wrapped) end |
#without(key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
93 94 95 |
# File 'lib/nanoc/base/entities/configuration.rb', line 93 def without(key) self.class.new(@wrapped.reject { |k, _v| k == key }) end |