redis-settings 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source "http://gems.simplesideias.com.br"
1
+ source :rubygems
2
2
  gemspec
data/Gemfile.lock CHANGED
@@ -1,65 +1,50 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-settings (0.2.1)
4
+ redis-settings (0.2.2)
5
5
  redis
6
6
 
7
7
  GEM
8
- remote: http://gems.simplesideias.com.br/
8
+ remote: http://rubygems.org/
9
9
  specs:
10
- activemodel (3.0.9)
11
- activesupport (= 3.0.9)
12
- builder (~> 2.1.2)
13
- i18n (~> 0.5.0)
14
- activerecord (3.0.9)
15
- activemodel (= 3.0.9)
16
- activesupport (= 3.0.9)
17
- arel (~> 2.0.10)
18
- tzinfo (~> 0.3.23)
19
- activesupport (3.0.9)
20
- archive-tar-minitar (0.5.2)
21
- arel (2.0.10)
22
- builder (2.1.2)
23
- columnize (0.3.3)
24
- diff-lcs (1.1.2)
25
- i18n (0.5.0)
26
- linecache19 (0.5.12)
27
- ruby_core_source (>= 0.1.4)
28
- rake (0.8.7)
29
- redis (2.2.1)
30
- redis-namespace (1.0.3)
31
- redis (< 3.0.0)
32
- rspec (2.6.0)
33
- rspec-core (~> 2.6.0)
34
- rspec-expectations (~> 2.6.0)
35
- rspec-mocks (~> 2.6.0)
36
- rspec-core (2.6.4)
37
- rspec-expectations (2.6.0)
38
- diff-lcs (~> 1.1.2)
39
- rspec-mocks (2.6.0)
40
- ruby-debug-base19 (0.11.25)
41
- columnize (>= 0.3.1)
42
- linecache19 (>= 0.5.11)
43
- ruby_core_source (>= 0.1.4)
44
- ruby-debug19 (0.11.6)
45
- columnize (>= 0.3.1)
46
- linecache19 (>= 0.5.11)
47
- ruby-debug-base19 (>= 0.11.19)
48
- ruby_core_source (0.1.5)
49
- archive-tar-minitar (>= 0.5.2)
50
- sqlite3 (1.3.3)
51
- sqlite3-ruby (1.3.3)
52
- sqlite3 (>= 1.3.3)
53
- tzinfo (0.3.28)
10
+ activemodel (3.2.11)
11
+ activesupport (= 3.2.11)
12
+ builder (~> 3.0.0)
13
+ activerecord (3.2.11)
14
+ activemodel (= 3.2.11)
15
+ activesupport (= 3.2.11)
16
+ arel (~> 3.0.2)
17
+ tzinfo (~> 0.3.29)
18
+ activesupport (3.2.11)
19
+ i18n (~> 0.6)
20
+ multi_json (~> 1.0)
21
+ arel (3.0.2)
22
+ builder (3.0.4)
23
+ diff-lcs (1.1.3)
24
+ i18n (0.6.1)
25
+ multi_json (1.5.0)
26
+ rake (10.0.3)
27
+ redis (3.0.2)
28
+ redis-namespace (1.2.1)
29
+ redis (~> 3.0.0)
30
+ rspec (2.12.0)
31
+ rspec-core (~> 2.12.0)
32
+ rspec-expectations (~> 2.12.0)
33
+ rspec-mocks (~> 2.12.0)
34
+ rspec-core (2.12.2)
35
+ rspec-expectations (2.12.1)
36
+ diff-lcs (~> 1.1.3)
37
+ rspec-mocks (2.12.2)
38
+ sqlite3 (1.3.7)
39
+ tzinfo (0.3.35)
54
40
 
55
41
  PLATFORMS
56
42
  ruby
57
43
 
58
44
  DEPENDENCIES
59
45
  activerecord
60
- rake (~> 0.8.7)
46
+ rake
61
47
  redis-namespace
62
48
  redis-settings!
63
- rspec (~> 2.6)
64
- ruby-debug19
65
- sqlite3-ruby
49
+ rspec
50
+ sqlite3
@@ -66,7 +66,7 @@ class Redis
66
66
  value = payload["data"]
67
67
  end
68
68
 
69
- value || default
69
+ value.nil? ? default : value
70
70
  end
71
71
 
72
72
  # Define a value for the specified setting.
@@ -3,7 +3,7 @@ class Redis
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 2
6
- PATCH = 1
6
+ PATCH = 2
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  end
9
9
  end
@@ -1,6 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "redis/settings/version"
2
+ require "./lib/redis/settings/version"
4
3
 
5
4
  Gem::Specification.new do |s|
6
5
  s.name = "redis-settings"
@@ -8,7 +7,7 @@ Gem::Specification.new do |s|
8
7
  s.platform = Gem::Platform::RUBY
9
8
  s.authors = ["Nando Vieira"]
10
9
  s.email = ["fnando.vieira@gmail.com"]
