lite-archive 1.0.1 → 1.0.6

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: cea659ac104f7809310d6f98631349067b942c6c5b9c2fcbbec3c387863ebf8a
4
- data.tar.gz: '006095e6223f4abbdd48c6c36ccfb8b955b0d8665ae793674b9f6db4ec46ae08'
3
+ metadata.gz: ee885d2a0188a5dcb40a19ed614d3d8b28db57093496a27f37b7ab2fcddd5a8b
4
+ data.tar.gz: 85975fb0e8438f2b5401470ee2eeab069033e23ab3c434ac09a96b2469e1e41c
5
5
  SHA512:
6
- metadata.gz: c388d87391c0a0dd4e55d072fddb75663ab537e740ad97da3bb4dbdfc2a108db952f2bc024a63ba500426eaac1b31de18bf18786fddc58b8e9c75645bd5b121d
7
- data.tar.gz: 4d8e2ae754e208b3dc35b4906e96d6b6cad160299d5dc0ba2250386038aae9f47b188d6b539c55e997871b48853c68685dcd295eb6835c7ed29f8804420f13da
6
+ metadata.gz: 2fcf6320a6825a97e3858551f0761419a0bd907c23692a898bea10a75951e9dbdfe02814eb9a96c7bed8220dffd7a3c94cb3a64ff109c782a3202e3b2a8f8ff6
7
+ data.tar.gz: '0180f91ac8a834c63f38182adce1107dcf3e793e20cb00953691b1bad1a26a7195722faf536b50a7f2dd046e7d6abd3397417203dcc31f28c83ab6876ccf56f0'
@@ -2,11 +2,12 @@ require:
2
2
  - rubocop-performance
3
3
  - rubocop-rspec
4
4
  AllCops:
5
- TargetRubyVersion: 2.6
5
+ TargetRubyVersion: 2.7
6
+ NewCops: enable
6
7
  DisplayCopNames: true
7
8
  DisplayStyleGuide: true
8
- LineLength:
9
- Max: 100
9
+ Layout/EmptyLinesAroundAttributeAccessor:
10
+ Enabled: true
10
11
  Layout/EmptyLinesAroundBlockBody:
11
12
  Exclude:
12
13
  - 'spec/**/**/*'
@@ -14,6 +15,14 @@ Layout/EmptyLinesAroundClassBody:
14
15
  EnforcedStyle: empty_lines_except_namespace
15
16
  Layout/EmptyLinesAroundModuleBody:
16
17
  EnforcedStyle: empty_lines_except_namespace
18
+ Layout/LineLength:
19
+ Max: 100
20
+ Layout/SpaceAroundMethodCallOperator:
21
+ Enabled: true
22
+ Lint/RaiseException:
23
+ Enabled: true
24
+ Lint/StructNewOverride:
25
+ Enabled: true
17
26
  Metrics/BlockLength:
18
27
  Exclude:
19
28
  - 'spec/**/**/*'
@@ -26,3 +35,13 @@ Style/Documentation:
26
35
  Enabled: false
27
36
  Style/ExpandPathArguments:
28
37
  Enabled: false
38
+ Style/ExponentialNotation:
39
+ Enabled: true
40
+ Style/HashEachMethods:
41
+ Enabled: true
42
+ Style/HashTransformKeys:
43
+ Enabled: true
44
+ Style/HashTransformValues:
45
+ Enabled: true
46
+ Style/SlicingWithRange:
47
+ Enabled: false
@@ -4,6 +4,7 @@ cache: bundler
4
4
  rvm:
5
5
  - 2.5
6
6
  - 2.6
7
+ - 2.7
7
8
  - ruby-head
8
9
  matrix:
9
10
  fast_finish: true
