paper_trail_scrapbook 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +52 -0
- data/.rubocop.yml +2 -1
- data/.ruby-version +1 -0
- data/Changelog.md +2 -2
- data/Gemfile +2 -0
- data/Gemfile.lock +5 -2
- data/Rakefile +2 -0
- data/lib/paper_trail_scrapbook.rb +2 -4
- data/lib/paper_trail_scrapbook/changes.rb +21 -21
- data/lib/paper_trail_scrapbook/chapter.rb +2 -0
- data/lib/paper_trail_scrapbook/config.rb +4 -2
- data/lib/paper_trail_scrapbook/journal_entry.rb +2 -0
- data/lib/paper_trail_scrapbook/life_history.rb +2 -0
- data/lib/paper_trail_scrapbook/secondary_chapter.rb +2 -0
- data/lib/paper_trail_scrapbook/user_journal.rb +2 -0
- data/lib/paper_trail_scrapbook/version.rb +3 -1
- data/lib/paper_trail_scrapbook/version_helpers.rb +2 -0
- data/paper_trail_scrapbook.gemspec +5 -2
- data/spec/dummy_app/Rakefile +3 -1
- data/spec/dummy_app/app/models/animal.rb +2 -0
- data/spec/dummy_app/app/models/article.rb +2 -0
- data/spec/dummy_app/app/models/authorship.rb +2 -0
- data/spec/dummy_app/app/models/bar_habtm.rb +2 -0
- data/spec/dummy_app/app/models/book.rb +2 -0
- data/spec/dummy_app/app/models/boolit.rb +2 -0
- data/spec/dummy_app/app/models/callback_modifier.rb +2 -0
- data/spec/dummy_app/app/models/car.rb +2 -0
- data/spec/dummy_app/app/models/cat.rb +2 -0
- data/spec/dummy_app/app/models/chapter.rb +2 -0
- data/spec/dummy_app/app/models/citation.rb +2 -0
- data/spec/dummy_app/app/models/custom_primary_key_record.rb +2 -0
- data/spec/dummy_app/app/models/customer.rb +2 -0
- data/spec/dummy_app/app/models/document.rb +2 -0
- data/spec/dummy_app/app/models/dog.rb +2 -0
- data/spec/dummy_app/app/models/editor.rb +2 -0
- data/spec/dummy_app/app/models/editorship.rb +2 -0
- data/spec/dummy_app/app/models/elephant.rb +2 -0
- data/spec/dummy_app/app/models/fluxor.rb +2 -0
- data/spec/dummy_app/app/models/foo_habtm.rb +2 -0
- data/spec/dummy_app/app/models/foo_widget.rb +2 -0
- data/spec/dummy_app/app/models/fruit.rb +2 -0
- data/spec/dummy_app/app/models/gadget.rb +2 -0
- data/spec/dummy_app/app/models/kitchen/banana.rb +2 -0
- data/spec/dummy_app/app/models/legacy_widget.rb +2 -0
- data/spec/dummy_app/app/models/line_item.rb +2 -0
- data/spec/dummy_app/app/models/not_on_update.rb +2 -0
- data/spec/dummy_app/app/models/on/create.rb +2 -0
- data/spec/dummy_app/app/models/on/destroy.rb +2 -0
- data/spec/dummy_app/app/models/on/empty_array.rb +2 -0
- data/spec/dummy_app/app/models/on/update.rb +2 -0
- data/spec/dummy_app/app/models/order.rb +2 -0
- data/spec/dummy_app/app/models/paragraph.rb +2 -0
- data/spec/dummy_app/app/models/person.rb +2 -0
- data/spec/dummy_app/app/models/post.rb +2 -0
- data/spec/dummy_app/app/models/post_with_status.rb +2 -0
- data/spec/dummy_app/app/models/quotation.rb +2 -0
- data/spec/dummy_app/app/models/section.rb +2 -0
- data/spec/dummy_app/app/models/skipper.rb +2 -0
- data/spec/dummy_app/app/models/song.rb +2 -0
- data/spec/dummy_app/app/models/thing.rb +2 -0
- data/spec/dummy_app/app/models/translation.rb +2 -0
- data/spec/dummy_app/app/models/truck.rb +2 -0
- data/spec/dummy_app/app/models/vehicle.rb +2 -0
- data/spec/dummy_app/app/models/whatchamajigger.rb +2 -0
- data/spec/dummy_app/app/models/widget.rb +3 -1
- data/spec/dummy_app/app/models/wotsit.rb +2 -0
- data/spec/dummy_app/app/versions/custom_primary_key_record_version.rb +2 -0
- data/spec/dummy_app/app/versions/joined_version.rb +2 -0
- data/spec/dummy_app/app/versions/json_version.rb +2 -0
- data/spec/dummy_app/app/versions/kitchen/banana_version.rb +2 -0
- data/spec/dummy_app/app/versions/post_version.rb +2 -0
- data/spec/dummy_app/config.ru +2 -0
- data/spec/dummy_app/config/application.rb +3 -1
- data/spec/dummy_app/config/boot.rb +4 -2
- data/spec/dummy_app/config/environment.rb +3 -1
- data/spec/dummy_app/config/environments/development.rb +2 -0
- data/spec/dummy_app/config/environments/production.rb +2 -0
- data/spec/dummy_app/config/environments/test.rb +2 -0
- data/spec/dummy_app/config/initializers/backtrace_silencers.rb +2 -0
- data/spec/dummy_app/config/initializers/inflections.rb +2 -0
- data/spec/dummy_app/config/initializers/mime_types.rb +2 -0
- data/spec/dummy_app/config/initializers/paper_trail.rb +2 -0
- data/spec/dummy_app/config/initializers/secret_token.rb +2 -0
- data/spec/dummy_app/config/initializers/session_store.rb +2 -0
- data/spec/dummy_app/config/routes.rb +2 -0
- data/spec/paper_trail_scrapbook/changes_spec.rb +2 -0
- data/spec/paper_trail_scrapbook/chapter_spec.rb +2 -0
- data/spec/paper_trail_scrapbook/config_spec.rb +2 -0
- data/spec/paper_trail_scrapbook/life_history_spec.rb +8 -6
- data/spec/paper_trail_scrapbook/secondary_chapter_spec.rb +2 -0
- data/spec/paper_trail_scrapbook/user_journal_spec.rb +47 -43
- data/spec/paper_trail_scrapbook/version_helpers_spec.rb +9 -7
- data/spec/paper_trail_scrapbook/version_spec.rb +2 -0
- data/spec/paper_trail_scrapbook_spec.rb +2 -0
- data/spec/spec_helper.rb +3 -1
- metadata +20 -5
- data/circle.yml +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: edde51db159600817dbb9e150b277d617415077c
|
4
|
+
data.tar.gz: ba553dc8f127055130d34e36a06c9be0204033ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 651b77abc9dd8aeb3113063243b8c03814411a79fbdd0d0c4cb2e5dfe96487ca0e20474d9a52a4a3fd3cb74cc8ba61c444c6aa71b37b6b0d973b9fac46b27e06
|
7
|
+
data.tar.gz: 99d45d37adc8953f3938a35de967d6511e969e71913e1a359795a6ab630ddea3d83db49276a31f167d3a8f36195a36e13a1152c2273c31b4f0d85631063928ac
|
@@ -0,0 +1,52 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
docker:
|
3
|
+
- image: circleci/ruby:2.5.0-node-browsers
|
4
|
+
- image: circleci/postgres:9.5-alpine
|
5
|
+
environment:
|
6
|
+
POSTGRES_USER: circleci
|
7
|
+
POSTGRES_DB: pts_db
|
8
|
+
|
9
|
+
version: 2
|
10
|
+
jobs:
|
11
|
+
build:
|
12
|
+
<<: *defaults
|
13
|
+
steps:
|
14
|
+
- checkout
|
15
|
+
- restore_cache:
|
16
|
+
keys:
|
17
|
+
- paper_trail_scrapbook-{{ checksum "Gemfile.lock" }}
|
18
|
+
- paper_trail_scrapbook-
|
19
|
+
- run:
|
20
|
+
name: Bundle Install
|
21
|
+
command: bundle check || bundle install
|
22
|
+
- save_cache:
|
23
|
+
key: paper_trail_scrapbook-{{ checksum "Gemfile.lock" }}
|
24
|
+
paths:
|
25
|
+
- vendor/bundle
|
26
|
+
- run:
|
27
|
+
name: Database setup
|
28
|
+
command: rake prepare
|
29
|
+
- run:
|
30
|
+
name: Setup CodeClimate test-reporter
|
31
|
+
command: |
|
32
|
+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > cc-test-reporter
|
33
|
+
chmod +x cc-test-reporter
|
34
|
+
- type: shell
|
35
|
+
command: |
|
36
|
+
./cc-test-reporter before-build
|
37
|
+
bundle exec rspec --profile 10 \
|
38
|
+
--format RspecJunitFormatter \
|
39
|
+
--out test_results/rspec.xml \
|
40
|
+
--format progress \
|
41
|
+
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
42
|
+
./cc-test-reporter format-coverage -t simplecov $CIRCLE_ARTIFACTS/coverage/.resultset.json
|
43
|
+
./cc-test-reporter upload-coverage
|
44
|
+
- store_test_results:
|
45
|
+
path: test_results
|
46
|
+
|
47
|
+
workflows:
|
48
|
+
version: 2
|
49
|
+
commit:
|
50
|
+
jobs:
|
51
|
+
- build
|
52
|
+
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
AllCops:
|
2
2
|
DisabledByDefault: false
|
3
|
-
TargetRubyVersion: 2.
|
3
|
+
TargetRubyVersion: 2.3
|
4
4
|
TargetRailsVersion: 4.0
|
5
5
|
DisplayCopNames: true
|
6
6
|
Exclude:
|
@@ -22,6 +22,7 @@ Metrics/LineLength:
|
|
22
22
|
Metrics/BlockLength:
|
23
23
|
Exclude:
|
24
24
|
- 'spec/**/*'
|
25
|
+
- 'paper_trail_scrapbook.gemspec'
|
25
26
|
|
26
27
|
Metrics/ModuleLength:
|
27
28
|
Exclude:
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.7
|
data/Changelog.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
paper_trail_scrapbook (0.1.
|
4
|
+
paper_trail_scrapbook (0.1.10)
|
5
5
|
activerecord (>= 4.0, < 5.2)
|
6
6
|
adamantium
|
7
7
|
concord
|
@@ -147,6 +147,8 @@ GEM
|
|
147
147
|
rspec-mocks (~> 3.6.0)
|
148
148
|
rspec-support (~> 3.6.0)
|
149
149
|
rspec-support (3.6.0)
|
150
|
+
rspec_junit_formatter (0.4.1)
|
151
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
150
152
|
rubocop (0.52.1)
|
151
153
|
parallel (~> 1.10)
|
152
154
|
parser (>= 2.4.0.2, < 3.0)
|
@@ -192,10 +194,11 @@ DEPENDENCIES
|
|
192
194
|
railties (>= 4.0, < 5.2)
|
193
195
|
rake (~> 10.4.2)
|
194
196
|
rspec-rails (~> 3.6)
|
197
|
+
rspec_junit_formatter
|
195
198
|
rubocop
|
196
199
|
rubocop-rspec
|
197
200
|
simplecov
|
198
201
|
timecop (~> 0.8.0)
|
199
202
|
|
200
203
|
BUNDLED WITH
|
201
|
-
1.16.
|
204
|
+
1.16.2
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module PaperTrailScrapbook
|
2
4
|
# Class Changes provides detailed attribute by attribute analysis
|
3
5
|
#
|
@@ -13,7 +15,7 @@ module PaperTrailScrapbook
|
|
13
15
|
changes
|
14
16
|
end
|
15
17
|
|
16
|
-
BULLET = ' •'
|
18
|
+
BULLET = ' •'
|
17
19
|
|
18
20
|
# Attribute change analysis
|
19
21
|
#
|
@@ -32,22 +34,22 @@ module PaperTrailScrapbook
|
|
32
34
|
|
33
35
|
private
|
34
36
|
|
35
|
-
def digest(
|
36
|
-
old, new =
|
37
|
+
def digest(key, values)
|
38
|
+
old, new = values
|
37
39
|
return if old.nil? && (new.nil? || new.eql?(''))
|
38
40
|
|
39
|
-
"#{BULLET} #{
|
41
|
+
"#{BULLET} #{key.tr('_', ' ')}: #{detailed_analysis(key, new, old)}"
|
40
42
|
end
|
41
43
|
|
42
|
-
def detailed_analysis(
|
44
|
+
def detailed_analysis(key, new, old)
|
43
45
|
if creating?
|
44
|
-
find_value(
|
46
|
+
find_value(key, new).to_s
|
45
47
|
elsif old.nil?
|
46
|
-
"#{find_value(
|
48
|
+
"#{find_value(key, new)} added"
|
47
49
|
elsif new.nil?
|
48
|
-
"#{find_value(
|
50
|
+
"#{find_value(key, old)} was *removed*"
|
49
51
|
else
|
50
|
-
"#{find_value(
|
52
|
+
"#{find_value(key, old)} -> #{find_value(key, new)}"
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
@@ -56,12 +58,12 @@ module PaperTrailScrapbook
|
|
56
58
|
end
|
57
59
|
|
58
60
|
def find_value(key, value)
|
59
|
-
return value.to_s unless
|
61
|
+
return value.to_s unless build_associations.key?(key)
|
60
62
|
|
61
63
|
return '*empty*' unless value
|
62
64
|
|
63
65
|
begin
|
64
|
-
|
66
|
+
build_associations[key].find(value).to_s.to_s + "[#{value}]"
|
65
67
|
rescue StandardError
|
66
68
|
"*not found*[#{value}]"
|
67
69
|
end
|
@@ -81,7 +83,7 @@ module PaperTrailScrapbook
|
|
81
83
|
end
|
82
84
|
|
83
85
|
def build_associations
|
84
|
-
@
|
86
|
+
@build_associations ||=
|
85
87
|
Hash[
|
86
88
|
klass
|
87
89
|
.reflect_on_all_associations
|
@@ -95,15 +97,13 @@ module PaperTrailScrapbook
|
|
95
97
|
end
|
96
98
|
|
97
99
|
def changes
|
98
|
-
@
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
100
|
+
@changes ||= if object_changes
|
101
|
+
YAML
|
102
|
+
.load(object_changes)
|
103
|
+
.except(*PaperTrailScrapbook.config.scrub_columns)
|
104
|
+
else
|
105
|
+
{}
|
106
|
+
end
|
105
107
|
end
|
106
|
-
|
107
|
-
attr_reader :assoc, :chs
|
108
108
|
end
|
109
109
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'singleton'
|
2
4
|
|
3
5
|
module PaperTrailScrapbook
|
@@ -5,13 +7,13 @@ module PaperTrailScrapbook
|
|
5
7
|
class Config
|
6
8
|
include Singleton
|
7
9
|
|
8
|
-
DEFAULT_TIME_FORMAT = '%A, %d %b %Y at %l:%M %p'
|
10
|
+
DEFAULT_TIME_FORMAT = '%A, %d %b %Y at %l:%M %p'
|
9
11
|
DEFAULT_EVENTS = { 'create' => 'created',
|
10
12
|
'update' => 'updated',
|
11
13
|
'destroy' => 'destroyed' }.freeze
|
12
14
|
|
13
15
|
SCRUB_COLUMNS = %w[updated_at created_at id].freeze
|
14
|
-
UNKNOWN_WHODUNNIT = '*the app*'
|
16
|
+
UNKNOWN_WHODUNNIT = '*the app*'
|
15
17
|
|
16
18
|
attr_accessor :whodunnit_class,
|
17
19
|
:time_format,
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('lib/paper_trail_scrapbook/version', __dir__)
|
2
4
|
|
3
5
|
Gem::Specification.new do |gem|
|
4
6
|
gem.name = 'paper_trail_scrapbook'
|
@@ -13,7 +15,7 @@ Gem::Specification.new do |gem|
|
|
13
15
|
gem.license = 'MIT'
|
14
16
|
|
15
17
|
gem.required_rubygems_version = '>= 1.3.6'
|
16
|
-
gem.required_ruby_version = '>= 2.
|
18
|
+
gem.required_ruby_version = '>= 2.3.0'
|
17
19
|
|
18
20
|
# Rails does not follow semver, makes breaking changes in minor versions.
|
19
21
|
gem.add_dependency 'activerecord', ['>= 4.0', '< 5.2']
|
@@ -34,6 +36,7 @@ Gem::Specification.new do |gem|
|
|
34
36
|
gem.add_development_dependency 'mutant-rspec'
|
35
37
|
gem.add_development_dependency 'pg', '= 0.18.4'
|
36
38
|
gem.add_development_dependency 'rspec-rails', '~> 3.6'
|
39
|
+
gem.add_development_dependency 'rspec_junit_formatter'
|
37
40
|
gem.add_development_dependency 'rubocop'
|
38
41
|
gem.add_development_dependency 'rubocop-rspec'
|
39
42
|
gem.add_development_dependency 'simplecov'
|
data/spec/dummy_app/Rakefile
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
4
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
5
|
|
4
|
-
require File.expand_path('
|
6
|
+
require File.expand_path('config/application', __dir__)
|
5
7
|
require 'rake'
|
6
8
|
|
7
9
|
Dummy::Application.load_tasks
|