Module: Wst::Configuration
- Included in:
- Haml::Helpers::WltExtensions, Content, CssRenderer, JsRenderer, Renderer, Wst
- Defined in:
- lib/configuration.rb
Class Method Summary collapse
- .config ⇒ Object
- .defaultLinks ⇒ Object
- .links_file_path ⇒ Object
- .read_config(location, local) ⇒ Object
- .read_configuration(location, local) ⇒ Object
- .read_default_links ⇒ Object
- .read_translations ⇒ Object
- .translation_files ⇒ Object
- .valid_location?(location) ⇒ Boolean
Instance Method Summary collapse
Class Method Details
.config ⇒ Object
9 10 11 |
# File 'lib/configuration.rb', line 9 def self.config @config end |
.defaultLinks ⇒ Object
17 18 19 |
# File 'lib/configuration.rb', line 17 def self.defaultLinks @defaultLinks end |
.links_file_path ⇒ Object
57 58 59 |
# File 'lib/configuration.rb', line 57 def self.links_file_path File.join config['path'], "links.md" end |
.read_config(location, local) ⇒ Object
21 22 23 24 25 |
# File 'lib/configuration.rb', line 21 def self.read_config location, local Configuration.read_configuration location, local Configuration.read_default_links Configuration.read_translations end |
.read_configuration(location, local) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/configuration.rb', line 27 def self.read_configuration location, local raise "Not a valid Web Log Today location" unless self.valid_location? location @config = YAML.load File.open(File.join(location, 'config.yaml'), 'r:utf-8').read @config["__site_url__"] = @config["site_url"] @config["site_url"] = "http://localhost:4000" if local @config["path"] = location @config["debug"] = ENV['WST_ENV'] != nil && ENV['WST_ENV'].casecmp('debug').zero? end |
.read_default_links ⇒ Object
36 37 38 |
# File 'lib/configuration.rb', line 36 def self.read_default_links @defaultLinks = if File.exists? self.links_file_path then "\n" + File.open(self.links_file_path, "r:utf-8").read else "" end end |
.read_translations ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/configuration.rb', line 40 def self.read_translations @config['translations'] = {} self.translation_files.each do |file| translation = YAML.load File.open(file, 'r:utf-8').read lang = File.basename file, '.yaml' @config['translations'][lang] = translation end end |
.translation_files ⇒ Object
61 62 63 |
# File 'lib/configuration.rb', line 61 def self.translation_files Dir.glob File.join config['path'], "_translations", "**.yaml" end |
.valid_location?(location) ⇒ Boolean
49 50 51 52 53 54 55 |
# File 'lib/configuration.rb', line 49 def self.valid_location? location return false unless File.exists? File.join location, "config.yaml" return false unless File.directory? File.join location, "_posts" return false unless File.directory? File.join location, "_pages" return false unless File.directory? File.join location, "_layouts" return true end |
Instance Method Details
#config ⇒ Object
5 6 7 |
# File 'lib/configuration.rb', line 5 def config Configuration.config end |
#defaultLinks ⇒ Object
13 14 15 |
# File 'lib/configuration.rb', line 13 def defaultLinks Configuration.defaultLinks end |