cequel 3.0.2 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1697dbd75c69854dffccbe95b14689a6f5d4453
4
- data.tar.gz: 62a729f6421425b0fdf188fca359498520f09ac1
3
+ metadata.gz: 6b2ad23f8a516eb2960f68a69b5d33d87ba81b99
4
+ data.tar.gz: 794306c91044e4e766694c0f029a3eba596e5552
5
5
  SHA512:
6
- metadata.gz: 13716de6aa85d3007df82a7330f1cca8e0cc46f08b4ac477a0381222bd01301b58a439e58c15a19561361cb26221fff6be7cc5c02ebba495b4ded5724efbf8e0
7
- data.tar.gz: 8ed5d80b009c48845ff74e3d2ccca6001408525131591caf6eb1aee4df9e77dc18112bb88f8ff4c1495c31917485a4a7415bf0ac9d6721a741e63946e6ebcf6b
6
+ metadata.gz: 68ae5930111f56d55bdedcef4e1999d21483e6c2a223961f5a249b05f9f4b25ee966e88cc7f4092276e0fb5e6b76769b285abd979cb340c0c35c4b8dab51aa78
7
+ data.tar.gz: a5ca1b83b34b2b6a00ebfa9bed2e075ebe4e569f0254563e6d5c432c25f1c51d01bb1e2ea536c58ac89635b727909d5c8d28ad4777f32cc9e43f70c8d820d131
@@ -1,3 +1,6 @@
1
+ ## 3.0.4
2
+ - support ruby 2.5 and rails 5.2 (https://github.com/cequel/cequel/pull/401)
3
+
1
4
  ## 3.0.2
2
5
  - support rails 5.1 (https://github.com/cequel/cequel/pull/389)
3
6
  - various small changes
@@ -41,23 +41,35 @@ bundle exec rake test
41
41
 
42
42
  ### Using Docker
43
43
 
44
- Cequel's test suite runs against a live Cassandra instance. The easiest way to
45
- get one is to use Docker, `docker run --rm -p 9042:9042 cassandra`.
44
+ Cequel's test suite, including a development bash environment, container, and Cassandra
45
+ instance is setup for use through Docker Compose.
46
46
 
47
- ### Using different ports
47
+ The local folder is mapped into the docker container. So, you can use your IDE of choice
48
+ to make edits, leveraging the docker-compose to provide Cassandra and an lightweight container for
49
+ running tests.
48
50
 
49
- You can configure the cequel test suite to use a different port by setting the `CEQUEL_TEST_PORT` environment variable. Example:
50
- 1. `docker run --rm -p 33333:9042 cassandra` in one terminal
51
- 1. `rake test CEQUEL_TEST_PORT=33333` in another termainal
51
+ To use, update the docker-compose.yml with your personal details (for Git compatibility) and then:
52
+ ```bash
53
+ docker-compose run dev
54
+ ```
55
+ This will drop you to a bash prompt in the `/cequel/` folder. From there, you can run
56
+ tests using familiar RSpec commands.
52
57
 
53
58
  ### Cassandra versions
54
59
 
55
60
  Cequel is tested against a large range of Ruby, Rails, and Cassandra
56
- versions; for most patches, you can just run the tests using the
61
+ versions; for most patches, you can develop the tests using the
57
62
  latest version of all of them. If you're messing with the
58
63
  `Cequel::Schema` or `Cequel::Type` modules, you'll want to test at
59
64
  least against the first and latest releases of 2.1, 2.2 and 3 series.
60
65
 
66
+ If want to use a specific version of Cassandra in development do this:
67
+
68
+ ```bash
69
+ docker-compose down
70
+ CASSANDRA_VERSION=3.10 docker-compose run dev
71
+ ```
72
+
61
73
  ## And finally
62
74
 
63
75
  **THANK YOU!**
@@ -0,0 +1,29 @@
1
+ FROM ruby:alpine
2
+
3
+ # Put the basic system setup in a layer of its own so we don't have
4
+ # rebuild it all the time.
5
+ RUN apk add --update build-base tzdata bash bash-completion git \
6
+ && rm -rf /var/cache/apk/*
7
+
8
+ WORKDIR /cequel
9
+
10
+ # Make it nicer to run tests.. now "ber" instead of "bundle exec rspec" and "bi" instead of "bundle install"
11
+ RUN echo 'alias be="bundle exec"' >> ~/.bashrc \
12
+ && echo 'alias ber="bundle exec rspec"' >> ~/.bashrc \
13
+ && echo 'alias bi="bundle install"' >> ~/.bashrc
14
+
15
+ # Put the bundle in a layer of its own. The bundle doesn't change
16
+ # that often to copy just the Gemfiles and bundle to build a layer
17
+ # that rarely changes
18
+ COPY ./Gemfile* /cequel/
19
+ COPY ./cequel.gemspec /cequel/
20
+ RUN mkdir -p /cequel/lib/cequel/
21
+ COPY ./lib/cequel/version.rb /cequel/lib/cequel/
22
+ RUN gem install bundler \
23
+ && bundle install
24
+
25
+
26
+ COPY ./* /cequel/
27
+
28
+
29
+
@@ -1,18 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cequel (3.0.2)
4
+ cequel (3.0.4)
5
5
  activemodel (>= 4.0)
6
6
  cassandra-driver (~> 3.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (5.1.4)
12
- activesupport (= 5.1.4)
13
- activesupport (5.1.4)
11
+ activemodel (5.2.1)
12
+ activesupport (= 5.2.1)
13
+ activesupport (5.2.1)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
- i18n (~> 0.7)
15
+ i18n (>= 0.7, < 2)
16
16
  minitest (~> 5.1)
17
17
  tzinfo (~> 1.1)
18
18
  addressable (2.4.0)
@@ -25,7 +25,7 @@ GEM
25
25
  byebug (2.7.0)
26
26
  columnize (~> 0.3)
27
27
  debugger-linecache (~> 1.2)
28
- cassandra-driver (3.2.0)
28
+ cassandra-driver (3.2.3)
29
29
  ione (~> 1.2)
30
30
  coderay (1.1.2)
31
31
  columnize (0.9.0)
@@ -49,7 +49,7 @@ GEM
49
49
  net-http-persistent (~> 2.9)
50
50
  net-http-pipeline
51
51
  highline (1.7.8)
52
- i18n (0.9.1)
52
+ i18n (1.1.1)
53
53
  concurrent-ruby (~> 1.0)
54
54
  ione (1.2.4)
55
55
  json (2.1.0)
@@ -60,7 +60,7 @@ GEM
60
60
  addressable (~> 2.3)
61
61
  spoon (~> 0.0.1)
62
62
  method_source (0.9.0)
63
- minitest (5.10.3)
63
+ minitest (5.11.3)
64
64
  multi_json (1.12.2)
65
65
  multipart-post (2.0.0)
66
66
  net-http-persistent (2.9.4)
@@ -327,7 +327,7 @@ GEM
327
327
  typhoeus (~> 0.6, >= 0.6.8)
328
328
  typhoeus (0.8.0)
329
329
  ethon (>= 0.8.0)
330
- tzinfo (1.2.4)
330
+ tzinfo (1.2.5)
331
331
  thread_safe (~> 0.1)
332
332
  unicode-display_width (1.3.0)
333
333
  websocket (1.2.4)
@@ -357,4 +357,4 @@ DEPENDENCIES
357
357
  yard (~> 0.6)
358
358
 
359
359
  BUNDLED WITH
360
- 1.14.6
360
+ 1.17.1
data/README.md CHANGED
@@ -594,7 +594,8 @@ you require this functionality.
594
594
  ## Compatibility ##
595
595
 
596
596
  ### Rails ###
597
-
597
+ * 5.2
598
+ * 5.1
598
599
  * 5.0
599
600
  * 4.2
600
601
  * 4.1
@@ -602,7 +603,7 @@ you require this functionality.
602
603
 
603
604
  ### Ruby ###
604
605
 
605
- * Ruby 2.3, 2.2, 2.1, 2.0
606
+ * Ruby 2.5, 2,4, 2.3, 2.2, 2.1, 2.0
606
607
 
607
608
  ### Cassandra ###
608
609
 
@@ -55,13 +55,14 @@ module Cequel
55
55
  end
56
56
  end
57
57
 
58
+ def current_batch
59
+ ::Thread.current[batch_key]
60
+ end
61
+
58
62
  private
59
63
 
60
64
  attr_reader :keyspace
61
65
 
62
- def current_batch
63
- ::Thread.current[batch_key]
64
- end
65
66
 
66
67
  def current_batch=(batch)
67
68
  ::Thread.current[batch_key] = batch
@@ -696,12 +696,8 @@ module Cequel
696
696
  end
697
697
  end
698
698
 
699
- protected
700
-
701
699
  attr_writer :row_limit, :query_consistency, :query_page_size, :query_paging_state, :allow_filtering
702
700
 
703
- private
704
-
705
701
  def results
706
702
  @results ||= execute_cql(cql)
707
703
  end
@@ -730,6 +726,8 @@ module Cequel
730
726
  Deleter.new(self, &block)
731
727
  end
732
728
 
729
+ private
730
+
733
731
  def initialize_copy(source)
734
732
  super
735
733
  @select_columns = source.select_columns.clone
@@ -188,8 +188,6 @@ module Cequel
188
188
  end
189
189
  end
190
190
 
191
- private
192
-
193
191
  def read_parent_association
194
192
  ivar_name = parent_association.instance_variable_name
195
193
  if instance_variable_defined?(ivar_name)
@@ -218,7 +218,7 @@ module Cequel
218
218
  # @param elements [Array] new elements to replace in this range
219
219
  #
220
220
  def []=(*args)
221
- if args[0].is_a?(Fixnum) && args.count == 2
221
+ if args[0].is_a?(Integer) && args.count == 2
222
222
  # single element set/replace
223
223
  elem = cast_element(args[1])
224
224
 
@@ -231,7 +231,7 @@ module Cequel
231
231
  # multi-element set/replace
232
232
  range = if args[0].is_a?(Range)
233
233
  args[0]
234
- elsif args[0].is_a?(Fixnum) && args[1].is_a?(Fixnum)
234
+ elsif args[0].is_a?(Integer) && args[1].is_a?(Integer)
235
235
  args[0]..(args[0]+args[1]-1)
236
236
  else
237
237
  Kernel.raise ArgumentError, "[i]=elem or [i,count]=elems or [a..b]=elems"
@@ -47,8 +47,12 @@ module Cequel
47
47
  def save(options = {})
48
48
  super.tap do |success|
49
49
  if success
50
- @previously_changed = changes
51
- @changed_attributes.clear
50
+ if self.respond_to?(:changes_applied)
51
+ changes_applied
52
+ else
53
+ @previously_changed = changes
54
+ @changed_attributes.clear
55
+ end
52
56
  end
53
57
  end
54
58
  end
@@ -82,7 +82,7 @@ module Cequel
82
82
  # @since 1.0.0
83
83
  #
84
84
  def key_attributes
85
- @attributes.slice(*self.class.key_column_names)
85
+ @cequel_attributes.slice(*self.class.key_column_names)
86
86
  end
87
87
 
88
88
  #
@@ -160,7 +160,7 @@ module Cequel
160
160
  # @since 1.0.0
161
161
  #
162
162
  def loaded?(column = nil)
163
- !!@loaded && (column.nil? || @attributes.key?(column.to_sym))
163
+ !!@loaded && (column.nil? || @cequel_attributes.key?(column.to_sym))
164
164
  end
165
165
 
166
166
  #
@@ -260,6 +260,16 @@ module Cequel
260
260
  self
261
261
  end
262
262
 
263
+ def updater
264
+ raise ArgumentError, "Can't get updater for new record" if new_record?
265
+ @updater ||= Metal::Updater.new(metal_scope)
266
+ end
267
+
268
+ def deleter
269
+ raise ArgumentError, "Can't get deleter for new record" if new_record?
270
+ @deleter ||= Metal::Deleter.new(metal_scope)
271
+ end
272
+
263
273
  protected
264
274
 
265
275
  def persisted!
@@ -291,16 +301,6 @@ module Cequel
291
301
  end
292
302
  instrument :update, data: ->(rec) { {table_name: rec.table_name} }
293
303
 
294
- def updater
295
- raise ArgumentError, "Can't get updater for new record" if new_record?
296
- @updater ||= Metal::Updater.new(metal_scope)
297
- end
298
-
299
- def deleter
300
- raise ArgumentError, "Can't get deleter for new record" if new_record?
301
- @deleter ||= Metal::Deleter.new(metal_scope)
302
- end
303
-
304
304
  private
305
305
 
306
306
  def_delegators 'self.class', :connection, :table
@@ -361,17 +361,17 @@ module Cequel
361
361
  end
362
362
 
363
363
  def attributes_for_create
364
- @attributes.each_with_object({}) do |(column, value), attributes|
364
+ @cequel_attributes.each_with_object({}) do |(column, value), attributes|
365
365
  attributes[column] = value unless value.nil?
366
366
  end
367
367
  end
368
368
 
369
369
  def attributes_for_update
370
- @attributes_for_update ||= {}
370
+ @cequel_attributes_for_update ||= {}
371
371
  end
372
372
 
373
373
  def attributes_for_deletion
374
- @attributes_for_deletion ||= []
374
+ @cequel_attributes_for_deletion ||= []
375
375
  end
376
376
 
377
377
  def assert_keys_present!
@@ -281,7 +281,7 @@ module Cequel
281
281
 
282
282
  # @private
283
283
  def initialize(attributes = {}, record_collection = nil)
284
- @attributes, @record_collection = attributes, record_collection
284
+ @cequel_attributes, @record_collection = attributes, record_collection
285
285
  @collection_proxies = {}
286
286
  end
287
287
 
@@ -289,7 +289,7 @@ module Cequel
289
289
  # @return [Array<Symbol>] list of names of attributes on this record
290
290
  #
291
291
  def attribute_names
292
- @attributes.keys
292
+ @cequel_attributes.keys
293
293
  end
294
294
 
295
295
  #
@@ -367,7 +367,7 @@ module Cequel
367
367
  protected
368
368
 
369
369
  def read_attribute(name)
370
- @attributes.fetch(name)
370
+ @cequel_attributes.fetch(name)
371
371
  rescue KeyError
372
372
  if self.class.reflect_on_column(name)
373
373
  fail MissingAttributeError, "missing attribute: #{name}"
@@ -382,7 +382,7 @@ module Cequel
382
382
  end
383
383
 
384
384
  send("#{name}_will_change!") unless value === read_attribute(name)
385
- @attributes[name] = value
385
+ @cequel_attributes[name] = value
386
386
  end
387
387
 
388
388
  private
@@ -397,14 +397,14 @@ module Cequel
397
397
  end
398
398
 
399
399
  def init_attributes(new_attributes)
400
- @attributes = {}
400
+ @cequel_attributes = {}
401
401
  new_attributes.each_pair do |name, value|
402
402
  if value.nil?
403
403
  value = empty_attributes.fetch(name.to_sym) { -> {} }.call
404
404
  end
405
- @attributes[name.to_sym] = value
405
+ @cequel_attributes[name.to_sym] = value
406
406
  end
407
- @attributes
407
+ @cequel_attributes
408
408
  end
409
409
 
410
410
  def initialize_new_record(attributes = {})
@@ -123,7 +123,7 @@ module Cequel
123
123
  #
124
124
  def initialize(target_class, attributes = {})
125
125
  attributes = self.class.default_attributes.merge!(attributes)
126
- @target_class, @attributes = target_class, attributes
126
+ @target_class, @cequel_attributes = target_class, attributes
127
127
  super(target_class)
128
128
  end
129
129
 
@@ -705,19 +705,49 @@ module Cequel
705
705
  entries
706
706
  end
707
707
 
708
- protected
708
+ def attributes
709
+ cequel_attributes
710
+ end
711
+
712
+ def attributes=(attrs)
713
+ self.cequel_attributes = attr
714
+ end
715
+
716
+ attr_accessor :cequel_attributes
717
+
718
+ def unscoped_key_names
719
+ unscoped_key_columns.map { |column| column.name }
720
+ end
721
+
722
+ def order_by_column
723
+ if target_class.clustering_columns.any?
724
+ target_class.clustering_columns.first
725
+ end
726
+ end
709
727
 
710
- attr_reader :attributes
711
- hattr_reader :attributes, :select_columns, :scoped_key_values,
728
+ def scoped_key_names
729
+ scoped_key_columns.map { |column| column.name }
730
+ end
731
+
732
+ hattr_inquirer :attributes, :reversed
733
+
734
+ def ascends_by?(column)
735
+ !descends_by?(column)
736
+ end
737
+
738
+ def descends_by?(column)
739
+ column.clustering_column? &&
740
+ (reversed? ^ (column.clustering_order == :desc))
741
+ end
742
+
743
+
744
+ hattr_reader :cequel_attributes, :select_columns, :scoped_key_values,
712
745
  :row_limit, :lower_bound, :upper_bound,
713
746
  :scoped_indexed_column, :query_consistency,
714
747
  :query_page_size, :query_paging_state,
715
748
  :allow_filtering
716
- protected :select_columns, :scoped_key_values, :row_limit, :lower_bound,
717
- :upper_bound, :scoped_indexed_column, :query_consistency,
718
- :query_page_size, :query_paging_state, :allow_filtering
719
- hattr_inquirer :attributes, :reversed
720
- protected :reversed?
749
+
750
+ protected
721
751
 
722
752
  def next_batch_from(row)
723
753
  range_key_value = row[range_key_name]
@@ -728,15 +758,6 @@ module Cequel
728
758
  end
729
759
  end
730
760
 
731
- def ascends_by?(column)
732
- !descends_by?(column)
733
- end
734
-
735
- def descends_by?(column)
736
- column.clustering_column? &&
737
- (reversed? ^ (column.clustering_order == :desc))
738
- end
739
-
740
761
  def find_nested_batches_from(row, options, &block)
741
762
  return unless next_range_key_column
742
763
 
@@ -836,10 +857,6 @@ module Cequel
836
857
  scoped(scoped_indexed_column: {column_name => column.cast(value)})
837
858
  end
838
859
 
839
- def scoped_key_names
840
- scoped_key_columns.map { |column| column.name }
841
- end
842
-
843
860
  def scoped_key_columns
844
861
  target_class.key_columns.first(scoped_key_values.length)
845
862
  end
@@ -848,10 +865,6 @@ module Cequel
848
865
  target_class.key_columns.drop(scoped_key_values.length)
849
866
  end
850
867
 
851
- def unscoped_key_names
852
- unscoped_key_columns.map { |column| column.name }
853
- end
854
-
855
868
  def range_key_column
856
869
  unscoped_key_columns.first
857
870
  end
@@ -913,12 +926,6 @@ module Cequel
913
926
  end
914
927
  end
915
928
 
916
- def order_by_column
917
- if target_class.clustering_columns.any?
918
- target_class.clustering_columns.first
919
- end
920
- end
921
-
922
929
  def selects_collection_columns?
923
930
  select_columns.any? do |column_name|
924
931
  target_class.reflect_on_column(column_name).collection_column?
@@ -60,7 +60,7 @@ module Cequel
60
60
 
61
61
  def initialize_new_record(*)
62
62
  super
63
- @attributes.merge!(self.class.current_scope.scoped_key_attributes)
63
+ @cequel_attributes.merge!(self.class.current_scope.scoped_key_attributes)
64
64
  end
65
65
  end
66
66
  end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Cequel
3
3
  # The current version of the library
4
- VERSION = '3.0.2'
4
+ VERSION = '3.0.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Brown
@@ -26,10 +26,11 @@ authors:
26
26
  - Tamara Temple
27
27
  - Long On
28
28
  - Lucas Mundim
29
+ - William Flanagan
29
30
  autorequire:
30
31
  bindir: bin
31
32
  cert_chain: []
32
- date: 2018-04-11 00:00:00.000000000 Z
33
+ date: 2018-11-04 00:00:00.000000000 Z
33
34
  dependencies:
34
35
  - !ruby/object:Gem::Dependency
35
36
  name: activemodel
@@ -207,12 +208,12 @@ description: |
207
208
  email: mat.a.brown@gmail.com
208
209
  executables: []
209
210
  extensions: []
210
- extra_rdoc_files:
211
- - README.md
211
+ extra_rdoc_files: []
212
212
  files:
213
213
  - Appraisals
214
214
  - CHANGELOG.md
215
215
  - CONTRIBUTING.md
216
+ - Dockerfile
216
217
  - Gemfile
217
218
  - Gemfile.lock
218
219
  - LICENSE
@@ -342,7 +343,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
342
343
  requirements:
343
344
  - Cassandra >= 2.0.0
344
345
  rubyforge_project:
345
- rubygems_version: 2.5.1
346
+ rubygems_version: 2.6.13
346
347
  signing_key:
347
348
  specification_version: 4
348
349
  summary: Full-featured, ActiveModel-compliant ORM for Cassandra using CQL3