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.
Files changed (98) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +52 -0
  3. data/.rubocop.yml +2 -1
  4. data/.ruby-version +1 -0
  5. data/Changelog.md +2 -2
  6. data/Gemfile +2 -0
  7. data/Gemfile.lock +5 -2
  8. data/Rakefile +2 -0
  9. data/lib/paper_trail_scrapbook.rb +2 -4
  10. data/lib/paper_trail_scrapbook/changes.rb +21 -21
  11. data/lib/paper_trail_scrapbook/chapter.rb +2 -0
  12. data/lib/paper_trail_scrapbook/config.rb +4 -2
  13. data/lib/paper_trail_scrapbook/journal_entry.rb +2 -0
  14. data/lib/paper_trail_scrapbook/life_history.rb +2 -0
  15. data/lib/paper_trail_scrapbook/secondary_chapter.rb +2 -0
  16. data/lib/paper_trail_scrapbook/user_journal.rb +2 -0
  17. data/lib/paper_trail_scrapbook/version.rb +3 -1
  18. data/lib/paper_trail_scrapbook/version_helpers.rb +2 -0
  19. data/paper_trail_scrapbook.gemspec +5 -2
  20. data/spec/dummy_app/Rakefile +3 -1
  21. data/spec/dummy_app/app/models/animal.rb +2 -0
  22. data/spec/dummy_app/app/models/article.rb +2 -0
  23. data/spec/dummy_app/app/models/authorship.rb +2 -0
  24. data/spec/dummy_app/app/models/bar_habtm.rb +2 -0
  25. data/spec/dummy_app/app/models/book.rb +2 -0
  26. data/spec/dummy_app/app/models/boolit.rb +2 -0
  27. data/spec/dummy_app/app/models/callback_modifier.rb +2 -0
  28. data/spec/dummy_app/app/models/car.rb +2 -0
  29. data/spec/dummy_app/app/models/cat.rb +2 -0
  30. data/spec/dummy_app/app/models/chapter.rb +2 -0
  31. data/spec/dummy_app/app/models/citation.rb +2 -0
  32. data/spec/dummy_app/app/models/custom_primary_key_record.rb +2 -0
  33. data/spec/dummy_app/app/models/customer.rb +2 -0
  34. data/spec/dummy_app/app/models/document.rb +2 -0
  35. data/spec/dummy_app/app/models/dog.rb +2 -0
  36. data/spec/dummy_app/app/models/editor.rb +2 -0
  37. data/spec/dummy_app/app/models/editorship.rb +2 -0
  38. data/spec/dummy_app/app/models/elephant.rb +2 -0
  39. data/spec/dummy_app/app/models/fluxor.rb +2 -0
  40. data/spec/dummy_app/app/models/foo_habtm.rb +2 -0
  41. data/spec/dummy_app/app/models/foo_widget.rb +2 -0
  42. data/spec/dummy_app/app/models/fruit.rb +2 -0
  43. data/spec/dummy_app/app/models/gadget.rb +2 -0
  44. data/spec/dummy_app/app/models/kitchen/banana.rb +2 -0
  45. data/spec/dummy_app/app/models/legacy_widget.rb +2 -0
  46. data/spec/dummy_app/app/models/line_item.rb +2 -0
  47. data/spec/dummy_app/app/models/not_on_update.rb +2 -0
  48. data/spec/dummy_app/app/models/on/create.rb +2 -0
  49. data/spec/dummy_app/app/models/on/destroy.rb +2 -0
  50. data/spec/dummy_app/app/models/on/empty_array.rb +2 -0
  51. data/spec/dummy_app/app/models/on/update.rb +2 -0
  52. data/spec/dummy_app/app/models/order.rb +2 -0
  53. data/spec/dummy_app/app/models/paragraph.rb +2 -0
  54. data/spec/dummy_app/app/models/person.rb +2 -0
  55. data/spec/dummy_app/app/models/post.rb +2 -0
  56. data/spec/dummy_app/app/models/post_with_status.rb +2 -0
  57. data/spec/dummy_app/app/models/quotation.rb +2 -0
  58. data/spec/dummy_app/app/models/section.rb +2 -0
  59. data/spec/dummy_app/app/models/skipper.rb +2 -0
  60. data/spec/dummy_app/app/models/song.rb +2 -0
  61. data/spec/dummy_app/app/models/thing.rb +2 -0
  62. data/spec/dummy_app/app/models/translation.rb +2 -0
  63. data/spec/dummy_app/app/models/truck.rb +2 -0
  64. data/spec/dummy_app/app/models/vehicle.rb +2 -0
  65. data/spec/dummy_app/app/models/whatchamajigger.rb +2 -0
  66. data/spec/dummy_app/app/models/widget.rb +3 -1
  67. data/spec/dummy_app/app/models/wotsit.rb +2 -0
  68. data/spec/dummy_app/app/versions/custom_primary_key_record_version.rb +2 -0
  69. data/spec/dummy_app/app/versions/joined_version.rb +2 -0
  70. data/spec/dummy_app/app/versions/json_version.rb +2 -0
  71. data/spec/dummy_app/app/versions/kitchen/banana_version.rb +2 -0
  72. data/spec/dummy_app/app/versions/post_version.rb +2 -0
  73. data/spec/dummy_app/config.ru +2 -0
  74. data/spec/dummy_app/config/application.rb +3 -1
  75. data/spec/dummy_app/config/boot.rb +4 -2
  76. data/spec/dummy_app/config/environment.rb +3 -1
  77. data/spec/dummy_app/config/environments/development.rb +2 -0
  78. data/spec/dummy_app/config/environments/production.rb +2 -0
  79. data/spec/dummy_app/config/environments/test.rb +2 -0
  80. data/spec/dummy_app/config/initializers/backtrace_silencers.rb +2 -0
  81. data/spec/dummy_app/config/initializers/inflections.rb +2 -0
  82. data/spec/dummy_app/config/initializers/mime_types.rb +2 -0
  83. data/spec/dummy_app/config/initializers/paper_trail.rb +2 -0
  84. data/spec/dummy_app/config/initializers/secret_token.rb +2 -0
  85. data/spec/dummy_app/config/initializers/session_store.rb +2 -0
  86. data/spec/dummy_app/config/routes.rb +2 -0
  87. data/spec/paper_trail_scrapbook/changes_spec.rb +2 -0
  88. data/spec/paper_trail_scrapbook/chapter_spec.rb +2 -0
  89. data/spec/paper_trail_scrapbook/config_spec.rb +2 -0
  90. data/spec/paper_trail_scrapbook/life_history_spec.rb +8 -6
  91. data/spec/paper_trail_scrapbook/secondary_chapter_spec.rb +2 -0
  92. data/spec/paper_trail_scrapbook/user_journal_spec.rb +47 -43
  93. data/spec/paper_trail_scrapbook/version_helpers_spec.rb +9 -7
  94. data/spec/paper_trail_scrapbook/version_spec.rb +2 -0
  95. data/spec/paper_trail_scrapbook_spec.rb +2 -0
  96. data/spec/spec_helper.rb +3 -1
  97. metadata +20 -5
  98. data/circle.yml +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 67563a25cc478a45dfcc0a63311ecec0b38db5c5e8ce3d50977e5eaf3f30ac36
