keytar 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,13 +2,15 @@ Keytar
2
2
  ======
3
3
 
4
4
  **1.** A keyboard that is designed to be played standing up, like a guitar.
5
- **2.** A crazy simple, flexible ruby library for generating NOSQL keys. Use it with redis, memcache, cassandra, or any other key-value store.
5
+ **2.** A crazy simple, flexible ruby library for generating NOSQL keys. Use it with redis, memcache, mongo, or any other key-value store.
6
6
 
7
7
  It Builds Keys
8
8
  --------
9
- keytar auto-magically generates keys using method names ending in `*_key` or simply `key`
10
-
11
- User.key #=> "user"
9
+ class User
10
+ include Keytar
11
+ define_keys :friends, :last_web_access_cache, :favorite_spots, :sweet
12
+ end
13
+
12
14
  User.friends_key #=> "user:friends"
13
15
 
14
16
  u = User.new
@@ -40,7 +42,7 @@ then run
40
42
 
41
43
  bundle install
42
44
 
43
- drop `include Keytar` in any __Ruby__ model you want and you're good to go
45
+ drop `include Keytar` in any model you want and you're good to go
44
46
 
45
47
 
46
48
  It's that simple
@@ -52,13 +54,13 @@ Keys should be pre-defined and configured by calling **define\_keys**:
52
54
  class User
53
55
  include Keytar
54
56
  define_keys :friend_ids, :email_subscriptions, :news_feed, :delimiter => "|", :version => "v2"
55
- define_keys :favorite_spots, :delimiter => "/", :version => 3, :key_prefix => "lol"
56
57
  end
57
58
 
58
59
  User.respond_to? :friend_ids_key #=> true
59
60
  User.friend_ids_key #=> "user|friend_ids|v2"
60
61
 
61
- Where the first argument is the key (or keys) to be defined, and the second argument is a hash of configurations.
62
+
63
+ Where the first argument is the key (or keys) to be defined, and the second argument is a hash of configuration options.
62
64
 
63
65
 
64
66
  Global options can also be configured per class by passing in a hash to **key_config**:
@@ -88,7 +90,7 @@ Here is a run down of what each does
88
90
 
89
91
  **unique** sets the unique value of the instance that is used to build the key
90
92
 
91
- By default all instance keys have an identifying unique element included in the key, specifying `key_unique` allows you to change the field that is used to specify a unique key. (defaults to database backed id, but will not use id if object.id == object.object_id)
93
+ By default all instance keys have an identifying unique element included in the key, specifying `key_unique` allows you to change the field that is used to specify a unique key. (defaults to database backed id, Object#id)
92
94
 
93
95
  User.create(:username => "Schneems", :id => 9)
94
96
  User.find(9).favorite_spots_key #=> "users:favorite_spots:9"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.4.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{keytar}
8
- s.version = "1.3.1"
8
+ s.version = "1.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Schneems"]
12
- s.date = %q{2011-07-13}
12
+ s.date = %q{2011-07-27}
13
13
  s.description = %q{
14
14
  Keytar is a Ruby on Rails wrapper for KeyBuilder.
15
15
  Use KeyBuilder to automatically generate keys based on class name instead of cluttering model
@@ -12,13 +12,6 @@ module KeyBuilder
12
12
  # setup method missing on class
13
13
  klass.class_eval do
14
14
  extend KeyBuilder::Ext
15
- def self.method_missing(method_name, *args, &blk)
16
- if method_name.to_s =~ /.*key$/
17
- self.build_key(:base => self.to_s.downcase, :name => method_name, :args => args)
18
- else
19
- super
20
- end
21
- end
22
15
  end
23
16
  end
24
17
 
@@ -130,14 +123,4 @@ module KeyBuilder
130
123
  options[:unique] = unique unless unique == object_id
131
124
  self.class.build_key(options)
132
125
  end
133
-
134
-
135
-
136
- def method_missing(method_name, *args, &blk)
137
- if method_name.to_s =~ /.*key$/
138
- build_key(:name => method_name, :args => args)
139
- else
140
- super
141
- end
142
- end
143
126
  end
@@ -17,19 +17,19 @@ end
17
17
 
18
18
  class Foo
19
19
  include Keytar
20
+ define_key :awesome
20
21
  end
21
22
 
22
23
  class Bar < ActiveRecord::Base
23
24
  include Keytar
25
+ define_key :awesome
24
26
  end
25
27
 
26
28
  class BarNonActiveRecord
27
-
28
29
  end
29
30
 
30
31
 
31
32
  class BarBaz < ActiveRecord::Base
32
-
33
33
  end
34
34
 
35
35
  describe Keytar do
@@ -63,10 +63,6 @@ describe Keytar do
63
63
  end
64
64
 
65
65
  describe 'class methods' do
66
- it 'should respond to "key" method by returning downcase of class name' do
67
- Foo.key.should == "foo"
68
- end
69
-
70
66
  it 'should respond to "awesome_key" method by returning :class, :delimiter, :name' do
71
67
  Foo.awesome_key.should == "foo:awesome"
72
68
  end
@@ -89,10 +85,6 @@ describe Keytar do
89
85
  @foo = Foo.new
90
86
  end
91
87
 
92
- it 'should respond to "key" method by returning pluralized downcase of class name' do
93
- @foo.key.should == "foos"
94
- end
95
-
96
88
  it 'should respond to "awesome_key" method by returning :class, :delimiter, :name' do
97
89
  @foo.awesome_key.should == "foos:awesome"
98
90
  end
@@ -179,7 +171,7 @@ describe Keytar do
179
171
  Foo.key_unique key_unique
180
172
  Foo.key_unique.should == key_unique
181
173
  foo = Foo.new
182
- foo.awesome_key.should == "foos:awesome:#{foo.timeish}"
174
+ foo.awesome_key.should include(foo.timeish)
183
175
  end
184
176
 
185
177
  # todo move tests and assertsions to seperate describe and it blocks
@@ -237,6 +229,7 @@ describe Keytar do
237
229
  it 'includes keybuilder when it is included' do
238
230
  BarNonActiveRecord.class_eval do
239
231
  include Keytar
232
+ define_key :awesome
240
233
  end
241
234
  describe BarNonActiveRecord.ancestors do
242
235
  it {should include( KeyBuilder)}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keytar
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 3
9
- - 1
10
- version: 1.3.1
8
+ - 4
9
+ - 0
10
+ version: 1.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Schneems
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-13 00:00:00 -05:00
18
+ date: 2011-07-27 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency