Class: Zmeygo::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/zmeygo/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/zmeygo/configuration.rb', line 10

def initialize
    src_file = File.join(File.dirname(__FILE__),'../..','templates','zmeygo.yml.template')
    dest_dir = File.dirname(File.expand_path(Constant::DEFAULT_CONFIG_FILE))
    dest_file = File.expand_path(Constant::DEFAULT_CONFIG_FILE)

    unless File.exists?(dest_file)
      puts "making folder #{dest_dir}"
      FileUtils.mkdir dest_dir
      system "cp #{src_file} #{dest_file}"
    end

    conf_all = YAML.load_file(File.expand_path(dest_file))

	#TODO: change env to vailue of either RAILS_ENV, RACK_ENV or ZMEYGO_ENV
	env = 'development'
	conf = conf_all[env]

	self.server = conf['server']
	self.api_token = conf['api_token']
	self.locale_dir = conf['locale_dir']
	self.default_project = conf['default_project']
end

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



8
9
10
# File 'lib/zmeygo/configuration.rb', line 8

def api_token
  @api_token
end

#default_projectObject

Returns the value of attribute default_project.



8
9
10
# File 'lib/zmeygo/configuration.rb', line 8

def default_project
  @default_project
end

#locale_dirObject

Returns the value of attribute locale_dir.



8
9
10
# File 'lib/zmeygo/configuration.rb', line 8

def locale_dir
  @locale_dir
end

#serverObject

Returns the value of attribute server.



8
9
10
# File 'lib/zmeygo/configuration.rb', line 8

def server
  @server
end

Instance Method Details

#[](key) ⇒ Object



33
34
35
36
37
# File 'lib/zmeygo/configuration.rb', line 33

def [](key)
	if self.respond_to?(key)
		send(key)
	end
end