configliere 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
data/configliere.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{configliere}
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mrflip"]
12
- s.date = %q{2011-03-07}
12
+ s.date = %q{2011-04-02}
13
13
  s.default_executable = %q{configliere}
14
14
  s.description = %q{ You've got a script. It's got some settings. Some settings are for this module, some are for that module. Most of them don't change. Except on your laptop, where the paths are different. Or when you're in production mode. Or when you're testing from the command line.
15
15
 
@@ -13,7 +13,16 @@ module Configliere
13
13
  # Load params from disk.
14
14
  # * file is in YAML format, as a hash of handle => param_hash pairs
15
15
  # * filename defaults to Configliere::DEFAULT_CONFIG_FILE (~/.configliere, probably)
16
- def read handle
16
+ #
17
+ # @option [String] :env
18
+ # If an :env option is given, only the indicated subhash is merged. This
19
+ # lets you for example specify production / environment / test settings
20
+ #
21
+ # @example
22
+ # # Read from config/apey_eye.yaml and use settings appropriate for development/staging/production
23
+ # Settings.read(root_path('config/apey_eye.yaml'), :env => (ENV['RACK_ENV'] || 'production'))
24
+ #
25
+ def read handle, options={}
17
26
  filename = filename_for_handle(handle)
18
27
  begin
19
28
  params = YAML.load(File.open(filename)) || {}
@@ -22,6 +31,10 @@ module Configliere
22
31
  params = {}
23
32
  end
24
33
  params = params[handle] if handle.is_a?(Symbol)
34
+ # Extract the :env (production/development/etc)
35
+ if options[:env]
36
+ params = params[options[:env]]
37
+ end
25
38
  deep_merge! params
26
39
  end
27
40
 
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configliere
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 3
9
- - 2
10
- version: 0.3.2
8
+ - 3
9
+ version: 0.3.3
11
10
  platform: ruby
12
11
  authors:
13
12
  - mrflip
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-03-07 00:00:00 -06:00
17
+ date: 2011-04-02 00:00:00 -05:00
19
18
  default_executable: configliere
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 13
30
28
  segments:
31
29
  - 1
32
30
  - 2
@@ -42,7 +40,6 @@ dependencies:
42
40
  requirements:
43
41
  - - ">="
44
42
  - !ruby/object:Gem::Version
45
- hash: 3
46
43
  segments:
47
44
  - 0
48
45
  version: "0"
@@ -114,7 +111,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
111
  requirements:
115
112
  - - ">="
116
113
  - !ruby/object:Gem::Version
117
- hash: 3
118
114
  segments:
119
115
  - 0
120
116
  version: "0"
@@ -123,7 +119,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
119
  requirements:
124
120
  - - ">="
125
121
  - !ruby/object:Gem::Version
126
- hash: 3
127
122
  segments:
128
123
  - 0
129
124
  version: "0"