Class: Nesta::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/nesta/config.rb

Defined Under Namespace

Classes: NotDefined

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.author_settingsObject

Returns the value of attribute author_settings.



21
22
23
# File 'lib/nesta/config.rb', line 21

def author_settings
  @author_settings
end

.settingsObject

Returns the value of attribute settings.



21
22
23
# File 'lib/nesta/config.rb', line 21

def settings
  @settings
end

.yaml_confObject

Returns the value of attribute yaml_conf.



21
22
23
# File 'lib/nesta/config.rb', line 21

def yaml_conf
  @yaml_conf
end

Class Method Details

.attachment_path(basename = nil) ⇒ Object



66
67
68
# File 'lib/nesta/config.rb', line 66

def self.attachment_path(basename = nil)
  get_path(File.join(content_path, "attachments"), basename)
end

.authorObject



42
43
44
45
46
47
48
49
50
51
# File 'lib/nesta/config.rb', line 42

def self.author
  environment_config = {}
  %w[name uri email].each do |setting|
    variable = "NESTA_AUTHOR__#{setting.upcase}"
    ENV[variable] && environment_config[setting] = ENV[variable]
  end
  environment_config.empty? ? from_yaml('author') : environment_config
rescue NotDefined
  nil
end

.cacheObject



53
54
55
56
# File 'lib/nesta/config.rb', line 53

def self.cache
  Nesta.deprecated('Nesta::Config.cache',
                   'see http://nestacms.com/docs/deployment/page-caching')
end

.content_path(basename = nil) ⇒ Object



58
59
60
# File 'lib/nesta/config.rb', line 58

def self.content_path(basename = nil)
  get_path(content, basename)
end

.fetch(key, *default) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/nesta/config.rb', line 24

def self.fetch(key, *default)
  from_environment(key.to_s)
rescue NotDefined
  begin
    from_yaml(key.to_s)
  rescue NotDefined
    default.empty? && raise || (return default.first)
  end
end

.method_missing(method, *args) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/nesta/config.rb', line 34

def self.method_missing(method, *args)
  if settings.include?(method.to_s)
    fetch(method, nil)
  else
    super
  end
end

.page_path(basename = nil) ⇒ Object



62
63
64
# File 'lib/nesta/config.rb', line 62

def self.page_path(basename = nil)
  get_path(File.join(content_path, "pages"), basename)
end

.read_moreObject



74
75
76
# File 'lib/nesta/config.rb', line 74

def self.read_more
  fetch('read_more', 'Continue reading')
end

.yaml_pathObject



70
71
72
# File 'lib/nesta/config.rb', line 70

def self.yaml_path
  File.expand_path('config/config.yml', Nesta::App.root)
end