@@ -5,6 +5,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
+
9
+ ## [1.0.6] - 2020-07-03
10
+ ### Removed
11
+ - Removed Ruby 2.7 deprecation warnings
12
+
13
+ ## [1.0.5] - 2019-11-02
14
+ ### Added
15
+ - Add `sync_updated_at` option
16
+
17
+ ## [1.0.4] - 2019-08-24
18
+ ### Changed
19
+ - Improved how configuration works
20
+
21
+ ## [1.0.3] - 2019-08-15
22
+ ### Changed
23
+ - Underscore initializer file name
24
+
25
+ ## [1.0.2] - 2019-07-08
26
+ ### Added
27
+ - Require rails/railtie in railtie
28
+
8
29
  ## [1.0.1] - 2019-07-01
9
30
  ### Changed
10
31
  - Rename `timestamp` to `archival_timestamp`
@@ -1,124 +1,129 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-archive (1.0.1)
4
+ lite-archive (1.0.6)
5
5
  activerecord
6
6
  activesupport
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (5.2.3)
12
- actionview (= 5.2.3)
13
- activesupport (= 5.2.3)
14
- rack (~> 2.0)
11
+ actionpack (6.0.3.2)
12
+ actionview (= 6.0.3.2)
13
+ activesupport (= 6.0.3.2)
14
+ rack (~> 2.0, >= 2.0.8)
15
15
  rack-test (>= 0.6.3)
16
16
  rails-dom-testing (~> 2.0)
17
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
18
- actionview (5.2.3)
19
- activesupport (= 5.2.3)
17
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
+ actionview (6.0.3.2)
19
+ activesupport (= 6.0.3.2)
20
20
  builder (~> 3.1)
21
21
  erubi (~> 1.4)
22
22
  rails-dom-testing (~> 2.0)
23
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
24
- activemodel (5.2.3)
25
- activesupport (= 5.2.3)
26
- activerecord (5.2.3)
27
- activemodel (= 5.2.3)
28
- activesupport (= 5.2.3)
29
- arel (>= 9.0)
30
- activesupport (5.2.3)
23
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
+ activemodel (6.0.3.2)
25
+ activesupport (= 6.0.3.2)
26
+ activerecord (6.0.3.2)
27
+ activemodel (= 6.0.3.2)
28
+ activesupport (= 6.0.3.2)
29
+ activesupport (6.0.3.2)
31
30
  concurrent-ruby (~> 1.0, >= 1.0.2)
32
31
  i18n (>= 0.7, < 2)
33
32
  minitest (~> 5.1)
34
33
  tzinfo (~> 1.1)
35
- arel (9.0.0)
36
- ast (2.4.0)
37
- builder (3.2.3)
34
+ zeitwerk (~> 2.2, >= 2.2.2)
35
+ ast (2.4.1)
36
+ builder (3.2.4)
38
37
  colorize (0.8.1)
39
- concurrent-ruby (1.1.5)
40
- crass (1.0.4)
41
- database_cleaner (1.7.0)
42
- diff-lcs (1.3)
43
- erubi (1.8.0)
44
- fasterer (0.5.1)
38
+ concurrent-ruby (1.1.6)
39
+ crass (1.0.6)
40
+ database_cleaner (1.8.5)
41
+ diff-lcs (1.4.4)
42
+ erubi (1.9.0)
43
+ fasterer (0.8.3)
45
44
  colorize (~> 0.7)
46
- ruby_parser (>= 3.13.0)
45
+ ruby_parser (>= 3.14.1)
47
46
  generator_spec (0.9.4)
48
47
  activesupport (>= 3.0.0)
49
48
  railties (>= 3.0.0)
50
- i18n (1.6.0)
49
+ i18n (1.8.3)
51
50
  concurrent-ruby (~> 1.0)
52
- jaro_winkler (1.5.3)
53
- loofah (2.2.3)
51
+ loofah (2.6.0)
54
52
  crass (~> 1.0.2)
55
53
  nokogiri (>= 1.5.9)
56
- method_source (0.9.2)
54
+ method_source (1.0.0)
57
55
  mini_portile2 (2.4.0)
