redis-settings 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --format documentation
data/Gemfile CHANGED
@@ -1,4 +1,2 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in redis-options.gemspec
1
+ source "http://gems.simplesideias.com.br"
4
2
  gemspec
data/Gemfile.lock CHANGED
@@ -1,41 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-settings (0.1.0)
4
+ redis-settings (0.2.0)
5
5
  redis
6
6
 
7
7
  GEM
8
- remote: http://rubygems.org/
8
+ remote: http://gems.simplesideias.com.br/
9
9
  specs:
10
- activemodel (3.0.1)
11
- activesupport (= 3.0.1)
10
+ activemodel (3.0.9)
11
+ activesupport (= 3.0.9)
12
12
  builder (~> 2.1.2)
13
- i18n (~> 0.4.1)
14
- activerecord (3.0.1)
15
- activemodel (= 3.0.1)
16
- activesupport (= 3.0.1)
17
- arel (~> 1.0.0)
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
18
  tzinfo (~> 0.3.23)
19
- activesupport (3.0.1)
19
+ activesupport (3.0.9)
20
20
  archive-tar-minitar (0.5.2)
21
- arel (1.0.1)
22
- activesupport (~> 3.0.0)
21
+ arel (2.0.10)
23
22
  builder (2.1.2)
24
- columnize (0.3.2)
23
+ columnize (0.3.3)
25
24
  diff-lcs (1.1.2)
26
- i18n (0.4.2)
27
- linecache19 (0.5.11)
25
+ i18n (0.5.0)
26
+ linecache19 (0.5.12)
28
27
  ruby_core_source (>= 0.1.4)
29
- redis (2.1.1)
30
- rspec (2.1.0)
31
- rspec-core (~> 2.1.0)
32
- rspec-expectations (~> 2.1.0)
33
- rspec-mocks (~> 2.1.0)
34
- rspec-core (2.1.0)
35
- rspec-expectations (2.1.0)
28
+ rake (0.8.7)
29
+ redis (2.2.1)
30
+ rspec (2.6.0)
31
+ rspec-core (~> 2.6.0)
32
+ rspec-expectations (~> 2.6.0)
33
+ rspec-mocks (~> 2.6.0)
34
+ rspec-core (2.6.4)
35
+ rspec-expectations (2.6.0)
36
36
  diff-lcs (~> 1.1.2)
37
- rspec-mocks (2.1.0)
38
- ruby-debug-base19 (0.11.24)
37
+ rspec-mocks (2.6.0)
38
+ ruby-debug-base19 (0.11.25)
39
39
  columnize (>= 0.3.1)
40
40
  linecache19 (>= 0.5.11)
41
41
  ruby_core_source (>= 0.1.4)
@@ -43,18 +43,20 @@ GEM
43
43
  columnize (>= 0.3.1)
44
44
  linecache19 (>= 0.5.11)
45
45
  ruby-debug-base19 (>= 0.11.19)
46
- ruby_core_source (0.1.4)
46
+ ruby_core_source (0.1.5)
47
47
  archive-tar-minitar (>= 0.5.2)
48
- sqlite3-ruby (1.3.2)
49
- tzinfo (0.3.23)
48
+ sqlite3 (1.3.3)
49
+ sqlite3-ruby (1.3.3)
50
+ sqlite3 (>= 1.3.3)
51
+ tzinfo (0.3.28)
50
52
 
51
53
  PLATFORMS
52
54
  ruby
53
55
 
54
56
  DEPENDENCIES
55
57
  activerecord
56
- redis
58
+ rake (~> 0.8.7)
57
59
  redis-settings!
58
- rspec (>= 2.0.0)
60
+ rspec (~> 2.6)
59
61
  ruby-debug19
60
62
  sqlite3-ruby
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- require 'bundler'
1
+ require "bundler"
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- require 'rspec/core/rake_task'
4
+ require "rspec/core/rake_task"
5
5
  RSpec::Core::RakeTask.new
@@ -82,6 +82,14 @@ class Redis
82
82
  end
83
83
  end
84
84
 
85
+ # Delete the specified option. Just a shortcut for <tt>settings.set(:name, nil)</tt>.
86
+ #
87
+ def remove(name)
88
+ set(name, nil)
89
+ end
90
+
91
+ alias_method :delete, :remove
92
+
85
93
  # Remove all settings from the current namespace
86
94
  def clear
87
95
  redis.del(namespace)
@@ -2,8 +2,8 @@ class Redis
2
2
  class Settings
3
3
  module Version
4
4
  MAJOR = 0
5
- MINOR = 1
6
- PATCH = 1
5
+ MINOR = 2
6
+ PATCH = 0
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  end
9
9
  end
@@ -18,7 +18,8 @@ Gem::Specification.new do |s|
18
18
  s.require_paths = ["lib"]
19
19
 
20
20
  s.add_dependency "redis"
