cassandro 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTk1NTEzMjZiNDVhZDgzZWJlZGJiYmY2MGUyYzA1ZTBjMDhmNDQyYg==
4
+ ZmNlNzM0YjQyYTIyYjAzN2NjMzA5ODJjNjI1N2Y1ODhiNjZhMDBjMQ==
5
5
  data.tar.gz: !binary |-
6
- MzE4MGMxZmViMWM4MTlmYmY3NmQwYWQ0OWQwYmZhYTE1N2JiZjNhNQ==
6
+ YjFhNWQyY2UyMzI1YmY0MzBkMjBhODE5NDk3ZjczNTYwYmM0YzU3MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTc0Yzc1MjhhODhlZTkxMmRiMThkZTNiMTdkNThlNDQwYTQ4N2U5ZDllYmQ0
10
- MjlhNDI3Mjc1NDg3MzQzNGI3ZDc0MWRmN2RjNjMyMThkNzNmYTM5ZjRjNDlm
11
- MGE1ZmJlZDNkNjk5ZDhlY2MxN2I4Y2I5OTJkZTZiNGExNDk2M2E=
9
+ Y2RlYTkzOWM1N2ZlNzQ1MTQ4NjA1YzI0MDNmYWQ3ZTViZTkxZWFjMmE0ZWRj
10
+ ZDY2MmQyM2U0NWMyMmE5OWZlZjZmNWY4ODg0N2ZmN2NmMzRlZWRiM2I5MzZk
11
+ NjFlZDM3YzE2NmZiNjViNGIwMjhhNzhhY2NmM2IxYWY5ZDRlZDI=
12
12
  data.tar.gz: !binary |-
13
- ODExNmZjNDJiNzkyZjNiNTdhZjk0MGU5ZTFiOWEwNjY3YzJhZGEwYjQyZmUw
14
- NWJiYjIwMzljYzFiM2VjYTQ5YWVjNWI3MGNmZmFiYzI5NjU1ZWQ5ZDVmMTM3
15
- NTUzMGIyN2UyYWUwN2U5ODA3Yjc1NTg0ODM1ZTUwNGM1NGU5NDI=
13
+ ODI4NjY1YmUwNWZlMTFhMTI5Yzc4ODg0Yzk1ZmYyYWQzNGU1ZTUzMGM0MmQ1
14
+ NDhmMzQyZGJiMjc1NjY0YTMwYzE2ZWRlYTBjZmViMTJlMDBjZGE4NThlMGVj
15
+ NTRjZGNlYzFmMmM2ZDk1ZWJjMTdmYWM3NmIwMmUyYzczNDI2YzE=
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Cassandro
1
+ # Cassandro [![Gem Version](https://badge.fury.io/rb/cassandro.svg)](http://badge.fury.io/rb/cassandro)
2
2
 
3
3
  Cassandro is a small Ruby ORM for Apache Cassandra 2.0 and CQL 3.0. Cassandro uses the new Datastax Ruby Driver (official driver).
4
4
 
data/cassandro.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "cassandro"
5
- s.version = "1.0.5"
5
+ s.version = "1.0.6"
6
6
  s.summary = "Ruby ORM for Apache Cassandra"
7
7
  s.license = "MIT"
8
8
  s.description = "Lightweight Apache Cassandra ORM for Ruby"
@@ -1,7 +1,18 @@
1
1
  module Cassandro
2
2
  module SoftDelete
3
+ module ClassMethods
4
+ def all(with_deleted = false)
5
+ results = super()
6
+
7
+ results.reject!{ |r| r.deleted } unless with_deleted
8
+
9
+ results
10
+ end
11
+ end
12
+
3
13
  def self.included(model)
4
14
  model.attribute :deleted, :boolean
15
+ model.extend ClassMethods
5
16
  end
6
17
 
7
18
  def destroy
@@ -6,6 +6,8 @@ Protest.describe "Cassandro Migration" do
6
6
  end
7
7
 
8
8
  test "enqueue migrations" do
9
+ Cassandro::Migration.clean
10
+
9
11
  class FirstMigration < Cassandro::Migration
10
12
  version 1
11
13
  end
@@ -1,6 +1,7 @@
1
1
  require_relative 'helper'
2
2
 
3
3
  Protest.describe "Cassandro Migrator" do
4
+ Cassandro.connect(hosts: ['127.0.0.1'], keyspace: 'cassandro_test')
4
5
  setup do
5
6
  #Cassandro::Migration.cleaassandra::Errors::InvalidError
6
7
  Cassandro.client.execute("DROP TABLE IF EXISTS users")
@@ -0,0 +1,44 @@
1
+ require_relative 'helper'
2
+ require_relative 'support/tables'
3
+
4
+ Protest.describe "Cassandro Model Soft Delete" do
5
+ setup do
6
+ Cassandro.connect(hosts: ['127.0.0.1'], keyspace: 'cassandro_test')
7
+
8
+ class Admin < Cassandro::Model
9
+ include Cassandro::SoftDelete
10
+
11
+ table :admins
12
+ attribute :nickname, :text
13
+
14
+ primary_key :nickname
15
+ end
16
+
17
+
18
+ Admin.all(true).each do |a|
19
+ Cassandro.execute("DELETE FROM admins WHERE nickname = '#{a.nickname}'")
20
+ end
21
+ end
22
+
23
+ test "all not include deleted" do
24
+
25
+ me = Admin.create(:nickname => "k4nd4lf")
26
+ other = Admin.create(:nickname => "Jim")
27
+
28
+ me.destroy
29
+
30
+ assert !Admin.all.include?(me)
31
+ end
32
+
33
+ test "all should include deleted if asked" do
34
+ me = Admin.create(:nickname => "k4nd4lf")
35
+ other = Admin.create(:nickname => "Jim")
36
+
37
+ me.destroy
38
+
39
+ assert !Admin.all.include?(me)
40
+
41
+ end
42
+ end
43
+
44
+
@@ -18,3 +18,13 @@ table = <<-TABLEDEF
18
18
  )
19
19
  TABLEDEF
20
20
  SESSION.execute(table)
21
+
22
+ SESSION.execute("DROP TABLE IF EXISTS admins")
23
+ table = <<-TABLEDEF
24
+ CREATE TABLE IF NOT EXISTS admins (
25
+ nickname VARCHAR,
26
+ deleted BOOLEAN,
27
+ PRIMARY KEY(nickname)
28
+ )
29
+ TABLEDEF
30
+ SESSION.execute(table)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassandro
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lautaro Orazi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-23 00:00:00.000000000 Z
12
+ date: 2015-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cassandra-driver
@@ -77,6 +77,7 @@ files:
77
77
  - test/cassandro_migration_test.rb
78
78
  - test/cassandro_migrator_test.rb
79
79
  - test/cassandro_model_test.rb
80
+ - test/cassandro_soft_delete_test.rb
80
81
  - test/cassandro_test.rb
81
82
  - test/helper.rb
82
83
  - test/support/migrations/animals_table.rb