Module: Configer
- Extended by:
- Helpers
- Defined in:
- lib/configer/dsl.rb,
lib/configer/ext.rb,
lib/configer/cache.rb,
lib/configer/logic.rb,
lib/configer/mount.rb,
lib/configer/object.rb,
lib/configer/support.rb,
lib/configer/instance.rb
Defined Under Namespace
Modules: Cache, HashExtension, Helpers, ObjectEXT
Classes: Object
Class Method Summary
collapse
Methods included from Helpers
mount_config, mount_config_environments, mount_lib_meta, mount_lib_module_meta, mount_process, name_parser, parser, supported_formats
Class Method Details
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/configer/support.rb', line 18
def env
if defined?(Rails) && !Rails.env.nil?
return Rails.env.to_s
elsif !ENV['RAILS_ENV'].nil?
return ENV['RAILS_ENV'].to_s
elsif !ENV['RACK_ENV'].nil?
return ENV['RACK_ENV'].to_s
elsif !ENV['STAGE'].nil?
case ENV['STAGE'].to_s.downcase
when /^dev/
return 'development'
when /^test/
return 'test'
when /^prod/,/^stag/
return 'production'
else
return ENV['STAGE']
end
else
return ENV.find{|k,v|
%W[ production development ].include?(v.to_s)
} || 'development'
end
end
|
.mount_all(get_pwd = Configer.pwd) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/configer/mount.rb', line 4
def mount_all(get_pwd=Configer.pwd)
return [
mount_lib_meta(get_pwd),
mount_lib_module_meta(get_pwd),
mount_config(get_pwd),
mount_config_environments(get_pwd)
].reduce(Object.new){|m,o| m.deep_merge!(o) rescue nil ;m}
end
|
3
4
5
6
7
8
9
10
11
12
|
# File 'lib/configer/instance.rb', line 3
def self.new(pwd)
raise(
ArgumentError,
'Configer::Instance can only be made with valid folder path!'
) unless File.exist?(pwd)
return Object.parse(Configer.mount_all(pwd))
end
|
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/configer/support.rb', line 5
def pwd
if defined?(Rails) && !Rails.root.nil?
Rails.root.to_s
elsif ENV['BUNDLE_GEMFILE']
ENV['BUNDLE_GEMFILE'].split(File::Separator)[0..-2].join(File::Separator)
else
Dir.pwd.to_s
end
end
|