gotime-cassandra_object 2.3.3 → 2.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,2 @@
1
+ == Cassandra Object
2
+
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'gotime-cassandra_object'
5
- s.version = '2.3.3'
5
+ s.version = '2.3.4'
6
6
  s.description = 'Cassandra ActiveModel'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
 
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.email = 'gems@gotime.com'
14
14
  s.homepage = 'http://github.com/gotime/cassandra_object'
15
15
 
16
- s.extra_rdoc_files = ["README.markdown"]
16
+ s.extra_rdoc_files = ["README.rdoc"]
17
17
  s.files = `git ls-files`.split("\n")
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.require_paths = ['lib']
@@ -3,7 +3,9 @@ module CassandraObject
3
3
  extend ActiveSupport::Concern
4
4
  module ClassMethods
5
5
  def find(key)
6
- if parse_key(key) && attributes = connection.get(column_family, key)
6
+ if !parse_key(key)
7
+ raise CassandraObject::RecordNotFound, "Couldn't find #{self.name} with key #{key.inspect}"
8
+ elsif attributes = connection.get(column_family, key)
7
9
  instantiate(key, attributes)
8
10
  else
9
11
  raise CassandraObject::RecordNotFound
@@ -28,20 +30,14 @@ module CassandraObject
28
30
  end
29
31
 
30
32
  def first(options = {})
31
- all(options.merge(:limit => 1)).first
33
+ all(options.merge(limit: 1)).first
32
34
  end
33
35
 
34
36
  def find_with_ids(*ids)
35
- expects_array = ids.first.kind_of?(Array)
36
- return ids.first if expects_array && ids.first.empty?
37
+ ids = ids.flatten
38
+ return ids if ids.empty?
37
39
 
38
- ids = ids.dup
39
- ids.flatten!
40
- ids.compact!
41
- ids.collect!(&:to_s)
42
- ids.uniq!
43
-
44
- #raise RecordNotFound, "Couldn't find #{record_klass.name} without an ID" if ids.empty?
40
+ ids = ids.compact.map(&:to_s).uniq
45
41
 
46
42
  results = multi_get(ids).values.compact
47
43
 
@@ -24,7 +24,7 @@ module CassandraObject
24
24
 
25
25
  # Parse should create a new key object from the 'to_param' format
26
26
  def parse(string)
27
- UUID.new(string)
27
+ UUID.new(string) if string
28
28
  rescue
29
29
  nil
30
30
  end
@@ -6,6 +6,13 @@ class CassandraObject::FinderMethodsTest < CassandraObject::TestCase
6
6
  assert_equal issue, Issue.find(issue.id)
7
7
  end
8
8
 
9
+ begin
10
+ Issue.find(nil)
11
+ assert false
12
+ rescue => e
13
+ assert_equal "Couldn't find Issue with key nil", e.message
14
+ end
15
+
9
16
  assert_raise CassandraObject::RecordNotFound do
10
17
  Issue.find('what')
11
18
  end
@@ -39,16 +46,7 @@ class CassandraObject::FinderMethodsTest < CassandraObject::TestCase
39
46
  third_issue = Issue.create
40
47
 
41
48
  assert_equal [], Issue.find_with_ids([])
42
- assert_equal first_issue, Issue.find_with_ids(first_issue.key)
43
49
  assert_equal [first_issue, second_issue].to_set, Issue.find_with_ids(first_issue.key, second_issue.key).to_set
44
50
  assert_equal [first_issue, second_issue].to_set, Issue.find_with_ids([first_issue.key, second_issue.key]).to_set
45
51
  end
46
-
47
- # test 'find single id' do
48
- # created_issue = Issue.create
49
- #
50
- # found_issue = Issue.find(created_issue.id)
51
- #
52
- # assert_equal created_issue, found_issue
53
- # end
54
52
  end
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class CassandraObject::Identity::UuidKeyFactoryTest < CassandraObject::TestCase
4
+ test 'parse' do
5
+ assert_not_nil key_factory.parse('95b2cf70-c318-11e0-962b-0800200c9a66')
6
+ assert_nil key_factory.parse('xyz')
7
+ assert_nil key_factory.parse(nil)
8
+ end
9
+
10
+ private
11
+ def key_factory
12
+ @key_factory ||= CassandraObject::Identity::UUIDKeyFactory.new
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gotime-cassandra_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.3
4
+ version: 2.3.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2011-08-10 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &2152892860 !ruby/object:Gem::Requirement
17
+ requirement: &2165457380 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '3.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2152892860
25
+ version_requirements: *2165457380
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: cassandra
28
- requirement: &2152892280 !ruby/object:Gem::Requirement
28
+ requirement: &2165456920 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.11.3
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2152892280
36
+ version_requirements: *2165456920
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bundler
39
- requirement: &2152891440 !ruby/object:Gem::Requirement
39
+ requirement: &2165456060 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,20 +44,20 @@ dependencies:
44
44
  version: 1.0.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2152891440
47
+ version_requirements: *2165456060
48
48
  description: Cassandra ActiveModel
49
49
  email: gems@gotime.com
50
50
  executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files:
53
- - README.markdown
53
+ - README.rdoc
54
54
  files:
55
55
  - .gitignore
56
56
  - CHANGELOG
57
57
  - Gemfile
58
58
  - LICENSE
59
59
  - MIT-LICENSE
60
- - README.markdown
60
+ - README.rdoc
61
61
  - Rakefile
62
62
  - gotime-cassandra_object.gemspec
63
63
  - lib/cassandra_object.rb
@@ -120,6 +120,7 @@ files:
120
120
  - test/connection_test.rb
121
121
  - test/consistency_test.rb
122
122
  - test/finder_methods_test.rb
123
+ - test/identity/uuid_key_factory_test.rb
123
124
  - test/identity_test.rb
124
125
  - test/persistence_test.rb
125
126
  - test/test_helper.rb
@@ -167,6 +168,7 @@ test_files:
167
168
  - test/connection_test.rb
168
169
  - test/consistency_test.rb
169
170
  - test/finder_methods_test.rb
171
+ - test/identity/uuid_key_factory_test.rb
170
172
  - test/identity_test.rb
171
173
  - test/persistence_test.rb
172
174
  - test/test_helper.rb
data/README.markdown DELETED
@@ -1,12 +0,0 @@
1
- # Cassandra Object
2
-
3
- Cassandra Object provides a API for working with [Cassandra](http://incubator.apache.org/cassandra/) in Rails projects.
4
-
5
- Installation:
6
-
7
- gem 'gotime-cassandra_object', require: 'cassandra_object'
8
-
9
- Example:
10
-
11
- class Customer < CassandraObject::Base
12
- end