Class: Hyde::Config
- Inherits:
-
Object
- Object
- Hyde::Config
- Defined in:
- lib/hyde/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.
-
#tilt_options(what, key = :tilt_options) ⇒ Object
Method: tilt_options (Hyde::Config) Returns tilt options for a given engine.
-
#tilt_options_for(file, options = {}) ⇒ Object
Method: tilt_options_for (Hyde::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/hyde/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/hyde/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/hyde/config.rb', line 57 def self.load(config_file) new(YAML::load_file(config_file)) rescue new end |
Instance Method Details
#tilt_options(what, key = :tilt_options) ⇒ Object
Method: tilt_options (Hyde::Config) Returns tilt options for a given engine.
## Usage
(engine_name)
## Example
('haml') # { :escape_html => ... }
100 101 102 103 |
# File 'lib/hyde/config.rb', line 100 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 (Hyde::Config) Returns tilt options for a given file.
## Usage
(filename, ={})
## Example
('index.haml') # { :escape_html => ... }
83 84 85 86 87 88 89 |
# File 'lib/hyde/config.rb', line 83 def (file, ={}) ext = file.split('.').last.downcase opts = (ext) || Hash.new opts = opts.merge((ext, :tilt_build_options)) if [:build] to_hash opts end |