Class: Recot::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/recot/config.rb

Constant Summary collapse

CONFIG_YML =
'config.yml'.freeze
KEY_THEME =
'theme'.freeze
KEY_PROJECT_NAME =
'project_name'.freeze
DEFAULT_THEME =
'white'.freeze

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



15
16
17
18
19
20
21
# File 'lib/recot/config.rb', line 15

def initialize
  # read config.yml file
  @config = nil
  if File.exist?("#{Dir.pwd}/#{CONFIG_YML}")
    @config = YAML.load_file("#{Dir.pwd}/#{CONFIG_YML}")
  end
end

Instance Method Details

#project_nameObject

Get project_name from config.yml.

Returns:

A project_name. If not set return empty.



39
40
41
42
43
44
45
# File 'lib/recot/config.rb', line 39

def project_name
  name = ''
  if @config && @config[KEY_PROJECT_NAME]
    name = @config[KEY_PROJECT_NAME]
  end
  name
end

#themeObject

Get theme from config.yml.

Returns:

A theme of html. If not set return ‘white’.



27
28
29
30
31
32
33
# File 'lib/recot/config.rb', line 27

def theme
  th = DEFAULT_THEME
  if @config && @config[KEY_THEME]
    th = @config[KEY_THEME]
  end
  th
end