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 +1 -1
- data/Gemfile.lock +35 -50
- data/lib/redis/settings.rb +1 -1
- data/lib/redis/settings/version.rb +1 -1
- data/redis-settings.gemspec +5 -7
- data/spec/redis/settings_spec.rb +57 -35
- data/spec/support/user.rb +1 -1
- metadata +96 -93
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source
|
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.
|
4
|
+
redis-settings (0.2.2)
|
5
5
|
redis
|
6
6
|
|
7
7
|
GEM
|
8
|
-
remote: http://
|
8
|
+
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (3.
|
11
|
-
activesupport (= 3.
|
12
|
-
builder (~>
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
arel (
|
22
|
-
builder (
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
rspec-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
rspec-
|
38
|
-
|
39
|
-
|
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
|
46
|
+
rake
|
61
47
|
redis-namespace
|
62
48
|
redis-settings!
|
63
|
-
rspec
|
64
|
-
|
65
|
-
sqlite3-ruby
|
49
|
+
rspec
|
50
|
+
sqlite3
|
data/lib/redis/settings.rb
CHANGED
data/redis-settings.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
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"
|
22
|
-
s.add_development_dependency "rspec"
|
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
|
24
|
+
s.add_development_dependency "sqlite3"
|
27
25
|
end
|
data/spec/redis/settings_spec.rb
CHANGED
@@ -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
|
-
|
8
|
+
settings.clear
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "#all" do
|
12
12
|
it "returns all settings" do
|
13
|
-
|
14
|
-
|
13
|
+
settings[:items] = 10
|
14
|
+
settings[:enabled] = true
|
15
15
|
|
16
|
-
|
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
|
-
|
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
|
-
|
33
|
+
expect(settings.namespace).to eq("settings/development/app")
|
32
34
|
end
|
33
35
|
|
34
36
|
it "sets value using custom namespace" do
|
35
|
-
|
36
|
-
JSON.parse(
|
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
|
-
|
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
|
-
|
49
|
-
JSON.parse(
|
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
|
-
|
54
|
-
JSON.parse(
|
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
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
73
|
-
|
74
|
-
|
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
|
-
|
81
|
-
|
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
|
-
|
86
|
-
|
102
|
+
settings[:items] = 10
|
103
|
+
expect(settings[:items]).to eq(10)
|
87
104
|
end
|
88
105
|
|
89
106
|
it "has #fetch alias" do
|
90
|
-
|
91
|
-
|
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
|
-
|
96
|
-
|
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
|
-
|
124
|
+
settings[:items] = 5
|
103
125
|
|
104
|
-
redis.hgetall(
|
105
|
-
|
106
|
-
redis.hgetall(
|
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
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
|
-
|
14
|
-
|
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:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements:
|
26
|
-
|
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:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
29
33
|
none: false
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
|
-
version_requirements:
|
37
|
-
|
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:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
40
49
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version:
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
45
54
|
type: :development
|
46
55
|
prerelease: false
|
47
|
-
version_requirements:
|
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:
|
56
|
-
|
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:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
62
65
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version:
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
67
70
|
type: :development
|
68
71
|
prerelease: false
|
69
|
-
version_requirements:
|
70
|
-
|
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:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
73
81
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version:
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
78
86
|
type: :development
|
79
87
|
prerelease: false
|
80
|
-
version_requirements:
|
81
|
-
|
82
|
-
|
83
|
-
|
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:
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
89
102
|
type: :development
|
90
103
|
prerelease: false
|
91
|
-
version_requirements:
|
92
|
-
|
93
|
-
|
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
|
-
|
132
|
-
|
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
|
-
|
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.
|
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: []
|