scoped_choices 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -8,11 +8,8 @@ Easy-peasy external settings for your Rails app.
8
8
 
9
9
  In your app initializer block:
10
10
 
11
- config.from_file 'settings.yml'
12
-
13
- #to scope out your settings
14
11
  # Rails.configuration.my_engine...
15
- config.from_file_with_scope 'settings.yml', "my_engine"
12
+ config.from_file_with_scope 'settings.yml', "my_scope"
16
13
 
17
14
  This will read configuration from "config/settings.yml" and, additionally, "settings.local.yml" if it exists. You should check the main file into version control, but not the ".local" file which is to be used for per-machine configuration: tweaks in development or private keys in production, for example.
18
15
 
@@ -49,5 +46,5 @@ The ".local" file can contain overrides for your development environment:
49
46
 
50
47
  Finally, the config keys can be read in your app as such:
51
48
 
52
- Rails.configuration.heroku #=> false
53
- Rails.configuration.mongodb.database #=> "myapp_dev"
49
+ Rails.configuration.my_scope.heroku #=> false
50
+ Rails.configuration.my_scope.mongodb.database #=> "myapp_dev"
@@ -28,7 +28,8 @@ module ScopedChoices
28
28
  end
29
29
 
30
30
  def yaml_load(content)
31
- if defined? YAML::ENGINE
31
+ ruby_major_version = RUBY_VERSION.split('.').first.to_i
32
+ if ruby_major_version < 2 && defined? YAML::ENGINE
32
33
  # avoid using broken Psych in 1.9.2
33
34
  old_yamler = YAML::ENGINE.yamler
34
35
  YAML::ENGINE.yamler = 'syck'
@@ -36,7 +37,9 @@ module ScopedChoices
36
37
  begin
37
38
  YAML::load(content)
38
39
  ensure
39
- YAML::ENGINE.yamler = old_yamler if defined? YAML::ENGINE
40
+ if ruby_major_version < 2 && defined? YAML::ENGINE
41
+ YAML::ENGINE.yamler = old_yamler
42
+ end
40
43
  end
41
44
  end
42
45
  end
@@ -18,9 +18,11 @@ module ScopedChoices::Rails
18
18
  file = root + 'config' + name
19
19
 
20
20
  settings = ScopedChoices.load_settings(file, Rails.respond_to?(:env) ? Rails.env : RAILS_ENV)
21
- scoped_settings = Hashie::Mash.new
22
- scoped_settings.send("#{scope}=", settings)
23
- settings = scoped_settings
21
+ if scope
22
+ scoped_settings = Hashie::Mash.new
23
+ scoped_settings.send("#{scope}=", settings)
24
+ settings = scoped_settings
25
+ end
24
26
  @scoped_choices.update settings
25
27
 
26
28
  settings.each do |key, value|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scoped_choices
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-02 00:00:00.000000000Z
13
+ date: 2013-05-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hashie
17
- requirement: &70248575343200 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,12 @@ dependencies:
22
22
  version: 0.4.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70248575343200
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: 0.4.0
26
31
  description: Based off Mislav's choices gem allows for scoping your configuration
27
32
  email: samer@onekingslane.com
28
33
  executables: []
@@ -54,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
59
  version: '0'
55
60
  requirements: []
56
61
  rubyforge_project:
57
- rubygems_version: 1.8.17
62
+ rubygems_version: 1.8.25
58
63
  signing_key:
59
64
  specification_version: 3
60
65
  summary: Easy settings for your app