orm_adapter-cequel 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +84 -0
- data/LICENSE.txt +22 -0
- data/README.md +23 -0
- data/Rakefile +68 -0
- data/lib/cequel/record/orm_adapter.rb +155 -0
- data/lib/orm_adapter-cequel/version.rb +3 -0
- data/lib/orm_adapter-cequel.rb +1 -0
- data/spec/examples/orm_adapter_spec.rb +145 -0
- data/spec/examples/spec_helper.rb +25 -0
- data/spec/models/blog.rb +8 -0
- data/spec/models/post.rb +8 -0
- metadata +173 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a0715546dcf2c15587035b28d0ef9503c9b37701
|
4
|
+
data.tar.gz: 06a2ec17fba0eafac9ceb751da34b350afd5bdf3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aa6af41e99ba6ef4ac3b7e7b9deb14340d404b275fcf045556a42a80e4e06b1bf039bc8cbfacc3b75033437b1b7b2b87db82d74c2ef35154347a7d6f03eb8eb4
|
7
|
+
data.tar.gz: 2404ea503cfa0a3a4ed7d5a6e6789ab561dc63189a92b91a774374bf88e07eaf82b45a57c3fb2e69093b58e89540721adc97b18c4382e2d28e2ee327357aaaf8
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
orm_adapter-cequel (1.0.0)
|
5
|
+
cequel (~> 1.0)
|
6
|
+
orm_adapter (~> 0.5)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (4.0.2)
|
12
|
+
activesupport (= 4.0.2)
|
13
|
+
builder (~> 3.1.0)
|
14
|
+
activesupport (4.0.2)
|
15
|
+
i18n (~> 0.6, >= 0.6.4)
|
16
|
+
minitest (~> 4.2)
|
17
|
+
multi_json (~> 1.3)
|
18
|
+
thread_safe (~> 0.1)
|
19
|
+
tzinfo (~> 0.3.37)
|
20
|
+
ast (1.1.0)
|
21
|
+
atomic (1.1.14)
|
22
|
+
builder (3.1.4)
|
23
|
+
cassandra-cql (1.2.2)
|
24
|
+
simple_uuid (>= 0.2.0)
|
25
|
+
thrift_client (>= 0.7.1, < 0.9)
|
26
|
+
cequel (1.0.0)
|
27
|
+
activemodel
|
28
|
+
activesupport (>= 3.1)
|
29
|
+
cassandra-cql (~> 1.2)
|
30
|
+
connection_pool (~> 1.1)
|
31
|
+
i18n
|
32
|
+
coderay (1.1.0)
|
33
|
+
connection_pool (1.2.0)
|
34
|
+
diff-lcs (1.2.5)
|
35
|
+
i18n (0.6.9)
|
36
|
+
json (1.8.1)
|
37
|
+
method_source (0.8.2)
|
38
|
+
minitest (4.7.5)
|
39
|
+
multi_json (1.8.4)
|
40
|
+
orm_adapter (0.5.0)
|
41
|
+
parser (2.1.4)
|
42
|
+
ast (~> 1.1)
|
43
|
+
slop (~> 3.4, >= 3.4.5)
|
44
|
+
powerpack (0.0.9)
|
45
|
+
pry (0.9.12.6)
|
46
|
+
coderay (~> 1.0)
|
47
|
+
method_source (~> 0.8)
|
48
|
+
slop (~> 3.4)
|
49
|
+
rainbow (2.0.0)
|
50
|
+
rake (10.1.1)
|
51
|
+
rspec (2.14.1)
|
52
|
+
rspec-core (~> 2.14.0)
|
53
|
+
rspec-expectations (~> 2.14.0)
|
54
|
+
rspec-mocks (~> 2.14.0)
|
55
|
+
rspec-core (2.14.7)
|
56
|
+
rspec-expectations (2.14.5)
|
57
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
58
|
+
rspec-mocks (2.14.5)
|
59
|
+
rubocop (0.18.0)
|
60
|
+
json (>= 1.7.7, < 2)
|
61
|
+
parser (~> 2.1.3)
|
62
|
+
powerpack (~> 0.0.6)
|
63
|
+
rainbow (>= 1.99.1, < 3.0)
|
64
|
+
simple_uuid (0.4.0)
|
65
|
+
slop (3.4.7)
|
66
|
+
thread_safe (0.1.3)
|
67
|
+
atomic
|
68
|
+
thrift (0.8.0)
|
69
|
+
thrift_client (0.8.4)
|
70
|
+
thrift (~> 0.8.0)
|
71
|
+
tzinfo (0.3.38)
|
72
|
+
yard (0.8.7.3)
|
73
|
+
|
74
|
+
PLATFORMS
|
75
|
+
ruby
|
76
|
+
|
77
|
+
DEPENDENCIES
|
78
|
+
bundler (~> 1.3)
|
79
|
+
orm_adapter-cequel!
|
80
|
+
pry
|
81
|
+
rake
|
82
|
+
rspec
|
83
|
+
rubocop
|
84
|
+
yard
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Mat Brown
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# OrmAdapter::Cequel
|
2
|
+
|
3
|
+
A plugin for [OrmAdapter](https://github.com/ianwhite/orm_adapter) adding
|
4
|
+
support for the [Cequel](https://github.com/cequel/cequel) Cassandra ORM.
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
The primary audience of this library is library developers who want a
|
9
|
+
consistent interface to various ORMs. You probably don't need to add this to
|
10
|
+
your application directly.
|
11
|
+
|
12
|
+
## Supported features
|
13
|
+
|
14
|
+
This adapter supports all OrmAdapter features except for the `:order` and
|
15
|
+
`:offset` options for the `#find_first` and `#find_every` methods.
|
16
|
+
|
17
|
+
## Contributing
|
18
|
+
|
19
|
+
1. Fork it
|
20
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
21
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
22
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
23
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
require File.expand_path('../lib/orm_adapter-cequel/version', __FILE__)
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
task :default => :release
|
9
|
+
task :release => [
|
10
|
+
:rubocop,
|
11
|
+
:"test:concise",
|
12
|
+
:build,
|
13
|
+
:tag,
|
14
|
+
:update_stable,
|
15
|
+
:push,
|
16
|
+
:cleanup
|
17
|
+
]
|
18
|
+
|
19
|
+
desc 'Build gem'
|
20
|
+
task :build do
|
21
|
+
system 'gem build orm_adapter-cequel.gemspec'
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Create git release tag'
|
25
|
+
task :tag do
|
26
|
+
system "git tag -a -m 'Version #{OrmAdapterCequel::VERSION}' #{OrmAdapterCequel::VERSION}"
|
27
|
+
system "git push origin #{OrmAdapterCequel::VERSION}:#{OrmAdapterCequel::VERSION}"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Update stable branch on GitHub'
|
31
|
+
task :update_stable do
|
32
|
+
if OrmAdapterCequel::VERSION =~ /^(\d+\.)+\d+$/ # Don't push for prerelease
|
33
|
+
system "git push -f origin HEAD:stable"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'Push gem to repository'
|
38
|
+
task :push do
|
39
|
+
system "gem push orm_adapter-cequel-#{OrmAdapterCequel::VERSION}.gem"
|
40
|
+
end
|
41
|
+
|
42
|
+
task 'Remove packaged gems'
|
43
|
+
task :cleanup do
|
44
|
+
system "rm -v *.gem"
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'Check style with Rubocop'
|
48
|
+
Rubocop::RakeTask.new(:rubocop) do |task|
|
49
|
+
task.patterns = ['lib']
|
50
|
+
task.formatters = ['files']
|
51
|
+
task.fail_on_error = true
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'Run the specs'
|
55
|
+
RSpec::Core::RakeTask.new(:test) do |t|
|
56
|
+
t.pattern = './spec/examples/**/*_spec.rb'
|
57
|
+
t.rspec_opts = '--fail-fast'
|
58
|
+
t.fail_on_error = true
|
59
|
+
end
|
60
|
+
|
61
|
+
namespace :test do
|
62
|
+
desc 'Run the specs with progress formatter'
|
63
|
+
RSpec::Core::RakeTask.new(:concise) do |t|
|
64
|
+
t.pattern = './spec/examples/**/*_spec.rb'
|
65
|
+
t.rspec_opts = '--fail-fast --format=progress'
|
66
|
+
t.fail_on_error = true
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'cequel/record'
|
2
|
+
require 'orm_adapter'
|
3
|
+
|
4
|
+
module Cequel
|
5
|
+
module Record
|
6
|
+
module ClassMethods # rubocop:disable Documentation
|
7
|
+
include ::OrmAdapter::ToAdapter
|
8
|
+
end
|
9
|
+
|
10
|
+
#
|
11
|
+
# ORM adapter for Cequel, the Ruby ORM for Cassandra
|
12
|
+
#
|
13
|
+
class OrmAdapter < ::OrmAdapter::Base
|
14
|
+
extend Forwardable
|
15
|
+
|
16
|
+
#
|
17
|
+
# @return [Array<Symbol>] names of columns on this model
|
18
|
+
#
|
19
|
+
def column_names
|
20
|
+
klass.columns.map { |column| column.name }
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# @param key_values [Array] values for each primary key column on this
|
25
|
+
# record
|
26
|
+
# @return [Cequel::Record] a record instance corresponding to this
|
27
|
+
# primary key
|
28
|
+
# @raise [Cequel::Record::RecordNotFound] if the key is not present
|
29
|
+
#
|
30
|
+
# @see #get
|
31
|
+
#
|
32
|
+
def get!(key_values)
|
33
|
+
klass.find(*key_values)
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# @param key_values [Array] values for each primary key column on this
|
38
|
+
# record
|
39
|
+
# @return [Cequel::Record] a record instance corresponding to this
|
40
|
+
# primary key or nil if not present
|
41
|
+
#
|
42
|
+
# @see #get
|
43
|
+
#
|
44
|
+
def get(key_values)
|
45
|
+
get!(key_values)
|
46
|
+
rescue Cequel::Record::RecordNotFound
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# Find the first record instance with the given conditions
|
52
|
+
#
|
53
|
+
# @param options [Options] options for query
|
54
|
+
# @option options [Hash] :conditions map of column names to column
|
55
|
+
# values. This can either be a one-element hash specifying a secondary
|
56
|
+
# index lookup, or a mapping of primary key columns to values.
|
57
|
+
# @return [Cequel::Record] the first record matching the query, or nil if
|
58
|
+
# none present
|
59
|
+
#
|
60
|
+
def find_first(options = {})
|
61
|
+
construct_scope(options).first
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# Find all records with the given conditions and limit
|
66
|
+
#
|
67
|
+
# @param options [Options] options for query
|
68
|
+
# @option options [Hash] :conditions map of column names to column
|
69
|
+
# values. This can either be a one-element hash specifying a secondary
|
70
|
+
# index lookup, or a mapping of primary key columns to values.
|
71
|
+
# @option options [Integer] :limit maximum number of rows to return
|
72
|
+
# @return [Array<Cequel::Record>] all records matching the conditions
|
73
|
+
#
|
74
|
+
def find_all(options = {})
|
75
|
+
construct_scope(options).to_a
|
76
|
+
end
|
77
|
+
|
78
|
+
#
|
79
|
+
# @!method create!(attributes = {})
|
80
|
+
# Create a new instance of the record class and save it to the database
|
81
|
+
#
|
82
|
+
# @param attributes [Hash] map of column names to values
|
83
|
+
# @return [Cequel::Record] the newly created
|
84
|
+
# @raise [Cequel::Record::RecordInvalid] if the record fails
|
85
|
+
# validations
|
86
|
+
#
|
87
|
+
def_delegator :klass, :create!
|
88
|
+
|
89
|
+
#
|
90
|
+
# Destroy the given record
|
91
|
+
#
|
92
|
+
# @param record [Cequel::Record] the record to destroy
|
93
|
+
# @return [void]
|
94
|
+
#
|
95
|
+
def destroy(record)
|
96
|
+
record.destroy
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def construct_scope(options)
|
102
|
+
conditions, _, limit, _ =
|
103
|
+
extract_conditions!(options.deep_symbolize_keys)
|
104
|
+
scope = klass.all
|
105
|
+
scope = apply_secondary_index_scope(scope, conditions) ||
|
106
|
+
apply_primary_key_scope(scope, conditions)
|
107
|
+
scope = scope.limit(limit) if limit
|
108
|
+
scope
|
109
|
+
end
|
110
|
+
|
111
|
+
def extract_conditions!(options)
|
112
|
+
super.tap do |_, order, _, offset|
|
113
|
+
if order.present?
|
114
|
+
fail ArgumentError,
|
115
|
+
"Cassandra does not support ordering of results by " \
|
116
|
+
"arbitrary columns"
|
117
|
+
end
|
118
|
+
if offset.present?
|
119
|
+
fail ArgumentError, 'Cassandra does not support row offsets'
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def apply_primary_key_scope(scope, conditions)
|
125
|
+
conditions = conditions.dup
|
126
|
+
conditions.assert_valid_keys(*klass.key_column_names)
|
127
|
+
|
128
|
+
klass.key_column_names.each do |column_name|
|
129
|
+
column_value = conditions.delete(column_name)
|
130
|
+
break unless column_value
|
131
|
+
scope = scope[column_value]
|
132
|
+
end
|
133
|
+
|
134
|
+
assert_conditions_empty!(conditions)
|
135
|
+
|
136
|
+
scope
|
137
|
+
end
|
138
|
+
|
139
|
+
def apply_secondary_index_scope(scope, conditions)
|
140
|
+
return unless conditions.one?
|
141
|
+
condition_column = klass.reflect_on_column(conditions.keys.first)
|
142
|
+
if condition_column.data_column? && condition_column.indexed?
|
143
|
+
scope.where(*conditions.first)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def assert_conditions_empty!(conditions)
|
148
|
+
unless conditions.empty?
|
149
|
+
fail ArgumentError,
|
150
|
+
"Invalid columns for conditions: #{conditions.keys.join(', ')}"
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cequel/record/orm_adapter'
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require_relative './spec_helper'
|
2
|
+
|
3
|
+
describe Cequel::Record::OrmAdapter do
|
4
|
+
let!(:blog) { Blog.create!(subdomain: 'cassandra', name: 'Cassandra') }
|
5
|
+
let!(:posts) do
|
6
|
+
5.times.map do |i|
|
7
|
+
Post.create!(blog: blog, title: "Cequel #{i}")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
let(:post) { posts.first }
|
11
|
+
let(:blog_adapter) { Blog.to_adapter }
|
12
|
+
let(:post_adapter) { Post.to_adapter }
|
13
|
+
subject { post_adapter }
|
14
|
+
|
15
|
+
its(:column_names) { should == [:blog_subdomain, :id, :title, :author_id] }
|
16
|
+
|
17
|
+
describe '#get!' do
|
18
|
+
it 'should get a simple primary key' do
|
19
|
+
blog_adapter.get!([blog.subdomain]).should == blog
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should get a simple primary key not specified as an array' do
|
23
|
+
blog_adapter.get!(blog.subdomain).should == blog
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should get a compound primary key' do
|
27
|
+
post_adapter.get!(post.key_values).should == post
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should raise an error if key not found' do
|
31
|
+
expect { blog_adapter.get!(['foo']) }.to raise_error
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#get' do
|
36
|
+
it 'should get a simple primary key' do
|
37
|
+
blog_adapter.get([blog.subdomain]).should == blog
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should return nil if key not found' do
|
41
|
+
blog_adapter.get(['foo']).should be_nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#find_first' do
|
46
|
+
let!(:other_post) do
|
47
|
+
Post.create!(blog_subdomain: 'postgres', title: 'Sequel', author_id: 1)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should find first with no conditions' do
|
51
|
+
post_adapter.find_first.should == post
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should find first with conditions' do
|
55
|
+
post_adapter.find_first(conditions: {blog_subdomain: 'postgres'})
|
56
|
+
.should == other_post
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should find first with secondary index condition' do
|
60
|
+
post_adapter.find_first(conditions: {author_id: 1})
|
61
|
+
.should == other_post
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should accept bare conditions' do
|
65
|
+
post_adapter.find_first(blog_subdomain: 'postgres')
|
66
|
+
.should == other_post
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should raise an error if key prefix missing' do
|
70
|
+
expect { post_adapter.find_first(id: post.id) }
|
71
|
+
.to raise_error(ArgumentError)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should raise an error if order passed' do
|
75
|
+
expect { post_adapter.find_first(
|
76
|
+
conditions: {blog_subdomain: 'postgres'}, order: [:title, :asc])}
|
77
|
+
.to raise_error(ArgumentError)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#find_all' do
|
82
|
+
let!(:other_posts) do
|
83
|
+
5.times.map do |i|
|
84
|
+
Post.create!(blog_subdomain: 'postgres', title: "Sequel #{i}",
|
85
|
+
author_id: 1)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should find all with no conditions' do
|
90
|
+
post_adapter.find_all.should =~ posts + other_posts
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should find all with conditions' do
|
94
|
+
post_adapter.find_all(conditions: {blog_subdomain: 'postgres'})
|
95
|
+
.should == other_posts
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should find all with bare conditions' do
|
99
|
+
post_adapter.find_all(blog_subdomain: 'postgres')
|
100
|
+
.should == other_posts
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should find first with secondary index condition' do
|
104
|
+
post_adapter.find_all(author_id: 1)
|
105
|
+
.should == other_posts
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should find all with limit' do
|
109
|
+
post_adapter.find_all(blog_subdomain: 'postgres', limit: 2)
|
110
|
+
.should == other_posts.first(2)
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should raise an error if key prefix missing' do
|
114
|
+
expect { post_adapter.find_all(id: post.id) }
|
115
|
+
.to raise_error(ArgumentError)
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should raise an error if order passed' do
|
119
|
+
expect { post_adapter.find_all(
|
120
|
+
conditions: {blog_subdomain: 'postgres'}, order: [:title, :asc]) }
|
121
|
+
.to raise_error(ArgumentError)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should raise an error if offset passed' do
|
125
|
+
expect { post_adapter.find_all(
|
126
|
+
conditions: {blog_subdomain: 'postgres'}, offset: 2) }
|
127
|
+
.to raise_error(ArgumentError)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe '#create!' do
|
132
|
+
it 'should create instance' do
|
133
|
+
post = post_adapter.create!(blog: blog, title: 'New Post')
|
134
|
+
Post.find(*post.to_key).title.should == 'New Post'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe '#destroy' do
|
139
|
+
it 'should destroy instance' do
|
140
|
+
post_adapter.destroy(post)
|
141
|
+
expect { Post.find(*post.to_key) }
|
142
|
+
.to raise_error(Cequel::Record::RecordNotFound)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.require(:default, :development)
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.before :all do
|
6
|
+
Cequel::Record.establish_connection(keyspace: 'orm_helper_cequel')
|
7
|
+
Cequel::Record.connection.schema.create!
|
8
|
+
Cequel::Record.connection.logger = Logger.new(STDOUT) if ENV['LOG_QUERIES']
|
9
|
+
|
10
|
+
Dir.glob(File.expand_path('../../models/**/*.rb', __FILE__)).each do |model|
|
11
|
+
require model
|
12
|
+
File.basename(model, '.rb').classify.constantize.synchronize_schema
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
config.after :each do
|
17
|
+
Dir.glob(File.expand_path('../../models/**/*.rb', __FILE__)).each do |model|
|
18
|
+
File.basename(model, '.rb').classify.constantize.destroy_all
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
config.after :all do
|
23
|
+
Cequel::Record.connection.schema.drop!
|
24
|
+
end
|
25
|
+
end
|
data/spec/models/blog.rb
ADDED
data/spec/models/post.rb
ADDED
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: orm_adapter-cequel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mat Brown
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: orm_adapter
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: cequel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: yard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: ORM adapter for Cequel, the CQL3 ORM for Ruby
|
126
|
+
email:
|
127
|
+
- mat.a.brown@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- lib/cequel/record/orm_adapter.rb
|
133
|
+
- lib/orm_adapter-cequel/version.rb
|
134
|
+
- lib/orm_adapter-cequel.rb
|
135
|
+
- Gemfile
|
136
|
+
- Gemfile.lock
|
137
|
+
- LICENSE.txt
|
138
|
+
- Rakefile
|
139
|
+
- README.md
|
140
|
+
- spec/examples/orm_adapter_spec.rb
|
141
|
+
- spec/examples/spec_helper.rb
|
142
|
+
- spec/models/blog.rb
|
143
|
+
- spec/models/post.rb
|
144
|
+
homepage: https://github.com/cequel/orm_adapter-cequel
|
145
|
+
licenses:
|
146
|
+
- MIT
|
147
|
+
metadata: {}
|
148
|
+
post_install_message:
|
149
|
+
rdoc_options: []
|
150
|
+
require_paths:
|
151
|
+
- lib
|
152
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
requirements: []
|
163
|
+
rubyforge_project:
|
164
|
+
rubygems_version: 2.1.11
|
165
|
+
signing_key:
|
166
|
+
specification_version: 4
|
167
|
+
summary: ORM adapter for Cequel
|
168
|
+
test_files:
|
169
|
+
- spec/examples/orm_adapter_spec.rb
|
170
|
+
- spec/examples/spec_helper.rb
|
171
|
+
- spec/models/blog.rb
|
172
|
+
- spec/models/post.rb
|
173
|
+
has_rdoc:
|