whi-cassie 1.2.0 → 1.3.0

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
  SHA256:
3
- metadata.gz: cc03cb8a9fdac75018c3c31a5466a681a7e57f4584c5d3c4540d012da48c8bc9
4
- data.tar.gz: 7576c9d2d998329cc918cc8c7dad45eda0012d420c123b7cfb9412c82873ab24
3
+ metadata.gz: 38924e7460050a72c231a359a4a07e1695349b55d24868ae8332a0ecbcf61356
4
+ data.tar.gz: 69f5b3396cb45c8f3247ba377d456173ac114220b2247163bc74060e9cff921a
5
5
  SHA512:
6
- metadata.gz: c60020caa9c11330c2c5713bbd0962cf1682f07f351815b60975b608af50031627a08c27d50e1175ffc02d44da368cc64e71f7a337164cf1dddd75da415e6dc6
7
- data.tar.gz: 2690d2fb060d226a11d81cba9db78251bce6ca0a744e27ddd1975e82b2db7376bc247c58b6a1af895da0b81a2d21e1e3b6f3eda64234e52a973b3d0ce221743b
6
+ metadata.gz: 46242596cf88a2d0600be23bb25a5138c7090acc952ccdbab3344d36abb1cd94ef4aef85bae071f60275297f10571377704a7de7348875cd0984439c7a3aecfd
7
+ data.tar.gz: d6e68b1ffd9a28cb27984e01bbce135502b4107d50be350d275dd745375fb5a2b90efa5384a4578c250654674b0ae7512bfe529fe3dc21f52c59b37b87e390e3
@@ -24,22 +24,23 @@ jobs:
24
24
  strategy:
25
25
  fail-fast: false
26
26
  matrix:
27
- ruby: [2.7]
28
- activemodel: [6]
27
+ ruby: ["3.0"]
28
+ activemodel: ["original"]
29
29
  job: [rspec]
30
- cassandra_version: ["4.0"]
30
+ cassandra_version: ["latest"]
31
31
  include:
32
- - ruby: 2.6
33
- activemodel: 5
32
+ - ruby: "2.6"
33
+ activemodel: "5"
34
34
  job: rspec
35
35
  cassandra_version: "3"
36
- - ruby: 2.4
37
- activemodel: 4
36
+ - ruby: "2.4"
37
+ activemodel: "4"
38
38
  job: rspec
39
39
  cassandra_version: "2"
40
- - ruby: 2.7
40
+ - ruby: "2.7"
41
+ activemodel: "6"
42
+ - ruby: "3.0"
41
43
  job: standardrb
42
- cassandra_version: "latest"
43
44
  steps:
44
45
  - name: checkout
45
46
  uses: actions/checkout@v2
data/.gitignore CHANGED
@@ -4,3 +4,6 @@ rdoc
4
4
  *.rbc
5
5
  .tm_properties
6
6
  .DS_Store