11
- s.homepage = ""
10
+ s.homepage = "http://github.com/fnando/redis-settings"
12
11
  s.summary = %[Store application and user settings on Redis. Comes with ActiveRecord support.]
13
12
  s.description = s.summary
14
13
 
@@ -18,10 +17,9 @@ Gem::Specification.new do |s|
18
17
  s.require_paths = ["lib"]
19
18
 
20
19
  s.add_dependency "redis"
21
- s.add_development_dependency "rake", "~> 0.8.7"
22
- s.add_development_dependency "rspec", "~> 2.6"
23
- s.add_development_dependency "ruby-debug19"
20
+ s.add_development_dependency "rake"
21
+ s.add_development_dependency "rspec"
24
22
  s.add_development_dependency "activerecord"
25
23
  s.add_development_dependency "redis-namespace"
26
- s.add_development_dependency "sqlite3-ruby"
24
+ s.add_development_dependency "sqlite3"
27
25
  end
@@ -1,25 +1,27 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Redis::Settings do
4
- subject { Redis::Settings.new("app") }
4
+ subject(:settings) { Redis::Settings.new("app") }
5
5
  let(:redis) { Redis::Settings.connection }
6
6
 
7
7
  before do
8
- subject.clear
8
+ settings.clear
9
9
  end
10
10
 
11
11
  describe "#all" do
12
12
  it "returns all settings" do
13
- subject[:items] = 10
14
- subject[:enabled] = true
13
+ settings[:items] = 10
14
+ settings[:enabled] = true
15
15
 
16
- subject.all.should == {:items => 10, :enabled => true}
16
+ expect(settings.all).to eq(:items => 10, :enabled => true)
17
17
  end
18
18
  end
19
19
 
20
20
  describe ".configure" do
21
21
  it "yields module" do
22
- Redis::Settings.configure {|config| config.should be(Redis::Settings)}
22
+ expect {|block|
23
+ Redis::Settings.configure(&block)
24
+ }.to yield_with_args(Redis::Settings)
23
25
  end
24
26
  end
25
27
 
@@ -28,82 +30,102 @@ describe Redis::Settings do
28
30
  after { Redis::Settings.root_namespace = "settings" }
29
31
 
30
32
  it "uses custom namespace" do
31
- subject.namespace.should == "settings/development/app"
33
+ expect(settings.namespace).to eq("settings/development/app")
32
34
  end
33
35
 
34
36
  it "sets value using custom namespace" do
35
- subject[:items] = 10
36
- JSON.parse(redis.hget("settings/development/app", :items)).should == {"data" => 10}
37
+ settings[:items] = 10
38
+ payload = JSON.parse(
39
+ redis.hget("settings/development/app", :items)
40
+ )
41
+
42
+ expect(payload).to eq("data" => 10)
37
43
  end
38
44
  end
39
45
 
40
46
  describe "#namespace" do
41
47
  it "includes settings as namespace root" do
42
- subject.namespace.should == "settings/app"
48
+ expect(settings.namespace).to eq("settings/app")
43
49
  end
44
50
  end
45
51
 
46
52
  describe "#set" do
47
53
  it "sets value" do
48
- subject.set(:items, 5)
49
- JSON.parse(redis.hget(subject.namespace, :items)).should == {"data" => 5}
54
+ settings.set(:items, 5)
55
+ payload = JSON.parse(
56
+ redis.hget(settings.namespace, :items)
57
+ )
58
+
59
+ expect(payload).to eq("data" => 5)
50
60
  end
51
61
 
52
62
  it "has shortcut" do
53
- subject[:items] = 10
54
- JSON.parse(redis.hget(subject.namespace, :items)).should == {"data" => 10}
63
+ settings[:items] = 10
64
+ payload = JSON.parse(
65
+ redis.hget(settings.namespace, :items)
66
+ )
67
+
68
+ expect(payload).to eq("data" => 10)
55
69
  end
56
70
 
57
71
  it "removes setting when assigning nil" do
58
- subject[:items] = 20
59
- subject[:items] = nil
60
- redis.hget(subject.namespace, :items).should be_nil
72
+ settings[:items] = 20
73
+ settings[:items] = nil
74
+
75
+ expect(redis.hget(settings.namespace, :items)).to be_nil
61
76
  end
62
77
  end
63
78
 
64
79
  describe "#remove" do
65
80
  it "removes option" do
66
- subject[:items] = 20
67
- subject.remove(:items)
68
- redis.hget(subject.namespace, :items).should be_nil
81
+ settings[:items] = 20
82
+ settings.remove(:items)
83
+
84
+ expect(redis.hget(settings.namespace, :items)).to be_nil
69
85
  end
70
86
 
71
87
  it "has alias" do
72
- subject[:items] = 20
73
- subject.delete(:items)
74
- redis.hget(subject.namespace, :items).should be_nil
88
+ settings[:items] = 20
89
+ settings.delete(:items)
90
+
91
+ expect(redis.hget(settings.namespace, :items)).to be_nil
75
92
  end
76
93
  end
77
94
 
78
95
  describe "#get" do