58
- minitest (5.11.3)
59
- nokogiri (1.10.3)
56
+ minitest (5.14.1)
57
+ nokogiri (1.10.9)
60
58
  mini_portile2 (~> 2.4.0)
61
- parallel (1.17.0)
62
- parser (2.6.3.0)
63
- ast (~> 2.4.0)
64
- rack (2.0.7)
59
+ parallel (1.19.2)
60
+ parser (2.7.1.4)
61
+ ast (~> 2.4.1)
62
+ rack (2.2.3)
65
63
  rack-test (1.1.0)
66
64
  rack (>= 1.0, < 3)
67
65
  rails-dom-testing (2.0.3)
68
66
  activesupport (>= 4.2.0)
69
67
  nokogiri (>= 1.6)
70
- rails-html-sanitizer (1.0.4)
71
- loofah (~> 2.2, >= 2.2.2)
72
- railties (5.2.3)
73
- actionpack (= 5.2.3)
74
- activesupport (= 5.2.3)
68
+ rails-html-sanitizer (1.3.0)
69
+ loofah (~> 2.3)
70
+ railties (6.0.3.2)
71
+ actionpack (= 6.0.3.2)
72
+ activesupport (= 6.0.3.2)
75
73
  method_source
76
74
  rake (>= 0.8.7)
77
- thor (>= 0.19.0, < 2.0)
75
+ thor (>= 0.20.3, < 2.0)
78
76
  rainbow (3.0.0)
79
- rake (12.3.2)
80
- rspec (3.8.0)
81
- rspec-core (~> 3.8.0)
82
- rspec-expectations (~> 3.8.0)
83
- rspec-mocks (~> 3.8.0)
84
- rspec-core (3.8.2)
85
- rspec-support (~> 3.8.0)
86
- rspec-expectations (3.8.4)
77
+ rake (13.0.1)
78
+ regexp_parser (1.7.1)
79
+ rexml (3.2.4)
80
+ rspec (3.9.0)
81
+ rspec-core (~> 3.9.0)
82
+ rspec-expectations (~> 3.9.0)
83
+ rspec-mocks (~> 3.9.0)
84
+ rspec-core (3.9.2)
85
+ rspec-support (~> 3.9.3)
86
+ rspec-expectations (3.9.2)
87
87
  diff-lcs (>= 1.2.0, < 2.0)
88
- rspec-support (~> 3.8.0)
89
- rspec-mocks (3.8.1)
88
+ rspec-support (~> 3.9.0)
89
+ rspec-mocks (3.9.1)
90
90
  diff-lcs (>= 1.2.0, < 2.0)
91
- rspec-support (~> 3.8.0)
92
- rspec-rails (3.8.2)
93
- actionpack (>= 3.0)
94
- activesupport (>= 3.0)
95
- railties (>= 3.0)
96
- rspec-core (~> 3.8.0)
97
- rspec-expectations (~> 3.8.0)
98
- rspec-mocks (~> 3.8.0)
99
- rspec-support (~> 3.8.0)
100
- rspec-support (3.8.2)
101
- rubocop (0.72.0)
102
- jaro_winkler (~> 1.5.1)
91
+ rspec-support (~> 3.9.0)
92
+ rspec-rails (4.0.1)
93
+ actionpack (>= 4.2)
94
+ activesupport (>= 4.2)
95
+ railties (>= 4.2)
96
+ rspec-core (~> 3.9)
97
+ rspec-expectations (~> 3.9)
98
+ rspec-mocks (~> 3.9)
99
+ rspec-support (~> 3.9)
100
+ rspec-support (3.9.3)
101
+ rubocop (0.86.0)
103
102
  parallel (~> 1.10)
104
- parser (>= 2.6)
103
+ parser (>= 2.7.0.1)
105
104
  rainbow (>= 2.2.2, < 4.0)
