setler 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -43,6 +43,9 @@ Set defaults in an initializer with something like:
43
43
 
44
44
  Featureflags.defaults[:bacon_dispenser_enabled] = false
45
45
  Settings.defaults[:allowed_meats] = ['itsnotbacon']
46
+
47
+ To revert to the default after changing a setting, destroy it.
48
+ Note: Updating the setting to nil or false no longer makes it the default setting (> 0.0.6), but changes the setting to nil or false.
46
49
 
47
50
  Add them to any ActiveRecord object:
48
51
 
data/contributors.txt ADDED
@@ -0,0 +1,4 @@
1
+ Chris Kelly github.com/ckdake
2
+ Andy Lindeman github.com/alindeman
3
+ Phil Ostler github.com/philostler
4
+ Rachel Heaton github.com/rheaton
@@ -22,7 +22,7 @@ module Setler
22
22
 
23
23
  def self.[](var)
24
24
  the_setting = thing_scoped.find_by_var(var.to_s)
25
- the_setting.try(:value) || @@defaults[var]
25
+ the_setting.present? ? the_setting.value : @@defaults[var]
26
26
  end
27
27
 
28
28
  def self.[]=(var, value)
@@ -1,3 +1,3 @@
1
1
  module Setler
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -41,7 +41,18 @@ class ::SettingsTest < Test::Unit::TestCase
41
41
  ::Settings.test = '321'
42
42
  assert_equal '321', ::Settings.test
43
43
  end
44
-
44
+
45
+ def test_update_with_false
46
+ ::Settings.test = false
47
+ assert_equal false, ::Settings.test
48
+ end
49
+
50
+ def test_update_with_nil_and_default_not_nil
51
+ ::Settings.defaults[:foo] = :test
52
+ ::Settings.foo = nil
53
+ assert_equal nil, ::Settings.foo
54
+ end
55
+
45
56
  def test_update_with_array_syntax
46
57
  ::Settings["test"] = '321'
47
58
  assert_equal '321', ::Settings.test
@@ -77,7 +88,15 @@ class ::SettingsTest < Test::Unit::TestCase
77
88
  ::Settings.destroy :test
78
89
  assert_nil ::Settings.test
79
90
  end
80
-
91
+
92
+ def test_destroy_reverts_to_default
93
+ ::Settings.defaults[:foo] = :test
94
+ ::Settings[:foo] = :bar
95
+
96
+ ::Settings.destroy :foo
97
+ assert_equal :test, ::Settings.foo
98
+ end
99
+
81
100
  def test_multiple_settings_classes
82
101
  ::Settings.testing = '123'
83
102
  assert_nil ::Preferences.testing
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: setler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-04 00:00:00.000000000Z
12
+ date: 2012-04-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70335468202960 !ruby/object:Gem::Requirement
16
+ requirement: &70289506810140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70335468202960
24
+ version_requirements: *70289506810140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails
27
- requirement: &70335468202460 !ruby/object:Gem::Requirement
27
+ requirement: &70289506809640 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70335468202460
35
+ version_requirements: *70289506809640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sqlite3
38
- requirement: &70335468202080 !ruby/object:Gem::Requirement
38
+ requirement: &70289506809260 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70335468202080
46
+ version_requirements: *70289506809260
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70335468231300 !ruby/object:Gem::Requirement
49
+ requirement: &70289506808800 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70335468231300
57
+ version_requirements: *70289506808800
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: cover_me
60
- requirement: &70335468230880 !ruby/object:Gem::Requirement
60
+ requirement: &70289506808380 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70335468230880
68
+ version_requirements: *70289506808380
69
69
  description: Setler is a Gem that lets one easily implement the "Feature Flags" pattern,
70
70
  or add settings to individual models. This is a cleanroom implementation of what
71
71
  the 'rails-settings' gem does. It's been forked all over the place, and my favorite
@@ -83,6 +83,7 @@ files:
83
83
  - MIT-LICENSE
84
84
  - README.rdoc
85
85
  - Rakefile
86
+ - contributors.txt
86
87
  - lib/generators/setler/setler_generator.rb
87
88
  - lib/generators/setler/templates/migration.rb
88
89
  - lib/generators/setler/templates/model.rb