21
- s.add_development_dependency "rspec", ">= 2.0.0"
21
+ s.add_development_dependency "rake", "~> 0.8.7"
22
+ s.add_development_dependency "rspec", "~> 2.6"
22
23
  s.add_development_dependency "ruby-debug19"
23
24
  s.add_development_dependency "activerecord"
24
25
  s.add_development_dependency "sqlite3-ruby"
@@ -10,22 +10,22 @@ describe Redis::Settings::ActiveRecord do
10
10
  admin.settings.clear
11
11
  end
12
12
 
13
- it "should inject settings method" do
13
+ it "injects settings method" do
14
14
  User.new.should respond_to(:settings)
15
15
  end
16
16
 
17
- it "should raise when trying to access settings from a new record" do
17
+ it "raises when trying to access settings from a new record" do
18
18
  expect {
19
19
  User.new.settings
20
20
  }.to raise_error(Redis::Settings::NewRecordError)
21
21
  end
22
22
 
23
- it "should set namespace accordingly" do
23
+ it "sets namespace accordingly" do
24
24
  user.settings.namespace.should == "#{root}/user/#{user.id}"
25
25
  admin.settings.namespace.should == "#{root}/admin/user/#{admin.id}"
26
26
  end
27
27
 
28
- it "should define setting" do
28
+ it "defines setting" do
29
29
  admin.settings[:role] = "admin"
30
30
  user.settings[:role] = "support"
31
31
 
@@ -33,7 +33,7 @@ describe Redis::Settings::ActiveRecord do
33
33
  admin.settings[:role].should == "admin"
34
34
  end
35
35
 
36
- it "should remove all settings when destroy a record" do
36
+ it "removes all settings when destroy a record" do
37
37
  user.settings[:role] = "customer"
38
38
  user.destroy
39
39
  Redis::Settings.connection.hgetall("#{root}/user/#{user.id}").should be_empty
@@ -9,7 +9,7 @@ describe Redis::Settings do
9
9
  end
10
10
 
11
11
  describe "#all" do
12
- it "should return all settings" do
12
+ it "returns all settings" do
13
13
  subject[:items] = 10
14
14
  subject[:enabled] = true
15
15
 
@@ -18,7 +18,7 @@ describe Redis::Settings do
18
18
  end
19
19
 
20
20
  describe ".configure" do
21
- it "should yield module" do
21
+ it "yields module" do
22
22
  Redis::Settings.configure {|config| config.should be(Redis::Settings)}
23
23
  end
24
24
  end
@@ -27,59 +27,73 @@ describe Redis::Settings do
27
27
  before { Redis::Settings.root_namespace = "settings/development" }
28
28
  after { Redis::Settings.root_namespace = "settings" }
29
29
 
30
- it "should use custom namespace" do
30
+ it "uses custom namespace" do
31
31
  subject.namespace.should == "settings/development/app"
32
32
  end
33
33
 
34
- it "should set value using custom namespace" do
34
+ it "sets value using custom namespace" do
35
35
  subject[:items] = 10
36
36
  JSON.parse(redis.hget("settings/development/app", :items)).should == {"data" => 10}
37
37
  end
38
38
  end
39
39
 
40
40
  describe "#namespace" do
41
- it "should include settings as namespace root" do
41
+ it "includes settings as namespace root" do
42
42
  subject.namespace.should == "settings/app"
43
43
  end
44
44
  end
45
45
 
46
46
  describe "#set" do
47
- it "should set value" do
47
+ it "sets value" do
48
48
  subject.set(:items, 5)
49
49
  JSON.parse(redis.hget(subject.namespace, :items)).should == {"data" => 5}
50
50
  end
51
51
 
52
- it "should have shortcut" do
52
+ it "has shortcut" do
53
53
  subject[:items] = 10
54
54
  JSON.parse(redis.hget(subject.namespace, :items)).should == {"data" => 10}
55
55
  end
56
56
 
57
- it "should remove setting when assigning nil" do
57
+ it "removes setting when assigning nil" do
58
58
  subject[:items] = 20
59
59
  subject[:items] = nil
60
60
  redis.hget(subject.namespace, :items).should be_nil
61
61
  end
62
62
  end
63
63
 
64
+ describe "#remove" do
65
+ it "removes option" do
66
+ subject[:items] = 20
67
+ subject.remove(:items)
68
+ redis.hget(subject.namespace, :items).should be_nil
69
+ end
70
+
71
+ it "has alias" do
72
+ subject[:items] = 20
73
+ subject.delete(:items)
74
+ redis.hget(subject.namespace, :items).should be_nil
75
+ end
76
+ end
77
+
64
78
  describe "#get" do
65
- it "should get value" do
79
+ it "gets value" do
66
80
  subject.set(:items, 5)
67
81
  subject.get(:items).should == 5
68
82
  end
69
83
 
70
- it "should have alias" do
84
+ it "has alias" do
71
85
  subject[:items] = 10