105
+ regexp_parser (>= 1.7)
106
+ rexml
107
+ rubocop-ast (>= 0.0.3, < 1.0)
106
108
  ruby-progressbar (~> 1.7)
107
- unicode-display_width (>= 1.4.0, < 1.7)
108
- rubocop-performance (1.4.0)
109
+ unicode-display_width (>= 1.4.0, < 2.0)
110
+ rubocop-ast (0.1.0)
111
+ parser (>= 2.7.0.1)
112
+ rubocop-performance (1.6.1)
109
113
  rubocop (>= 0.71.0)
110
- rubocop-rspec (1.33.0)
111
- rubocop (>= 0.60.0)
114
+ rubocop-rspec (1.41.0)
115
+ rubocop (>= 0.68.1)
112
116
  ruby-progressbar (1.10.1)
113
- ruby_parser (3.13.1)
117
+ ruby_parser (3.14.2)
114
118
  sexp_processor (~> 4.9)
115
- sexp_processor (4.12.1)
116
- sqlite3 (1.4.1)
117
- thor (0.20.3)
119
+ sexp_processor (4.15.0)
120
+ sqlite3 (1.4.2)
121
+ thor (1.0.1)
118
122
  thread_safe (0.3.6)
119
- tzinfo (1.2.5)
123
+ tzinfo (1.2.7)
120
124
  thread_safe (~> 0.1)
121
- unicode-display_width (1.6.0)
125
+ unicode-display_width (1.7.0)
126
+ zeitwerk (2.3.1)
122
127
 
123
128
  PLATFORMS
124
129
  ruby
@@ -138,4 +143,4 @@ DEPENDENCIES
138
143
  sqlite3
139
144
 
140
145
  BUNDLED WITH
141
- 2.0.1
146
+ 2.1.4
data/README.md CHANGED
@@ -35,11 +35,12 @@ Or install it yourself as:
35
35
  ## Configurations
36
36
 
37
37
  `rails g lite:archive:install` will generate the following file:
38
- `../config/initalizers/lite-archive.rb`
38
+ `../config/initalizers/lite_archive.rb`
39
39
 
40
40
  ```ruby
41
41
  Lite::Archive.configure do |config|
42
42
  config.all_records_archivable = false
43
+ config.sync_updated_at = true
43
44
  end
44
45
  ```
45
46
 
@@ -49,17 +50,23 @@ An `archived_at` column must be added to tables where you do not want records de
49
50
  If the table does not have this column, records will be destroy instead of archived.
50
51
 
