Class: ZAssets::Config
- Inherits:
-
Object
- Object
- ZAssets::Config
- Defined in:
- lib/zassets/config.rb
Constant Summary collapse
- DEFAULT_CONFIG_PATH =
'config/zassets.yaml'.freeze
- DEFAULT_OPTIONS =
{ verbose: false, host: '::1', port: 9292, plugins: [], engines: {}, base_url: '/assets', paths: %w[app], public_path: 'public', build_path: 'public/assets', build: [] }.freeze
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #default_config_file? ⇒ Boolean
- #default_options ⇒ Object
-
#initialize(**options) ⇒ Config
constructor
A new instance of Config.
- #load_options(filepath = DEFAULT_CONFIG_PATH) ⇒ Object
- #register_plugins! ⇒ Object
Constructor Details
#initialize(**options) ⇒ Config
Returns a new instance of Config.
20 21 22 23 24 25 26 27 |
# File 'lib/zassets/config.rb', line 20 def initialize ** o = o.merge! if default_config_file? o.merge! ([:config_file]) if [:config_file] o.merge! = o register_plugins! end |
Instance Method Details
#[](key) ⇒ Object
50 51 52 |
# File 'lib/zassets/config.rb', line 50 def [] key [key] end |
#[]=(key, value) ⇒ Object
54 55 56 |
# File 'lib/zassets/config.rb', line 54 def []= key, value [key] = value end |
#default_config_file? ⇒ Boolean
38 39 40 |
# File 'lib/zassets/config.rb', line 38 def default_config_file? File.exist?(DEFAULT_CONFIG_PATH) end |
#default_options ⇒ Object
29 30 31 |
# File 'lib/zassets/config.rb', line 29 def DEFAULT_OPTIONS.dup end |
#load_options(filepath = DEFAULT_CONFIG_PATH) ⇒ Object
33 34 35 36 |
# File 'lib/zassets/config.rb', line 33 def filepath = DEFAULT_CONFIG_PATH return {} unless = YAML.load_file(filepath) symbolize_keys end |
#register_plugins! ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/zassets/config.rb', line 42 def register_plugins! return unless load_plugins! ::ZAssets::Plugins.constants.each do |plugin_module_name| plugin_module = ::ZAssets::Plugins.const_get(plugin_module_name) plugin_module::Registrant.new(self).register end end |