7
+ .env
8
+ Gemfile.lock
9
+ gemfiles/*.lock
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.0.2
data/Appraisals CHANGED
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ appraise "activemodel-7" do
4
+ gem "activemodel", "~> 7.0"
5
+ end
6
+
3
7
  appraise "activemodel-6" do
4
8
  gem "activemodel", "~> 6.0"
5
9
  end
data/Gemfile CHANGED
@@ -6,5 +6,5 @@ group :development, :test do
6
6
  gem "rake"
7
7
  gem "rspec"
8
8
  gem "appraisal"
9
- gem "standard", "~>0.8.1"
9
+ gem "standard", "~>1.0"
10
10
  end
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.3.0
2
+
3
+ * Add update, update!, primary_key, and reload methods to models.
4
+
1
5
  ## 1.2.0
2
6
 
3
7
  * Update schema queries to support Cassandra 3.x+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.3.0
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_RETRY: "1"
@@ -8,7 +8,7 @@ group :development, :test do
8
8
  gem "rake"
9
9
  gem "rspec"
10
10
  gem "appraisal"
11
- gem "standard", "~>0.8.1"
11
+ gem "standard", "~>1.0"
12
12
  end
13
13
 
14
14
  gemspec path: "../"
@@ -8,7 +8,7 @@ group :development, :test do
8
8
  gem "rake"
9
9
  gem "rspec"
10
10
  gem "appraisal"
11
- gem "standard", "~>0.8.1"
11
+ gem "standard", "~>1.0"
12
12
  end
13
13
 
14
14
  gemspec path: "../"
@@ -8,7 +8,7 @@ group :development, :test do
8
8
  gem "rake"
9
9
  gem "rspec"
10
10
  gem "appraisal"
11
- gem "standard", "~>0.8.1"
11
+ gem "standard", "~>1.0"
12
12
  end
13
13
 
14
14
  gemspec path: "../"
@@ -0,0 +1,14 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activemodel", "~> 7.0"
6
+
7
+ group :development, :test do
8
+ gem "rake"
9
+ gem "rspec"
10
+ gem "appraisal"
11
+ gem "standard", "~>1.0"
12
+ end
13
+
14
+ gemspec path: "../"
data/lib/cassie/model.rb CHANGED
@@ -451,7 +451,7 @@ module Cassie::Model
451
451
  elsif type_class == Cassandra::Types::Set
452
452
  Set.new(value)
453
453
  elsif type_class == Cassandra::Types::Map
454
- Hash[value]
454
+ value.to_h
455
455
  else
456
456
  type_class.new(value)
457
457
  end
@@ -531,6 +531,18 @@ module Cassie::Model
531
531
  end
532
532
  end
533
533
 
534
+ # Update a record with the specified attributes. Returns false the record is invalid.
535
+ def update(values)
536
+ self.attributes = values
537
+ save
538
+ end
539
+
540
+ # Update a record with the specified attributes and raise an error if it is invalid.
541
+ def update!(values)
542
+ self.attributes = values
543
+ save!
544
+ end
545
+
534
546
  # Returns a hash of column to values. Column names will be symbols.
535
547
  def attributes
536
548
  hash = {}
@@ -540,6 +552,25 @@ module Cassie::Model
540
552
  hash
541
553
  end
542
554
 
555
+ # Mass set attributes from a hash.
556
+ def attributes=(values)
557
+ values.each do |name, value|
558
+ send("#{name}=", value)
559
+ end
560
+ end
561
+
562
+ # Returns a hash representing the primary key value.
563
+ def primary_key
564
+ self.class.primary_key.each_with_object({}) { |name, hash|
565
+ hash[name] = send(name)
566
+ }
567
+ end
568
+
569
+ # Reloads the record in memory.
570
+ def reload
571
+ self.class.find(primary_key)
572
+ end
573
+
543
574
  # Subclasses can override this method to provide a TTL on the persisted record.
544
575
  def persistence_ttl
545
576
  nil
@@ -142,11 +142,15 @@ describe Cassie::Model do
142
142
  it "should get and set attributes" do
143
143
  record = Cassie::Thing.new(owner: 1, id: 2, val: "foo")
144
144
  expect(record.attributes).to eq({owner: 1, id: 2, val: "foo"})
145
+ record.attributes = {owner: 2, id: 3, val: "bar"}
146
+ expect(record.attributes).to eq({owner: 2, id: 3, val: "bar"})
145
147
  end
146
148
 
147
149
  it "should get and set attributes using human readable names" do
148
150
  record = Cassie::Thing.new(owner: 1, identifier: 2, value: "foo")
149
151
  expect(record.attributes).to eq({owner: 1, id: 2, val: "foo"})
152
+ record.attributes = {owner: 2, identifier: 3, val: "bar"}
153
+ expect(record.attributes).to eq({owner: 2, id: 3, val: "bar"})
150
154
  end
151
155
  end
152
156
 
@@ -194,6 +198,25 @@ describe Cassie::Model do
194
198
  end
195
199
  end
196
200
 
201
+ describe "update" do
202
+ it "should set attributes and save" do
203
+ record = Cassie::Thing.create(owner: 1, id: 2, val: "foo")
204
+ record.update(owner: 2)
205
+ record.reload
206
+ expect(record.owner).to eq 2
207
+ record.update!(owner: 3)
208
+ record.reload
209
+ expect(record.owner).to eq 3
210
+ end
211
+ end
212
+
213
+ describe "primary_key" do
214
+ it "should return the primary key as a hash" do
215
+ record = Cassie::Thing.create(owner: 1, id: 2, val: "foo")
216
+ expect(record.primary_key).to eq({owner: 1, id: 2})
217
+ end
218
+ end
219
+
197
220
  describe "destroy" do
198
221
  it "should delete a record from Cassandra calling any destroy callbacks" do
199
222
  Cassie::Thing.create(owner: 1, id: 2, val: "foo")
data/spec/spec_helper.rb CHANGED
@@ -38,7 +38,7 @@ RSpec.configure do |config|
38
38
  break
39
39
  rescue Cassandra::Errors::NoHostsAvailable => e
40
40
  attempts += 1
41
- raise e if attempts > 30
41
+ raise e if attempts > 60
42
42
  sleep(1)
43
43
  end
44
44
  end
data/whi-cassie.gemspec CHANGED
@@ -19,5 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.required_ruby_version = ">= 2.4"
20
20
  spec.add_dependency("cassandra-driver", "~>3.0")
21
21
  spec.add_dependency("activemodel", ">=4.0")
22
+ spec.add_dependency("sorted_set")
22
23
  spec.add_development_dependency "bundler", "~>2.0"
23
24
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whi-cassie
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - We Heart It
8
8
  - Brian Durand
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-10-28 00:00:00.000000000 Z
12
+ date: 2022-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cassandra-driver
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '4.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: sorted_set
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: bundler
44
58
  requirement: !ruby/object:Gem::Requirement
@@ -63,18 +77,20 @@ files:
63
77
  - ".github/dependabot.yml"
64
78
  - ".github/workflows/continuous_integration.yml"
65
79
  - ".gitignore"
80
+ - ".ruby-version"
66
81
  - ".standard.yml"
67
82
  - Appraisals
68
83
  - Gemfile
69
- - Gemfile.lock
70
84
  - HISTORY.md
71
85
  - MIT-LICENSE
72
86
  - README.md
73
87
  - Rakefile
74
88
  - VERSION
89
+ - gemfiles/.bundle/config
75
90
  - gemfiles/activemodel_4.gemfile
76
91
  - gemfiles/activemodel_5.gemfile
77
92
  - gemfiles/activemodel_6.gemfile
93
+ - gemfiles/activemodel_7.gemfile
78
94
  - lib/cassie.rb
79
95
  - lib/cassie/config.rb
80
96
  - lib/cassie/model.rb
@@ -96,7 +112,7 @@ homepage: https://github.com/weheartit/cassie
96
112
  licenses:
97
113
  - MIT
98
114
  metadata: {}
99
- post_install_message:
115
+ post_install_message:
100
116
  rdoc_options: []
101
117
  require_paths:
102
118
  - lib
@@ -111,8 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
127
  - !ruby/object:Gem::Version
112
128
  version: '0'
113
129
  requirements: []
114
- rubygems_version: 3.0.3
115
- signing_key:
130
+ rubygems_version: 3.2.22
131
+ signing_key:
116
132
  specification_version: 4
117
133
  summary: Simple object mapper for Cassandra data tables specifically designed to work
118
134
  with the limitations and strengths of Cassandra.
data/Gemfile.lock DELETED
@@ -1,89 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- whi-cassie (1.2.0)
5
- activemodel (>= 4.0)
6
- cassandra-driver (~> 3.0)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- activemodel (6.0.3.4)
12
- activesupport (= 6.0.3.4)
13
- activesupport (6.0.3.4)
14
- concurrent-ruby (~> 1.0, >= 1.0.2)
15
- i18n (>= 0.7, < 2)
16
- minitest (~> 5.1)
17
- tzinfo (~> 1.1)
18
- zeitwerk (~> 2.2, >= 2.2.2)
19
- appraisal (2.3.0)
20
- bundler
21
- rake
22
- thor (>= 0.14.0)
23
- ast (2.4.1)
24
- cassandra-driver (3.2.5)
25
- ione (~> 1.2)
26
- concurrent-ruby (1.1.7)
27
- diff-lcs (1.4.4)
28
- i18n (1.8.5)
29
- concurrent-ruby (~> 1.0)
30
- ione (1.2.4)
31
- minitest (5.14.2)
32
- parallel (1.19.2)
33
- parser (2.7.2.0)
34
- ast (~> 2.4.1)
35
- rainbow (3.0.0)
36
- rake (13.0.1)
37
- regexp_parser (1.8.2)
38
- rexml (3.2.4)
39
- rspec (3.9.0)
40
- rspec-core (~> 3.9.0)
41
- rspec-expectations (~> 3.9.0)
42
- rspec-mocks (~> 3.9.0)
43
- rspec-core (3.9.3)
44
- rspec-support (~> 3.9.3)
45
- rspec-expectations (3.9.3)
46
- diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.9.0)
48
- rspec-mocks (3.9.1)
49
- diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.9.0)
51
- rspec-support (3.9.4)
52
- rubocop (1.0.0)
53
- parallel (~> 1.10)
54
- parser (>= 2.7.1.5)
55
- rainbow (>= 2.2.2, < 4.0)
56
- regexp_parser (>= 1.8)
57
- rexml
58
- rubocop-ast (>= 0.6.0)
59
- ruby-progressbar (~> 1.7)
60
- unicode-display_width (>= 1.4.0, < 2.0)
61
- rubocop-ast (1.1.0)
62
- parser (>= 2.7.1.5)
63
- rubocop-performance (1.8.1)
64
- rubocop (>= 0.87.0)
65
- rubocop-ast (>= 0.4.0)
66
- ruby-progressbar (1.10.1)
67
- standard (0.8.1)
68
- rubocop (= 1.0.0)
69
- rubocop-performance (= 1.8.1)
70
- thor (1.0.1)
71
- thread_safe (0.3.6)
72
- tzinfo (1.2.7)
73
- thread_safe (~> 0.1)
74
- unicode-display_width (1.7.0)
75
- zeitwerk (2.4.0)
76
-
77
- PLATFORMS
78
- ruby
79
-
80
- DEPENDENCIES
81
- appraisal
82
- bundler (~> 2.0)
83
- rake
84
- rspec
85
- standard (~> 0.8.1)
86
- whi-cassie!
87
-
88
- BUNDLED WITH
89
- 2.1.4