riak-shim 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ vendor/bundle
data/Guardfile ADDED
@@ -0,0 +1,7 @@
1
+ guard 'rspec', :version => 2, :cli => "--color --format nested" do
2
+ watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
3
+ watch(%r{^spec/support/*}) { 'spec' }
4
+ watch(%r{^lib/(.+)\.rb$}) { 'spec' }
5
+ watch('spec/spec_helper.rb') { "spec" }
6
+ end
7
+
data/README.md CHANGED
@@ -40,6 +40,10 @@ In any class you wish to persist:
40
40
  # Return hashified version of your class
41
41
  end
42
42
 
43
+ def self.from_hash(key)
44
+ # Return a fresh instance of your class populated by the hash provided
45
+ end
46
+
43
47
  def fields_to_index
44
48
  # Return an Array of hash keys you would like placed into a secondary index.
45
49
  # Return an empty Array if you don't know what this means. :)
@@ -65,4 +69,7 @@ Return value is an Array of instances of your class matching the query.
65
69
 
66
70
  ## TODOS
67
71
 
68
- - Implement a #for_key lookup method.
72
+ - #from_hash does not work as advertised
73
+ - Implement a #for_key lookup method
74
+ - Examples directory
75
+ - Revisit tests
@@ -6,7 +6,7 @@ module Riak
6
6
  attr_accessor :key
7
7
 
8
8
  def key
9
- @key ||= gen_key
9
+ @key ||= self.class.gen_key
10
10
  end
11
11
 
12
12
  def bucket
@@ -50,10 +50,18 @@ module Riak
50
50
  end
51
51
 
52
52
  def bucket_name
53
- myclass = self.to_s.underscore
53
+ myclass = de_cammel(self.to_s)
54
54
  "#{store.bucket_prefix}#{myclass}"
55
55
  end
56
56
 
57
+ def de_cammel(classname)
58
+ classname.gsub(/::/, '__').
59
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
60
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
61
+ tr("-", "_").
62
+ downcase
63
+ end
64
+
57
65
  def bucket
58
66
  return store.bucket(bucket_name)
59
67
  end
@@ -1,5 +1,5 @@
1
1
  module Riak
2
2
  module Shim
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
data/riak-shim.gemspec CHANGED
@@ -20,4 +20,6 @@ Gem::Specification.new do |gem|
20
20
 
21
21
  gem.add_development_dependency "rake"
22
22
  gem.add_development_dependency "rspec"
23
+ gem.add_development_dependency "guard"
24
+ gem.add_development_dependency "guard-rspec"
23
25
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riak-shim
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Brodhead & Shai Rosenfeld
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-11 00:00:00 Z
18
+ date: 2012-07-12 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: riak-client
@@ -73,6 +73,34 @@ dependencies:
73
73
  version: "0"
74
74
  type: :development
75
75
  version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: guard
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ type: :development
89
+ version_requirements: *id005
90
+ - !ruby/object:Gem::Dependency
91
+ name: guard-rspec
92
+ prerelease: false
93
+ requirement: &id006 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ type: :development
103
+ version_requirements: *id006
76
104
  description: Riak shim for bucket names and config.
77
105
  email:
78
106
  - mkb@engineyard.com
@@ -85,11 +113,11 @@ extra_rdoc_files: []
85
113
  files:
86
114
  - .gitignore
87
115
  - Gemfile
116
+ - Guardfile
88
117
  - LICENSE
89
118
  - README.md
90
119
  - Rakefile
91
120
  - lib/riak-shim.rb
92
- - lib/riak-shim/core_ext.rb
93
121
  - lib/riak-shim/persistable.rb
94
122
  - lib/riak-shim/store.rb
95
123
  - lib/riak-shim/version.rb
@@ -1,12 +0,0 @@
1
- ## taken from active support, but don't want all the baggage...
2
- ## converts camel case to all lower case name delimited by underscores
3
- ## for bucket name prettyness
4
- class String
5
- def underscore
6
- self.gsub(/::/, '/').
7
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
8
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
9
- tr("-", "_").
10
- downcase
11
- end
12
- end