4
- data.tar.gz: 78c1e866535132c11e9e98a606ef739e973f5ed4db0a878db6ae5bf150e67c68
2
+ SHA1:
3
+ metadata.gz: edde51db159600817dbb9e150b277d617415077c
4
+ data.tar.gz: ba553dc8f127055130d34e36a06c9be0204033ee
5
5
  SHA512:
6
- metadata.gz: fe2c6468ec05d4f1f4996a248667ac8ec7c7b3d15921df851dc9266c3ff45566e15569f9f64ebc868bef95a798fb049c33e7363a090ef05158409cc0eafa7cc1
7
- data.tar.gz: 2eb5f79927a5e60ccaad7accd97c6eaca0afc0fa51fe4075c63a5b42d4f424a645ba531c6ebabdc558faeef126b5799269e1ef76a30d50265c67a0fbc9b64c87
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.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
@@ -7,11 +7,11 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).
7
7
 
8
8
  ### Breaking Changes
9
9
 
10
- - None
10
+ - Mandate use of Ruby 2.3+
11
11
 
12
12
  ### Added
13
13
 
14
- - None
14
+ - Switched from CodeClimate v1 to version 2.
15
15
 
16
16
  ### Fixed
17
17
 
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec # DRY! No need to repeat the gem deps here
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paper_trail_scrapbook (0.1.9)
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.1
204
+ 1.16.2
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler'
2
4
  Bundler::GemHelper.install_tasks
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'adamantium'
2
4
  require 'concord'