79
96
  it "gets value" do
80
- subject.set(:items, 5)
81
- subject.get(:items).should == 5
97
+ settings.set(:items, 5)
98
+ expect(settings.get(:items)).to eq(5)
82
99
  end
83
100
 
84
101
  it "has #[] alias" do
85
- subject[:items] = 10
86
- subject[:items].should == 10
102
+ settings[:items] = 10
103
+ expect(settings[:items]).to eq(10)
87
104
  end
88
105
 
89
106
  it "has #fetch alias" do
90
- subject[:items] = 10
91
- subject.fetch(:items).should == 10
107
+ settings[:items] = 10
108
+ expect(settings.fetch(:items)).to eq(10)
92
109
  end
93
110
 
94
111
  it "returns default value" do
95
- subject[:items] = nil
96
- subject.get(:items, 15).should == 15
112
+ settings[:items] = nil
113
+ expect(settings.get(:items, 15)).to eq(15)
114
+ end
115
+
116
+ it "returns false as default value" do
117
+ settings[:item] = false
118
+ expect(settings.get(:item, true)).to eq(false)
97
119
  end
98
120
  end
99
121
 
100
122
  describe "#clear" do
101
123
  it "removes all settings" do
102
- subject[:items] = 5
124
+ settings[:items] = 5
103
125
 
104
- redis.hgetall(subject.namespace).should_not be_empty
105
- subject.clear
106
- redis.hgetall(subject.namespace).should be_empty
126
+ expect(redis.hgetall(settings.namespace)).not_to be_empty
127
+ settings.clear
128
+ expect(redis.hgetall(settings.namespace)).to be_empty
107
129
  end
108
130
  end
109
131
  end
data/spec/support/user.rb CHANGED
@@ -3,6 +3,6 @@ end
3
3
 
4
4
  module Admin
5
5
  class User < ActiveRecord::Base
6
- set_table_name "users"
6
+ self.table_name = "users"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,104 +1,120 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: redis-settings
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
4
5
  prerelease:
5
- version: 0.2.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Nando Vieira
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-07-15 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2013-02-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: redis
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
27
31
  name: rake
28
- requirement: &id002 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
29
33
  none: false
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: 0.8.7
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
38
47
  name: rspec
39
- requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
40
49
  none: false
41
- requirements:
42
- - - ~>
43
- - !ruby/object:Gem::Version
44
- version: "2.6"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
45
54
  type: :development
46
55
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: ruby-debug19
50
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
51
57
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: "0"
56
- type: :development
57
- prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
60
63
  name: activerecord
61
- requirement: &id005 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
62
65
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
67
70
  type: :development
68
71
  prerelease: false
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
71
79
  name: redis-namespace
72
- requirement: &id006 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
73
81
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: "0"
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
78
86
  type: :development
79
87
  prerelease: false
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
82
- name: sqlite3-ruby
83
- requirement: &id007 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: sqlite3
96
+ requirement: !ruby/object:Gem::Requirement
84
97
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: "0"
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
89
102
  type: :development
90
103
  prerelease: false
91
- version_requirements: *id007
92
- description: Store application and user settings on Redis. Comes with ActiveRecord support.
93
- email:
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: Store application and user settings on Redis. Comes with ActiveRecord
111
+ support.
112
+ email:
94
113
  - fnando.vieira@gmail.com
95
114
  executables: []
96
-
97
115
  extensions: []
98
-
99
116
  extra_rdoc_files: []
100
-
101
- files:
117
+ files:
102
118
  - .gitignore
103
119
  - .rspec
104
120
  - Gemfile
@@ -115,41 +131,28 @@ files:
115
131
  - spec/redis/settings_spec.rb
116
132
  - spec/spec_helper.rb
117
133
  - spec/support/user.rb
118
- homepage: ""
134
+ homepage: http://github.com/fnando/redis-settings
119
135
  licenses: []
120
-
121
136
  post_install_message:
122
137
  rdoc_options: []
123
-
124
- require_paths:
138
+ require_paths:
125
139
  - lib
126
- required_ruby_version: !ruby/object:Gem::Requirement
140
+ required_ruby_version: !ruby/object:Gem::Requirement
127
141
  none: false
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- hash: 1544773941053479143
132
- segments:
133
- - 0
134
- version: "0"
135
- required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ! '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
147
  none: false
137
- requirements:
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- hash: 1544773941053479143
141
- segments:
142
- - 0
143
- version: "0"
148
+ requirements:
149
+ - - ! '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
144
152
  requirements: []
145
-
146
153
  rubyforge_project:
147
- rubygems_version: 1.8.5
154
+ rubygems_version: 1.8.25
148
155
  signing_key:
149
156
  specification_version: 3
150
157
  summary: Store application and user settings on Redis. Comes with ActiveRecord support.
151
- test_files:
152
- - spec/redis/settings/active_record_spec.rb
153
- - spec/redis/settings_spec.rb
154
- - spec/spec_helper.rb
155
- - spec/support/user.rb
158
+ test_files: []