72
86
  subject[:items].should == 10
73
87
  end
74
88
 
75
- it "should return default value" do
89
+ it "returns default value" do
76
90
  subject[:items] = nil
77
91
  subject.get(:items, 15).should == 15
78
92
  end
79
93
  end
80
94
 
81
95
  describe "#clear" do
82
- it "should remove all settings" do
96
+ it "removes all settings" do
83
97
  subject[:items] = 5
84
98
 
85
99
  redis.hgetall(subject.namespace).should_not be_empty
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-settings
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 1
9
- version: 0.1.1
4
+ prerelease:
5
+ version: 0.2.0
10
6
  platform: ruby
11
7
  authors:
12
8
  - Nando Vieira
@@ -14,76 +10,74 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2010-11-18 00:00:00 -02:00
18
- default_executable:
13
+ date: 2011-06-22 00:00:00 Z
19
14
  dependencies:
20
15
  - !ruby/object:Gem::Dependency
21
16
  name: redis
22
- prerelease: false
23
17
  requirement: &id001 !ruby/object:Gem::Requirement
24
18
  none: false
25
19
  requirements:
26
20
  - - ">="
27
21
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
22
  version: "0"
31
23
  type: :runtime
24
+ prerelease: false
32
25
  version_requirements: *id001
33
26
  - !ruby/object:Gem::Dependency
34
- name: rspec
35
- prerelease: false
27
+ name: rake
36
28
  requirement: &id002 !ruby/object:Gem::Requirement
37
29
  none: false
38
30
  requirements:
39
- - - ">="
31
+ - - ~>
40
32
  - !ruby/object:Gem::Version
41
- segments:
42
- - 2
43
- - 0
44
- - 0
45
- version: 2.0.0
33
+ version: 0.8.7
46
34
  type: :development
35
+ prerelease: false
47
36
  version_requirements: *id002
48
37
  - !ruby/object:Gem::Dependency
49
- name: ruby-debug19
50
- prerelease: false
38
+ name: rspec
51
39
  requirement: &id003 !ruby/object:Gem::Requirement
52
40
  none: false
53
41
  requirements:
54
- - - ">="
42
+ - - ~>
55
43
  - !ruby/object:Gem::Version
56
- segments:
57
- - 0
58
- version: "0"
44
+ version: "2.6"
59
45
  type: :development
46
+ prerelease: false
60
47
  version_requirements: *id003
61
48
  - !ruby/object:Gem::Dependency
62
- name: activerecord
63
- prerelease: false
49
+ name: ruby-debug19
64
50
  requirement: &id004 !ruby/object:Gem::Requirement
65
51
  none: false
66
52
  requirements:
67
53
  - - ">="
68
54
  - !ruby/object:Gem::Version
69
- segments:
70
- - 0
71
55
  version: "0"
72
56
  type: :development
57
+ prerelease: false
73
58
  version_requirements: *id004
74
59
  - !ruby/object:Gem::Dependency
75
- name: sqlite3-ruby
76
- prerelease: false
60
+ name: activerecord
77
61
  requirement: &id005 !ruby/object:Gem::Requirement
78
62
  none: false
79
63
  requirements:
80
64
  - - ">="
81
65
  - !ruby/object:Gem::Version
82
- segments:
83
- - 0
84
66
  version: "0"
85
67
  type: :development
68
+ prerelease: false
86
69
  version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: sqlite3-ruby
72
+ requirement: &id006 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *id006
87
81
  description: Store application and user settings on Redis. Comes with ActiveRecord support.
88
82
  email:
89
83
  - fnando.vieira@gmail.com
@@ -95,6 +89,7 @@ extra_rdoc_files: []
95
89
 
96
90
  files:
97
91
  - .gitignore
92
+ - .rspec
98
93
  - Gemfile
99
94
  - Gemfile.lock
100
95
  - README.rdoc
@@ -109,7 +104,6 @@ files:
109
104
  - spec/redis/settings_spec.rb
110
105
  - spec/spec_helper.rb
111
106
  - spec/support/user.rb
112
- has_rdoc: true
113
107
  homepage: ""
114
108
  licenses: []
115
109
 
@@ -123,6 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
117
  requirements:
124
118
  - - ">="
125
119
  - !ruby/object:Gem::Version
120
+ hash: 3051372814580971106
126
121
  segments:
127
122
  - 0
128
123
  version: "0"
@@ -131,13 +126,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
126
  requirements:
132
127
  - - ">="
133
128
  - !ruby/object:Gem::Version
129
+ hash: 3051372814580971106
134
130
  segments:
135
131
  - 0
136
132
  version: "0"
137
133
  requirements: []
138
134
 
139
135
  rubyforge_project:
140
- rubygems_version: 1.3.7
136
+ rubygems_version: 1.8.5
141
137
  signing_key:
142
138
  specification_version: 3
143
139
  summary: Store application and user settings on Redis. Comes with ActiveRecord support.