whi-cassie 1.1.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +12 -0
- data/.github/workflows/continuous_integration.yml +64 -0
- data/.gitignore +7 -15
- data/.ruby-version +1 -0
- data/.standard.yml +11 -0
- data/Appraisals +17 -0
- data/Gemfile +10 -0
- data/HISTORY.md +12 -0
- data/README.md +14 -10
- data/Rakefile +13 -12
- data/VERSION +1 -1
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/activemodel_4.gemfile +14 -0
- data/gemfiles/activemodel_5.gemfile +14 -0
- data/gemfiles/activemodel_6.gemfile +14 -0
- data/gemfiles/activemodel_7.gemfile +14 -0
- data/lib/cassie/config.rb +8 -7
- data/lib/cassie/model.rb +143 -111
- data/lib/cassie/railtie.rb +7 -5
- data/lib/cassie/schema.rb +35 -28
- data/lib/cassie/subscribers.rb +10 -12
- data/lib/cassie/testing.rb +22 -20
- data/lib/cassie.rb +55 -57
- data/lib/whi-cassie.rb +2 -0
- data/spec/cassie/config_spec.rb +20 -22
- data/spec/cassie/model_spec.rb +333 -311
- data/spec/cassie/subscribers_spec.rb +19 -21
- data/spec/cassie_spec.rb +86 -87
- data/spec/models/thing.rb +11 -11
- data/spec/models/type_tester.rb +7 -7
- data/spec/spec_helper.rb +32 -13
- data/whi-cassie.gemspec +17 -19
- metadata +23 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 38924e7460050a72c231a359a4a07e1695349b55d24868ae8332a0ecbcf61356
|
4
|
+
data.tar.gz: 69f5b3396cb45c8f3247ba377d456173ac114220b2247163bc74060e9cff921a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46242596cf88a2d0600be23bb25a5138c7090acc952ccdbab3344d36abb1cd94ef4aef85bae071f60275297f10571377704a7de7348875cd0984439c7a3aecfd
|
7
|
+
data.tar.gz: d6e68b1ffd9a28cb27984e01bbce135502b4107d50be350d275dd745375fb5a2b90efa5384a4578c250654674b0ae7512bfe529fe3dc21f52c59b37b87e390e3
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Dependabot update strategy
|
2
|
+
version: 2
|
3
|
+
updates:
|
4
|
+
- package-ecosystem: bundler
|
5
|
+
directory: "/"
|
6
|
+
schedule:
|
7
|
+
interval: daily
|
8
|
+
allow:
|
9
|
+
# Automatically keep all runtime dependencies updated
|
10
|
+
- dependency-name: "*"
|
11
|
+
dependency-type: "production"
|
12
|
+
versioning-strategy: lockfile-only
|
@@ -0,0 +1,64 @@
|
|
1
|
+
name: Continuous Integration
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- master
|
6
|
+
- actions-*
|
7
|
+
tags:
|
8
|
+
- v*
|
9
|
+
pull_request:
|
10
|
+
env:
|
11
|
+
BUNDLE_CLEAN: "true"
|
12
|
+
BUNDLE_PATH: vendor/bundle
|
13
|
+
BUNDLE_JOBS: 3
|
14
|
+
BUNDLE_RETRY: 3
|
15
|
+
jobs:
|
16
|
+
specs:
|
17
|
+
name: ${{ matrix.job }} ruby-${{ matrix.ruby }} ${{ matrix.activemodel && format('activemodel-{0}', matrix.activemodel) }} cassandra-${{ matrix.cassandra_version }}
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
services:
|
20
|
+
cassandra:
|
21
|
+
image: cassandra:${{ matrix.cassandra_version }}
|
22
|
+
ports:
|
23
|
+
- 9042:9042
|
24
|
+
strategy:
|
25
|
+
fail-fast: false
|
26
|
+
matrix:
|
27
|
+
ruby: ["3.0"]
|
28
|
+
activemodel: ["original"]
|
29
|
+
job: [rspec]
|
30
|
+
cassandra_version: ["latest"]
|
31
|
+
include:
|
32
|
+
- ruby: "2.6"
|
33
|
+
activemodel: "5"
|
34
|
+
job: rspec
|
35
|
+
cassandra_version: "3"
|
36
|
+
- ruby: "2.4"
|
37
|
+
activemodel: "4"
|
38
|
+
job: rspec
|
39
|
+
cassandra_version: "2"
|
40
|
+
- ruby: "2.7"
|
41
|
+
activemodel: "6"
|
42
|
+
- ruby: "3.0"
|
43
|
+
job: standardrb
|
44
|
+
steps:
|
45
|
+
- name: checkout
|
46
|
+
uses: actions/checkout@v2
|
47
|
+
- name: set up Ruby
|
48
|
+
uses: ruby/setup-ruby@v1
|
49
|
+
with:
|
50
|
+
ruby-version: ${{ matrix.ruby }}
|
51
|
+
- name: inject activemodel ${{ matrix.activemodel }}
|
52
|
+
if: matrix.activemodel != 'original' && matrix.activemodel != null
|
53
|
+
run: | # inject a specific version of activemodel into the Gemfile
|
54
|
+
bundle update
|
55
|
+
bundle exec appraisal generate
|
56
|
+
bundle config set gemfile "gemfiles/activemodel_${{ matrix.activemodel }}.gemfile"
|
57
|
+
- name: install dependencies
|
58
|
+
run: bundle install
|
59
|
+
- name: specs
|
60
|
+
if: matrix.job == 'rspec'
|
61
|
+
run: bundle exec rake spec
|
62
|
+
- name: standardrb
|
63
|
+
if: matrix.job == 'standardrb'
|
64
|
+
run: bundle exec rake standard
|
data/.gitignore
CHANGED
@@ -1,17 +1,9 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
1
|
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
2
|
tmp
|
3
|
+
rdoc
|
4
|
+
*.rbc
|
5
|
+
.tm_properties
|
6
|
+
.DS_Store
|
7
|
+
.env
|
8
|
+
Gemfile.lock
|
9
|
+
gemfiles/*.lock
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.2
|
data/.standard.yml
ADDED
data/Appraisals
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
appraise "activemodel-7" do
|
4
|
+
gem "activemodel", "~> 7.0"
|
5
|
+
end
|
6
|
+
|
7
|
+
appraise "activemodel-6" do
|
8
|
+
gem "activemodel", "~> 6.0"
|
9
|
+
end
|
10
|
+
|
11
|
+
appraise "activemodel-5" do
|
12
|
+
gem "activemodel", "~> 5.0"
|
13
|
+
end
|
14
|
+
|
15
|
+
appraise "activemodel-4" do
|
16
|
+
gem "activemodel", "~> 4.0"
|
17
|
+
end
|
data/Gemfile
ADDED
data/HISTORY.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 1.3.0
|
2
|
+
|
3
|
+
* Add update, update!, primary_key, and reload methods to models.
|
4
|
+
|
5
|
+
## 1.2.0
|
6
|
+
|
7
|
+
* Update schema queries to support Cassandra 3.x+
|
8
|
+
* Require Ruby 2.4 or greater
|
9
|
+
|
10
|
+
## 1.1.1
|
11
|
+
* Update dependencies to support Rails 5.
|
12
|
+
|
1
13
|
## 1.1.0
|
2
14
|
|
3
15
|
* Bump supported version of cassandra-driver to 3.x.
|
data/README.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
![Continuous Integration](https://github.com/weheartit/cassie/workflows/Continuous%20Integration/badge.svg)
|
2
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/129ede20094ea298c687/maintainability)](https://codeclimate.com/github/weheartit/cassie/maintainability)
|
3
|
+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
|
4
|
+
|
1
5
|
# Cassie
|
2
6
|
|
3
7
|
The short and sweet Cassandra object mapper from [We Heart It](http://weheartit.com/)
|
@@ -8,34 +12,34 @@ The short and sweet Cassandra object mapper from [We Heart It](http://weheartit.
|
|
8
12
|
class Thing
|
9
13
|
# Your model must include this
|
10
14
|
include Cassie::Model
|
11
|
-
|
15
|
+
|
12
16
|
# Set the table name where the data lives.
|
13
17
|
self.table_name = "things"
|
14
|
-
|
18
|
+
|
15
19
|
# Set the keyspace where the table lives. Keyspaces can be defined abstractly and mapped
|
16
20
|
# and mapped in a configuration file. This can allow you to have different keyspace names
|
17
21
|
# between different environments and still use the same code.
|
18
22
|
self.keyspace = "default"
|
19
|
-
|
23
|
+
|
20
24
|
# You must defind the primary key. They columns must be listed in the order that they apper
|
21
25
|
# in the Cassandra CQL PRIMARY KEY clause defining the table.
|
22
26
|
self.primary_key = [:owner, :id]
|
23
|
-
|
27
|
+
|
24
28
|
# All columns are explicitly defined with their name and data type and an optional
|
25
29
|
# alias name.
|
26
30
|
column :owner, :int
|
27
31
|
column :id, :int, :as => :identifier
|
28
32
|
column :val, :varchar, :as => :value
|
29
|
-
|
33
|
+
|
30
34
|
# The ordering keys should also be defined along with how they are ordered.
|
31
35
|
ordering_key :id, :desc
|
32
|
-
|
36
|
+
|
33
37
|
# You can use all the standard ActiveModel validations.
|
34
38
|
validates_presence_of :owner, :id
|
35
|
-
|
39
|
+
|
36
40
|
# You also get before and after callbacks for create, update, save, and destroy.
|
37
41
|
before_save :some_callback_method
|
38
|
-
|
42
|
+
|
39
43
|
...
|
40
44
|
end
|
41
45
|
|
@@ -176,13 +180,13 @@ To use it with rspec you should add this code to your spec_helper.rb file:
|
|
176
180
|
end
|
177
181
|
Cassie::Testing.prepare!
|
178
182
|
end
|
179
|
-
|
183
|
+
|
180
184
|
config.after(:suite) do
|
181
185
|
Cassie::Schema.all do |keyspace|
|
182
186
|
Cassie::Schema.drop!(keyspace)
|
183
187
|
end
|
184
188
|
end
|
185
|
-
|
189
|
+
|
186
190
|
config.around(:each) do |example|
|
187
191
|
Cassie::Testing.cleanup! do
|
188
192
|
example.run
|
data/Rakefile
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "standard/rake"
|
2
4
|
|
3
|
-
|
4
|
-
task :default => :test
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
6
|
|
6
|
-
|
7
|
-
task :tests => :test
|
7
|
+
task default: :spec
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
desc "run the specs using appraisal"
|
10
|
+
task :appraisals do
|
11
|
+
exec "bundle exec appraisal rake spec"
|
12
|
+
end
|
13
|
+
|
14
|
+
namespace :appraisals do
|
15
|
+
desc "install all the appraisal gemspecs"
|
16
|
+
task :install do
|
17
|
+
exec "bundle exec appraisal install"
|
17
18
|
end
|
18
19
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/lib/cassie/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Simple configuration for connecting to Cassandra.
|
2
4
|
#
|
3
5
|
# :cluster should be a Hash of the options to initialize the Cassandra cluster.
|
@@ -19,7 +21,7 @@
|
|
19
21
|
class Cassie::Config
|
20
22
|
attr_reader :cluster
|
21
23
|
attr_accessor :max_prepared_statements, :schema_directory, :default_keyspace
|
22
|
-
|
24
|
+
|
23
25
|
def initialize(options = {})
|
24
26
|
options = options.symbolize_keys
|
25
27
|
@cluster = (options[:cluster] || {}).symbolize_keys
|
@@ -28,27 +30,27 @@ class Cassie::Config
|
|
28
30
|
@schema_directory = options[:schema_directory]
|
29
31
|
@default_keyspace = options[:default_keyspace]
|
30
32
|
end
|
31
|
-
|
33
|
+
|
32
34
|
# Get the actual keyspace mapped to the abstract name.
|
33
35
|
def keyspace(name)
|
34
36
|
@keyspaces[name.to_s] || name.to_s
|
35
37
|
end
|
36
|
-
|
38
|
+
|
37
39
|
# Get the list of keyspaces defined for the cluster.
|
38
40
|
def keyspaces
|
39
41
|
@keyspaces.values
|
40
42
|
end
|
41
|
-
|
43
|
+
|
42
44
|
# Get the list of abstract keyspace names.
|
43
45
|
def keyspace_names
|
44
46
|
@keyspaces.keys
|
45
47
|
end
|
46
|
-
|
48
|
+
|
47
49
|
# Add a mapping of a name to a keyspace.
|
48
50
|
def add_keyspace(name, value)
|
49
51
|
@keyspaces[name.to_s] = value
|
50
52
|
end
|
51
|
-
|
53
|
+
|
52
54
|
# Return the cluster options without passwords or tokens. Used for logging.
|
53
55
|
def sanitized_cluster
|
54
56
|
options = cluster.dup
|
@@ -59,5 +61,4 @@ class Cassie::Config
|
|
59
61
|
options[:logger] = options[:logger].class.name if options.include?(:logger)
|
60
62
|
options
|
61
63
|
end
|
62
|
-
|
63
64
|
end
|