51
52
  ```ruby
52
- class AddArchivedAtColumns < ActiveRecord::Migration
53
+ class AddArchivedAtColumn < ActiveRecord::Migration
53
54
  def change
54
55
  # Adds archived_at automatically (if all_records_archivable is set to true)
55
56
  t.timestamp
56
57
 
58
+ # - or -
59
+
57
60
  # Adds archived_at timestamp
58
61
  t.timestamp archive: true
59
62
 
63
+ # - or -
64
+
60
65
  # Does NOT add archived_at timestamp
61
66
  t.timestamp archive: false
62
67
 
68
+ # - or -
69
+
63
70
  # Manual column (null constraint must be false)
64
71
  add_column :your_model, :archived_at, :datetime
65
72
  end
@@ -103,7 +110,7 @@ User.unarchived.all #=> Returns only unarchived records
103
110
 
104
111
  ## Port
105
112
 
106
- `Lite::Archive` is compatible port of [ActiveArchive](https://github.com/drexed/active_archive).
113
+ `Lite::Archive` is a compatible port of [ActiveArchive](https://github.com/drexed/active_archive).
107
114
 
108
115
  Switching is as easy as renaming `ActiveArchive` to `Lite::Archive`.
109
116
 
@@ -9,7 +9,7 @@ module Lite
9
9
  source_root File.expand_path('../templates', __FILE__)
10
10
 
11
11
  def copy_initializer_file
12
- copy_file('install.rb', 'config/initializers/lite-archive.rb')
12
+ copy_file('install.rb', 'config/initializers/lite_archive.rb')
13
13
  end
14
14
 
15
15
  end
@@ -2,4 +2,5 @@
2
2
 
3
3
  Lite::Archive.configure do |config|
4
4
  config.all_records_archivable = false
5
+ config.sync_updated_at = true
5
6
  end
@@ -146,6 +146,8 @@ module Lite
146
146
  end
147
147
 
148
148
  def updatable?
149
+ return false unless Lite::Archive.configuration.sync_updated_at == true
150
+
149
151
  respond_to?(:updated_at)
150
152
  end
151
153
 
@@ -5,24 +5,31 @@ module Lite
5
5
 
6
6
  class Configuration
7
7
 
8
- attr_accessor :all_records_archivable
8
+ attr_accessor :all_records_archivable, :sync_updated_at
9
9
 
10
10
  def initialize
11
11
  @all_records_archivable = false
12
+ @sync_updated_at = true
12
13
  end
13
14
 
14
15
  end
15
16
 
16
- def self.configuration
17
- @configuration ||= Configuration.new
18
- end
17
+ class << self
19
18
 
20
- def self.configuration=(config)
21
- @configuration = config
22
- end
19
+ attr_writer :configuration
20
+
21
+ def configuration
22
+ @configuration ||= Configuration.new
23
+ end
24
+
25
+ def configure
26
+ yield(configuration)
27
+ end
28
+
29
+ def reset_configuration!
30
+ @configuration = Configuration.new
31
+ end
23
32
 
24
- def self.configure
25
- yield(configuration)
26
33
  end
27
34
 
28
35
  end
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rails/railtie'
4
+
3
5
  module Lite
4
6
  module Archive
5
7
  class Railtie < ::Rails::Railtie
6
8
 
7
- initializer 'lite-archive' do |app|
9
+ initializer 'lite-archive.setup' do |app|
8
10
  Lite::Archive::Railtie.instance_eval do
9
11
  [app.config.i18n.available_locales].flatten.each do |locale|
10
12
  path = File.expand_path("../../../config/locales/#{locale}.yml", __FILE__)
@@ -7,14 +7,14 @@ module Lite
7
7
  def timestamps(*args)
8
8
  options = args.extract_options!
9
9
 
10
- column(:created_at, :datetime, options)
11
- column(:updated_at, :datetime, options)
10
+ column(:created_at, :datetime, **options)
11
+ column(:updated_at, :datetime, **options)
12
12
 
13
13
  return unless Lite::Archive.configuration.all_records_archivable == true
14
14
  return if options[:archive] == false
15
15
 
16
16
  options[:null] = true
17
- column(:archived_at, :datetime, options)
17
+ column(:archived_at, :datetime, **options)
18
18
  end
19
19
 
20
20
  end
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Archive
5
5
 
6
- VERSION ||= '1.0.1'
6
+ VERSION ||= '1.0.6'
7
7
 
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-01 00:00:00.000000000 Z
11
+ date: 2020-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -192,7 +192,7 @@ dependencies:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
- description:
195
+ description:
196
196
  email:
197
197
  - j.gomez@drexed.com
198
198
  executables: []
@@ -230,7 +230,7 @@ homepage: http://drexed.github.io/lite-archive
230
230
  licenses:
231
231
  - MIT
232
232
  metadata: {}
233
- post_install_message:
233
+ post_install_message:
234
234
  rdoc_options: []
235
235
  require_paths:
236
236
  - lib
@@ -245,8 +245,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
245
  - !ruby/object:Gem::Version
246
246
  version: '0'
247
247
  requirements: []
248
- rubygems_version: 3.0.4
249
- signing_key:
248
+ rubygems_version: 3.1.4
249
+ signing_key:
250
250
  specification_version: 4
251
251
  summary: Archive (soft-delete) ActiveRecord database records
252
252
  test_files: []