virsandra 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/LICENSE.txt +22 -0
  2. data/README.md +93 -0
  3. data/Rakefile +18 -0
  4. data/lib/virsandra.rb +89 -0
  5. data/lib/virsandra/configuration.rb +61 -0
  6. data/lib/virsandra/connection.rb +39 -0
  7. data/lib/virsandra/cql_value.rb +38 -0
  8. data/lib/virsandra/errors.rb +3 -0
  9. data/lib/virsandra/model.rb +86 -0
  10. data/lib/virsandra/model_query.rb +52 -0
  11. data/lib/virsandra/queries/add_query.rb +25 -0
  12. data/lib/virsandra/queries/alter_query.rb +34 -0
  13. data/lib/virsandra/queries/delete_query.rb +25 -0
  14. data/lib/virsandra/queries/insert_query.rb +34 -0
  15. data/lib/virsandra/queries/limit_query.rb +17 -0
  16. data/lib/virsandra/queries/order_query.rb +36 -0
  17. data/lib/virsandra/queries/select_query.rb +72 -0
  18. data/lib/virsandra/queries/table_query.rb +13 -0
  19. data/lib/virsandra/queries/values_query.rb +41 -0
  20. data/lib/virsandra/queries/where_query.rb +69 -0
  21. data/lib/virsandra/query.rb +87 -0
  22. data/lib/virsandra/version.rb +3 -0
  23. data/spec/feature_helper.rb +62 -0
  24. data/spec/integration/virsandra_spec.rb +13 -0
  25. data/spec/lib/virsandra/configuration_spec.rb +66 -0
  26. data/spec/lib/virsandra/connection_spec.rb +47 -0
  27. data/spec/lib/virsandra/cql_value_spec.rb +25 -0
  28. data/spec/lib/virsandra/model_query_spec.rb +58 -0
  29. data/spec/lib/virsandra/model_spec.rb +173 -0
  30. data/spec/lib/virsandra/queries/add_query_spec.rb +26 -0
  31. data/spec/lib/virsandra/queries/alter_query_spec.rb +35 -0
  32. data/spec/lib/virsandra/queries/delete_query_spec.rb +34 -0
  33. data/spec/lib/virsandra/queries/insert_query_spec.rb +36 -0
  34. data/spec/lib/virsandra/queries/limit_query_spec.rb +20 -0
  35. data/spec/lib/virsandra/queries/order_query_spec.rb +33 -0
  36. data/spec/lib/virsandra/queries/select_query_spec.rb +108 -0
  37. data/spec/lib/virsandra/queries/table_query_spec.rb +13 -0
  38. data/spec/lib/virsandra/queries/values_query_spec.rb +41 -0
  39. data/spec/lib/virsandra/queries/where_query_spec.rb +76 -0
  40. data/spec/lib/virsandra/query_spec.rb +117 -0
  41. data/spec/lib/virsandra_spec.rb +108 -0
  42. data/spec/spec_helper.rb +19 -0
  43. metadata +207 -0
