Class: Proton::Config
- Inherits:
-
Object
- Object
- Proton::Config
- Defined in:
- lib/proton/config.rb
Overview
Constant Summary collapse
- DEFAULTS =
{ :site_path => '.', :layouts_path => '_layouts', :extensions_path => '_extensions', :partials_path => '_layouts', :output_path => '_output', :tilt_options => { :haml => { :escape_html => true }, :sass => { :load_paths => ['css', '.'], :style => :compact, :line_numbers => true }, :scss => { :load_paths => ['css', '.'], :style => :compact, :line_numbers => true }, }, :tilt_build_options => { :scss => { :style => :compressed, :line_numbers => false }, :sass => { :style => :compressed, :line_numbers => false } } }
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
-
#method_missing(meth, *args, &blk) ⇒ Object
Passthru.
- #requirement ⇒ Object
-
#tilt_options(what, key = :tilt_options) ⇒ Object
Method: tilt_options (Proton::Config) Returns tilt options for a given engine.
-
#tilt_options_for(file, options = {}) ⇒ Object
Method: tilt_options_for (Proton::Config) Returns tilt options for a given file.
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
61 62 63 64 65 66 67 |
# File 'lib/proton/config.rb', line 61 def initialize(={}) # Try to emulate proper .merge behavior in Ruby 1.8 #DEFAULTS.each { |k, v| options[k] ||= v } @table = Hashie::Mash.new @table.deep_merge! DEFAULTS @table.deep_merge! end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object
Passthru
70 71 72 |
# File 'lib/proton/config.rb', line 70 def method_missing(meth, *args, &blk) @table.send meth, *args end |
Class Method Details
.load(config_file) ⇒ Object
57 58 59 |
# File 'lib/proton/config.rb', line 57 def self.load(config_file) new(YAML::load_file(config_file)) rescue new end |
Instance Method Details
#requirement ⇒ Object
74 75 76 77 78 |
# File 'lib/proton/config.rb', line 74 def requirement # Backward compatibility; this config option used to be called # `hyde_requirement` before the project was renamed to Proton. self[:requirement] || self[:hyde_requirement] end |
#tilt_options(what, key = :tilt_options) ⇒ Object
Method: tilt_options (Proton::Config) Returns tilt options for a given engine.
## Usage
(engine_name)
## Example
('haml') # { :escape_html => ... }
106 107 108 109 |
# File 'lib/proton/config.rb', line 106 def (what, key=:tilt_options) @table[key] ||= Hash.new @table[key][what.to_s] ||= Hash.new end |
#tilt_options_for(file, options = {}) ⇒ Object
Method: tilt_options_for (Proton::Config) Returns tilt options for a given file.
## Usage
(filename, ={})
## Example
('index.haml') # { :escape_html => ... }
89 90 91 92 93 94 95 |
# File 'lib/proton/config.rb', line 89 def (file, ={}) ext = file.split('.').last.downcase opts = (ext) || Hash.new opts = opts.merge((ext, :tilt_build_options)) if [:build] to_hash opts end |