records_rip 0.3.0 → 0.4.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: ba53c93ab8aa6e03bf60d6aae43ab7ef670e57e1ddef44cb9110ec5249daa367
4
- data.tar.gz: 90634bd3d59070c8787b3af20e381607a63077c02c8f34b4438612aa8c581186
3
+ metadata.gz: 8fecd3e94adbd056f3f663df95e1b82cb833c8286df376b0429693d57b05b3e0
4
+ data.tar.gz: 5640b2b8b6004984ecebfbaf2adbb6f8f25d38e094e1833cc3295748114c9c0c
5
5
  SHA512:
6
- metadata.gz: 5a9461267bfca7bd06026366a4684c7182d87c7403c52335d3ce13a648db146bbde6c724ec6deb7d85b3551e5ce2259de80e0edce667b7bef5392fc81fcb7917
7
- data.tar.gz: 62d179fc31026c9c8a6cf1be3b8f86bbb92b54366c889b74ceaf652640cce62d7387e4d3f330e93ca9d182be1a5dfecd5c7a0faeeeae10a68a0d0c02d4109820
6
+ metadata.gz: 5357c054043a34603c920f8a48aca5f051bbecd276510187cbb094497725511f6bf4c7a0fdb7ec51fe7e8051244068512c25d046242bdc06e3471b3d9272b077
7
+ data.tar.gz: e5bc1f6e9fea4caeb38a772592d965f5b8e28ea396902e73b470fce7b5765d6dbada047bede91e5d36e5a1d2f41f82adf6f47353dae29cf2dbcda1ebe18544f3
data/.travis.yml ADDED
@@ -0,0 +1,33 @@
1
+ language: ruby
2
+ cache: bundler
3
+
4
+ # For ruby compatibility, we test the highest and lowest minor versions only.
5
+ # For example, if our gemspec says `required_ruby_version = ">= 2.3.0"`, and
6
+ # ruby 2.5.0 has just been released, then we test 2.3 and 2.5, but not 2.4.
7
+ rvm:
8
+ - 2.3.8
9
+ - 2.4.5
10
+ - 2.5.3
11
+
12
+ env:
13
+ global:
14
+ - TRAVIS=true
15
+ matrix:
16
+ - DB=mysql
17
+ - DB=postgres
18
+ - DB=sqlite
19
+
20
+ # We want to use `sudo: false` because the container infrastructure is supposed
21
+ # to be faster, but Travis is having issues with containers lately ..
22
+ #
23
+ # > No output has been received in the last 10m0s
24
+ #
25
+ # .. and they recommend we use the VM infrastructure (`sudo: required`) in
26
+ # the meantime.
27
+ sudo: required
28
+
29
+ before_install:
30
+ - gem update bundler
31
+
32
+ addons:
33
+ postgresql: "9.4"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- records_rip (0.3.0)
4
+ records_rip (0.4.0)
5
5
  activesupport (>= 4.2, < 6.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # Records, R.I.P.
2
2
 
3
+ [![Build Status](https://travis-ci.org/ts-3156/records_rip.svg?branch=master)](https://travis-ci.org/ts-3156/records_rip)
4
+ [![Gem Version](https://badge.fury.io/rb/records_rip.svg)](https://badge.fury.io/rb/records_rip)
5
+
3
6
  This gem is a place to let deleted records rest in peace. :coffin:
4
7
 
5
- Soft deletes are evil. _Blest be y man y spares thes stones. And curst be he y moves my bones._
8
+ Soft deletes are evil. __Blest be y man y spares thes stones. And curst be he y moves my bones.__
6
9
 
7
10
  ## Getting Started
8
11
 
@@ -25,7 +28,25 @@ end
25
28
  You can perform WHERE queries for `tombs#epitaph` based on attributes:
26
29
 
27
30
  ```ruby
28
- User.tomb(name: 'Smith')
31
+ user = User.create(name: 'Smith')
32
+ user.destroy
33
+
34
+ User.tomb(name: 'Smith').to_a
35
+ # => [#<RecordsRip::Tomb id: 1, item_type: "User", item_id: 1, epitaph: "{\"id\"=>1, \"name\"=>\"Smith\"}">]
36
+ ```
37
+
38
+ #### Change serialization method
39
+
40
+ ```ruby
41
+ class User < ApplicationRecord
42
+ rest_in_place {|record| Hash[record.attributes.map {|k, v| [k, "Great #{v}"]}] }
43
+ end
44
+
45
+ user = User.create(name: 'Smith')
46
+ user.destroy
47
+
48
+ User.tomb(name: 'Great Smith').to_a
49
+ # => [#<RecordsRip::Tomb id: 1, item_type: "User", item_id: 1, epitaph: "{\"id\"=>1, \"name\"=>\"Great Smith\"}">]
29
50
  ```
30
51
 
31
52
  ## Contributing
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
- task :default => :spec
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task default: :test
@@ -5,13 +5,22 @@ module RecordsRip
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  class_methods do
8
- def rest_in_place
8
+ def rest_in_place(&block)
9
9
  model_class = self
10
10
 
11
+ serializer =
12
+ if block_given?
13
+ block
14
+ else
15
+ lambda do |record|
16
+ Hash[record.attributes.map {|k, v| [k, v]}]
17
+ end
18
+ end
19
+
11
20
  model_class.send(
12
21
  "before_destroy",
13
22
  lambda do |record|
14
- epitaph = Hash[record.attributes.map {|k, v| [k, v]}]
23
+ epitaph = serializer.call(record)
15
24
  ::RecordsRip::Tomb.create(item_id: record.id, item_type: record.class.name, epitaph: epitaph)
16
25
  end
17
26
  )
@@ -1,3 +1,3 @@
1
1
  module RecordsRip
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: records_rip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ts-3156
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-20 00:00:00.000000000 Z
11
+ date: 2018-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -108,6 +108,7 @@ extensions: []
108
108
  extra_rdoc_files: []
109
109
  files:
110
110
  - ".gitignore"
111
+ - ".travis.yml"
111
112
  - Gemfile
112
113
  - Gemfile.lock
113
114
  - LICENSE.txt