@@ -0,0 +1,108 @@
1
+ require 'spec_helper'
2
+
3
+ describe Virsandra do
4
+ let(:config){ double("config", :changed? => false, :accept_changes => true) }
5
+ let(:connection){ double("connection") }
6
+ subject{ described_class }
7
+
8
+ before do
9
+ described_class::Connection.stub(new: connection)
10
+ described_class::Configuration.stub(new: config)
11
+ described_class.disconnect!
12
+ described_class.reset_configuration!
13
+ end
14
+
15
+ after do
16
+ described_class::Connection.unstub(:new)
17
+ described_class::Configuration.unstub(:new)
18
+ described_class.disconnect!
19
+ described_class.reset_configuration!
20
+ end
21
+
22
+ describe "#execute" do
23
+ it "should be delegated to connection" do
24
+ connection.should_receive(:execute).with("query")
25
+ described_class.execute("query")
26
+ end
27
+ end
28
+
29
+ describe "#connection" do
30
+ it "should pass configuration to connection" do
31
+ described_class::Connection.should_receive(:new).with(config).once
32
+ described_class.connection
33
+ described_class.connection.should eq(connection)
34
+ end
35
+
36
+ it "should create new connection when configuration has been changed" do
37
+ described_class::Connection.should_receive(:new).twice
38
+ described_class.connection
39
+ config.stub(:changed? => true)
40
+ described_class.connection
41
+ end
42
+
43
+ it "should have connection for each thread" do
44
+ described_class::Connection.should_receive(:new).twice
45
+ threads = []
46
+ threads << Thread.new{ described_class.connection }
47
+ threads << Thread.new{ described_class.connection }
48
+ threads.map(&:join)
49
+ end
50
+ end
51
+
52
+
53
+ describe "#configuration" do
54
+ it "returns configuration" do
55
+ described_class.configuration.should eq(config)
56
+ end
57
+
58
+ it "should have configuration for every thread" do
59
+ described_class::Configuration.should_receive(:new).twice
60
+ threads = []
61
+ threads << Thread.new{ described_class.configuration }
62
+ threads << Thread.new{ described_class.configuration }
63
+ threads.map(&:join)
64
+ end
65
+ end
66
+
67
+ describe "#configure" do
68
+ it "should yield to block if block given" do
69
+ expect{|b| described_class.configure(&b) }.to yield_with_args(config)
70
+ end
71
+ end
72
+
73
+ describe "delegation to configuration" do
74
+ [:keyspace, :servers, :consistency, :reset!].each do |method_name|
75
+ it "should deletege #{method_name} to configuration" do
76
+ config.should_receive(method_name).any_number_of_times.and_return("value")
77
+ described_class.send(method_name).should eq("value")
78
+ end
79
+ end
80
+
81
+ [:keyspace=, :servers=, :consistency=].each do |method_name|
82
+ it "should deletege #{method_name} to configuration" do
83
+ config.should_receive(method_name).with("value").any_number_of_times
84
+ described_class.send(method_name, "value")
85
+ end
86
+ end
87
+ end
88
+
89
+ describe "#dissconnect!" do
90
+ it "should dissconnect" do
91
+ described_class.connection
92
+ connection.stub(respond_to?: true)
93
+ connection.should_receive(:disconnect!)
94
+ described_class.disconnect!
95
+ end
96
+ end
97
+
98
+ describe "#reset_configuration!" do
99
+ it "should reset configuration" do
100
+ described_class::Configuration.should_receive(:new).twice
101
+ described_class.configuration
102
+ described_class.reset_configuration!
103
+ described_class.configuration
104
+ end
105
+ end
106
+
107
+
108
+ end
@@ -0,0 +1,19 @@
1
+ require 'bundler/setup'
2
+
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+
6
+ require 'simplecov'
7
+ SimpleCov.start
8
+
9
+ require 'rspec'
10
+ require 'virsandra'
11
+
12
+ RSpec.configure do |config|
13
+ config.treat_symbols_as_metadata_keys_with_true_values = true
14
+ config.run_all_when_everything_filtered = true
15
+ config.filter_run :focus
16
+
17
+ config.order = 'random'
18
+ end
19
+
metadata ADDED
@@ -0,0 +1,207 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: virsandra
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Robert Crim
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ type: :runtime
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: 0.5.5
21
+ none: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.5.5
27
+ none: false
28
+ prerelease: false
29
+ name: virtus
30
+ - !ruby/object:Gem::Dependency
31
+ type: :runtime
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ~>
35
+ - !ruby/object:Gem::Version
36
+ version: 1.0.4
37
+ none: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ version: 1.0.4
43
+ none: false
44
+ prerelease: false
45
+ name: cql-rb
46
+ - !ruby/object:Gem::Dependency
47
+ type: :runtime
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ~>
51
+ - !ruby/object:Gem::Version
52
+ version: 0.3.0
53
+ none: false
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ version: 0.3.0
59
+ none: false
60
+ prerelease: false
61
+ name: simple_uuid
62
+ - !ruby/object:Gem::Dependency
63
+ type: :development
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 10.0.4
69
+ none: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ version: 10.0.4
75
+ none: false
76
+ prerelease: false
77
+ name: rake
78
+ - !ruby/object:Gem::Dependency
79
+ type: :development
80
+ requirement: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ~>
83
+ - !ruby/object:Gem::Version
84
+ version: 2.13.0
85
+ none: false
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: 2.13.0
91
+ none: false
92
+ prerelease: false
93
+ name: rspec
94
+ - !ruby/object:Gem::Dependency
95
+ type: :development
96
+ requirement: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ~>
99
+ - !ruby/object:Gem::Version
100
+ version: 0.7.1
101
+ none: false
102
+ version_requirements: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ~>
105
+ - !ruby/object:Gem::Version
106
+ version: 0.7.1
107
+ none: false
108
+ prerelease: false
109
+ name: simplecov
110
+ description: Cassandra CQL3 persistence for Virtus extended classes
111
+ email:
112
+ - rob@servermilk.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files:
116
+ - LICENSE.txt
117
+ - README.md
118
+ files:
119
+ - lib/virsandra/model_query.rb
120
+ - lib/virsandra/version.rb
121
+ - lib/virsandra/cql_value.rb
122
+ - lib/virsandra/queries/alter_query.rb
123
+ - lib/virsandra/queries/table_query.rb
124
+ - lib/virsandra/queries/limit_query.rb
125
+ - lib/virsandra/queries/insert_query.rb
126
+ - lib/virsandra/queries/values_query.rb
127
+ - lib/virsandra/queries/delete_query.rb
128
+ - lib/virsandra/queries/select_query.rb
129
+ - lib/virsandra/queries/order_query.rb
130
+ - lib/virsandra/queries/where_query.rb
131
+ - lib/virsandra/queries/add_query.rb
132
+ - lib/virsandra/model.rb
133
+ - lib/virsandra/errors.rb
134
+ - lib/virsandra/connection.rb
135
+ - lib/virsandra/query.rb
136
+ - lib/virsandra/configuration.rb
137
+ - lib/virsandra.rb
138
+ - Rakefile
139
+ - README.md
140
+ - LICENSE.txt
141
+ - spec/feature_helper.rb
142
+ - spec/spec_helper.rb
143
+ - spec/lib/virsandra/model_spec.rb
144
+ - spec/lib/virsandra/connection_spec.rb
145
+ - spec/lib/virsandra/query_spec.rb
146
+ - spec/lib/virsandra/queries/limit_query_spec.rb
147
+ - spec/lib/virsandra/queries/table_query_spec.rb
148
+ - spec/lib/virsandra/queries/alter_query_spec.rb
149
+ - spec/lib/virsandra/queries/delete_query_spec.rb
150
+ - spec/lib/virsandra/queries/values_query_spec.rb
151
+ - spec/lib/virsandra/queries/order_query_spec.rb
152
+ - spec/lib/virsandra/queries/where_query_spec.rb
153
+ - spec/lib/virsandra/queries/insert_query_spec.rb
154
+ - spec/lib/virsandra/queries/select_query_spec.rb
155
+ - spec/lib/virsandra/queries/add_query_spec.rb
156
+ - spec/lib/virsandra/cql_value_spec.rb
157
+ - spec/lib/virsandra/configuration_spec.rb
158
+ - spec/lib/virsandra/model_query_spec.rb
159
+ - spec/lib/virsandra_spec.rb
160
+ - spec/integration/virsandra_spec.rb
161
+ homepage: https://github.com/ottbot/virsandra
162
+ licenses:
163
+ - MIT
164
+ post_install_message:
165
+ rdoc_options: []
166
+ require_paths:
167
+ - lib
168
+ required_ruby_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ! '>='
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ none: false
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ! '>='
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ none: false
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 1.8.25
183
+ signing_key:
184
+ specification_version: 3
185
+ summary: Easily store models defined with Virtus in Cassandra using CQL3
186
+ test_files:
187
+ - spec/feature_helper.rb
188
+ - spec/spec_helper.rb
189
+ - spec/lib/virsandra/model_spec.rb
190
+ - spec/lib/virsandra/connection_spec.rb
191
+ - spec/lib/virsandra/query_spec.rb
192
+ - spec/lib/virsandra/queries/limit_query_spec.rb
193
+ - spec/lib/virsandra/queries/table_query_spec.rb
194
+ - spec/lib/virsandra/queries/alter_query_spec.rb
195
+ - spec/lib/virsandra/queries/delete_query_spec.rb
196
+ - spec/lib/virsandra/queries/values_query_spec.rb
197
+ - spec/lib/virsandra/queries/order_query_spec.rb
198
+ - spec/lib/virsandra/queries/where_query_spec.rb
199
+ - spec/lib/virsandra/queries/insert_query_spec.rb
200
+ - spec/lib/virsandra/queries/select_query_spec.rb
201
+ - spec/lib/virsandra/queries/add_query_spec.rb
202
+ - spec/lib/virsandra/cql_value_spec.rb
203
+ - spec/lib/virsandra/configuration_spec.rb
204
+ - spec/lib/virsandra/model_query_spec.rb
205
+ - spec/lib/virsandra_spec.rb
206
+ - spec/integration/virsandra_spec.rb
207
+ has_rdoc: