Class: Village::Config
- Inherits:
-
Object
- Object
- Village::Config
- Extended by:
- Attributes
- Defined in:
- lib/village/config.rb
Instance Attribute Summary
Attributes included from Attributes
Class Method Summary collapse
- .clone(*keys) ⇒ Object
- .default_attributes ⇒ Object
- .initialize_configurations(path = "#{Rails.root}/config/village_config.yml") ⇒ Object
- .village_permalink_regex(options) ⇒ Object
Class Method Details
.clone(*keys) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/village/config.rb', line 30 def self.clone(*keys) unless @attributes.nil? = @attributes.clone .keep_if { |key,value| keys.include?(key.to_sym) } unless keys.nil? else {} end end |
.default_attributes ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/village/config.rb', line 14 def self.default_attributes { :permalink_regex => { :day => %r[\d{4}/\d{2}/\d{2}/[^/]+], :month => %r[\d{4}/\d{2}/[^/]+], :year => %r[\d{4}/[^/]+], :slug => %r[[^/]+] }, :permalink_format => :day, :file_extensions => ["markdown", "erb", "haml"], :layout => "village", :page_size => 10 } end |
.initialize_configurations(path = "#{Rails.root}/config/village_config.yml") ⇒ Object
7 8 9 10 11 12 |
# File 'lib/village/config.rb', line 7 def self.initialize_configurations(path = "#{Rails.root}/config/village_config.yml") if File.exists? path and @attributes.nil? @attributes = YAML::load(IO.read(path)).with_indifferent_access @attributes.reverse_merge!(default_attributes) end end |
.village_permalink_regex(options) ⇒ Object
40 41 42 43 |
# File 'lib/village/config.rb', line 40 def self.village_permalink_regex() @attributes[:permalink_format] = [:permalink_format] @attributes[:permalink_regex].try(:[], [:permalink_format]) or raise_village_permalink_error end |