3
5
  require 'equalizer'
@@ -26,9 +28,5 @@ module PaperTrailScrapbook
26
28
  @config
27
29
  end
28
30
  alias configure config
29
-
30
- def version
31
- VERSION::STRING
32
- end
33
31
  end
34
32
  end
@@ -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 = ' •'.freeze
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(k, v)
36
- old, new = v
37
+ def digest(key, values)
38
+ old, new = values
37
39
  return if old.nil? && (new.nil? || new.eql?(''))
38
40
 
39
- "#{BULLET} #{k.tr('_', ' ')}: #{detailed_analysis(k, new, old)}"
41
+ "#{BULLET} #{key.tr('_', ' ')}: #{detailed_analysis(key, new, old)}"
40
42
  end
41
43
 
42
- def detailed_analysis(k, new, old)
44
+ def detailed_analysis(key, new, old)
43
45
  if creating?
44
- find_value(k, new).to_s
46
+ find_value(key, new).to_s
45
47
  elsif old.nil?
46
- "#{find_value(k, new)} added"
48
+ "#{find_value(key, new)} added"
47
49
  elsif new.nil?
48
- "#{find_value(k, old)} was *removed*"
50
+ "#{find_value(key, old)} was *removed*"
49
51
  else
50
- "#{find_value(k, old)} -> #{find_value(k, new)}"
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 assoc.key?(key)
61
+ return value.to_s unless build_associations.key?(key)
60
62
 
61
63
  return '*empty*' unless value
62
64
 
63
65
  begin
64
- assoc[key].find(value).to_s.to_s + "[#{value}]"
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
- @assoc ||=
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
- @chs ||= if object_changes
99
- YAML
100
- .load(object_changes)
101
- .except(*PaperTrailScrapbook.config.scrub_columns)
102
- else
103
- {}
104
- end
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_relative 'version_helpers'
2
4
 
3
5
  module PaperTrailScrapbook
@@ -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'.freeze
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*'.freeze
16
+ UNKNOWN_WHODUNNIT = '*the app*'
15
17
 
16
18
  attr_accessor :whodunnit_class,
17
19
  :time_format,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'version_helpers'
2
4
 
3
5
  module PaperTrailScrapbook
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PaperTrailScrapbook
2
4
  # Class LifeHistory provides Full multi version history
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PaperTrailScrapbook
2
4
  # Class SecondaryChapter provides single version history analysis for data
3
5
  # related to the main subject
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PaperTrailScrapbook
2
4
  # Class UserJournal provides history for a user, optionally scoped by
3
5
  # object class and/or date range
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PaperTrailScrapbook
2
4
  # Current version
3
- VERSION = '0.1.9'.freeze
5
+ VERSION = '0.1.10'
4
6
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PaperTrailScrapbook
2
4
  # Module VersionHelpers provides methods for extracting common information
3
5
  # from a version or PaperTrailScrapbook config
@@ -1,4 +1,6 @@
1
- require File.expand_path('../lib/paper_trail_scrapbook/version', __FILE__)
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.2.0'
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'
@@ -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('../config/application', __FILE__)
6
+ require File.expand_path('config/application', __dir__)
5
7
  require 'rake'
6
8
 
7
9
  Dummy::Application.load_tasks
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Animal < ActiveRecord::Base
2
4
  has_paper_trail
3
5
  self.inheritance_column = 'species'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Article < ActiveRecord::Base
2
4
  has_paper_trail(
3
5
  ignore: [
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Authorship < ActiveRecord::Base
2
4
  belongs_to :book
3
5
  belongs_to :author, class_name: 'Person'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class BarHabtm < ActiveRecord::Base
2
4
  has_and_belongs_to_many :foo_habtms
3
5
  has_paper_trail
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Book < ActiveRecord::Base
2
4
  has_many :authorships, dependent: :destroy
3
5
  has_many :authors, through: :authorships
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Boolit < ActiveRecord::Base
2
4
  default_scope { where(scoped: true) }
3
5
  has_paper_trail
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CallbackModifier < ActiveRecord::Base
2
4
  has_paper_trail on: []
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Car < Vehicle
2
4
  has_paper_trail
3
5
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Cat < Animal
2
4
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Chapter < ActiveRecord::Base
2
4
  has_many :sections, dependent: :destroy
3
5
  has_many :paragraphs, through: :sections
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Citation < ActiveRecord::Base
2
4
  belongs_to :quotation
3
5