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
- .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
47 48 49 |
# File 'lib/configuration.rb', line 47 def self.links_file_path File.join config['path'], "links.md" end |
.read_config(location, local) ⇒ Object
21 22 23 24 |
# File 'lib/configuration.rb', line 21 def self.read_config location, local Configuration.read_configuration location, local Configuration.read_default_links end |
.read_configuration(location, local) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/configuration.rb', line 26 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
35 36 37 |
# File 'lib/configuration.rb', line 35 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 |
.valid_location?(location) ⇒ Boolean
39 40 41 42 43 44 45 |
# File 'lib/configuration.rb', line 39 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 |