lite-archive 1.0.6 → 1.0.7

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: ee885d2a0188a5dcb40a19ed614d3d8b28db57093496a27f37b7ab2fcddd5a8b
4
- data.tar.gz: 85975fb0e8438f2b5401470ee2eeab069033e23ab3c434ac09a96b2469e1e41c
3
+ metadata.gz: 05c24a09d2048dfa4e351204489462d3d86ba453fcdcabbb2cd6920d0dd20a9b
4
+ data.tar.gz: 2336963e85871ab47c5c58c8f9d0acbef1dfdcbc928694ef9c18a65b73eb031a
5
5
  SHA512:
6
- metadata.gz: 2fcf6320a6825a97e3858551f0761419a0bd907c23692a898bea10a75951e9dbdfe02814eb9a96c7bed8220dffd7a3c94cb3a64ff109c782a3202e3b2a8f8ff6
7
- data.tar.gz: '0180f91ac8a834c63f38182adce1107dcf3e793e20cb00953691b1bad1a26a7195722faf536b50a7f2dd046e7d6abd3397417203dcc31f28c83ab6876ccf56f0'
6
+ metadata.gz: e3083fb599fc8fa1043327aea5ef7823c804e51f48c93e6212e71d319d59fdd294b8f436eb4b9e4a564e3ecfea021dfa8da60972a2ff2c5997540d5ccf6406d4
7
+ data.tar.gz: 10aece893c72226121d2b9f73c4d2aaeed29b1ce91859488877e44e5811b3ff9089e4dd36078e0ebe8f925a530c2b962def47fa5abf8149ec23d41ff208a26ef
@@ -6,6 +6,8 @@ AllCops:
6
6
  NewCops: enable
7
7
  DisplayCopNames: true
8
8
  DisplayStyleGuide: true
9
+ Gemspec/RequiredRubyVersion:
10
+ Enabled: false
9
11
  Layout/EmptyLinesAroundAttributeAccessor:
10
12
  Enabled: true
11
13
  Layout/EmptyLinesAroundBlockBody:
@@ -35,13 +37,3 @@ Style/Documentation:
35
37
  Enabled: false
36
38
  Style/ExpandPathArguments:
37
39
  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
@@ -6,9 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.0.7] - 2020-11-03
10
+ ### Changed
11
+ - Improved migration support
12
+
9
13
  ## [1.0.6] - 2020-07-03
10
- ### Removed
11
- - Removed Ruby 2.7 deprecation warnings
14
+ ### Added
15
+ - Added Ruby 2.7 support
12
16
 
13
17
  ## [1.0.5] - 2019-11-02
14
18
  ### Added
@@ -1,32 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-archive (1.0.6)
4
+ lite-archive (1.0.7)
5
5
  activerecord
6
6
  activesupport
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (6.0.3.2)
12
- actionview (= 6.0.3.2)
13
- activesupport (= 6.0.3.2)
11
+ actionpack (6.0.3.4)
12
+ actionview (= 6.0.3.4)
13
+ activesupport (= 6.0.3.4)
14
14
  rack (~> 2.0, >= 2.0.8)
15
15
  rack-test (>= 0.6.3)
16
16
  rails-dom-testing (~> 2.0)
17
17
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (6.0.3.2)
19
- activesupport (= 6.0.3.2)
18
+ actionview (6.0.3.4)
19
+ activesupport (= 6.0.3.4)
20
20
  builder (~> 3.1)
21
21
  erubi (~> 1.4)
22
22
  rails-dom-testing (~> 2.0)
23
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)
24
+ activemodel (6.0.3.4)
25
+ activesupport (= 6.0.3.4)
26
+ activerecord (6.0.3.4)
27
+ activemodel (= 6.0.3.4)
28
+ activesupport (= 6.0.3.4)
29
+ activesupport (6.0.3.4)
30
30
  concurrent-ruby (~> 1.0, >= 1.0.2)
31
31
  i18n (>= 0.7, < 2)
32
32
  minitest (~> 5.1)
@@ -35,7 +35,7 @@ GEM
35
35
  ast (2.4.1)
36
36
  builder (3.2.4)
37
37
  colorize (0.8.1)
38
- concurrent-ruby (1.1.6)
38
+ concurrent-ruby (1.1.7)
39
39
  crass (1.0.6)
40
40
  database_cleaner (1.8.5)
41
41
  diff-lcs (1.4.4)
@@ -46,18 +46,18 @@ GEM
46
46
  generator_spec (0.9.4)
47
47
  activesupport (>= 3.0.0)
48
48
  railties (>= 3.0.0)
49
- i18n (1.8.3)
49
+ i18n (1.8.5)
50
50
  concurrent-ruby (~> 1.0)
51
- loofah (2.6.0)
51
+ loofah (2.7.0)
52
52
  crass (~> 1.0.2)
53
53
  nokogiri (>= 1.5.9)
54
54
  method_source (1.0.0)
55
55
  mini_portile2 (2.4.0)
56
- minitest (5.14.1)
57
- nokogiri (1.10.9)
56
+ minitest (5.14.2)
57
+ nokogiri (1.10.10)
58
58
  mini_portile2 (~> 2.4.0)
59
59
  parallel (1.19.2)
60
- parser (2.7.1.4)
60
+ parser (2.7.2.0)
61
61
  ast (~> 2.4.1)
62
62
  rack (2.2.3)
63
63
  rack-test (1.1.0)
@@ -67,28 +67,28 @@ GEM
67
67
  nokogiri (>= 1.6)
68
68
  rails-html-sanitizer (1.3.0)
69
69
  loofah (~> 2.3)
70
- railties (6.0.3.2)
71
- actionpack (= 6.0.3.2)
72
- activesupport (= 6.0.3.2)
70
+ railties (6.0.3.4)
71
+ actionpack (= 6.0.3.4)
72
+ activesupport (= 6.0.3.4)
73
73
  method_source
74
74
  rake (>= 0.8.7)
75
75
  thor (>= 0.20.3, < 2.0)
76
76
  rainbow (3.0.0)
77
77
  rake (13.0.1)
78
- regexp_parser (1.7.1)
78
+ regexp_parser (1.8.2)
79
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)
80
+ rspec (3.10.0)
81
+ rspec-core (~> 3.10.0)
82
+ rspec-expectations (~> 3.10.0)
83
+ rspec-mocks (~> 3.10.0)
84
+ rspec-core (3.10.0)
85
+ rspec-support (~> 3.10.0)
86
+ rspec-expectations (3.10.0)
87
87
  diff-lcs (>= 1.2.0, < 2.0)
88
- rspec-support (~> 3.9.0)
89
- rspec-mocks (3.9.1)
88
+ rspec-support (~> 3.10.0)
89
+ rspec-mocks (3.10.0)
90
90
  diff-lcs (>= 1.2.0, < 2.0)
91
- rspec-support (~> 3.9.0)
91
+ rspec-support (~> 3.10.0)
92
92
  rspec-rails (4.0.1)
93
93
  actionpack (>= 4.2)
94
94
  activesupport (>= 4.2)
@@ -97,33 +97,35 @@ GEM
97
97
  rspec-expectations (~> 3.9)
98
98
  rspec-mocks (~> 3.9)
99
99
  rspec-support (~> 3.9)
100
- rspec-support (3.9.3)
101
- rubocop (0.86.0)
100
+ rspec-support (3.10.0)
101
+ rubocop (0.93.1)
102
102
  parallel (~> 1.10)
103
- parser (>= 2.7.0.1)
103
+ parser (>= 2.7.1.5)
104
104
  rainbow (>= 2.2.2, < 4.0)
105
- regexp_parser (>= 1.7)
105
+ regexp_parser (>= 1.8)
106
106
  rexml
107
- rubocop-ast (>= 0.0.3, < 1.0)
107
+ rubocop-ast (>= 0.6.0)
108
108
  ruby-progressbar (~> 1.7)
109
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)
113
- rubocop (>= 0.71.0)
114
- rubocop-rspec (1.41.0)
115
- rubocop (>= 0.68.1)
110
+ rubocop-ast (1.1.0)
111
+ parser (>= 2.7.1.5)
112
+ rubocop-performance (1.8.1)
113
+ rubocop (>= 0.87.0)
114
+ rubocop-ast (>= 0.4.0)
115
+ rubocop-rspec (1.44.1)
116
+ rubocop (~> 0.87)
117
+ rubocop-ast (>= 0.7.1)
116
118
  ruby-progressbar (1.10.1)
117
- ruby_parser (3.14.2)
119
+ ruby_parser (3.15.0)
118
120
  sexp_processor (~> 4.9)
119
- sexp_processor (4.15.0)
121
+ sexp_processor (4.15.1)
120
122
  sqlite3 (1.4.2)
121
123
  thor (1.0.1)
122
124
  thread_safe (0.3.6)
123
125
  tzinfo (1.2.7)
124
126
  thread_safe (~> 0.1)
125
127
  unicode-display_width (1.7.0)
126
- zeitwerk (2.3.1)
128
+ zeitwerk (2.4.1)
127
129
 
128
130
  PLATFORMS
129
131
  ruby
data/README.md CHANGED
@@ -52,23 +52,15 @@ If the table does not have this column, records will be destroy instead of archi
52
52
  ```ruby
53
53
  class AddArchivedAtColumn < ActiveRecord::Migration
54
54
  def change
55
- # Adds archived_at automatically (if all_records_archivable is set to true)
56
- t.timestamp
55
+ create_table :table_name do |t|
56
+ t.timestamp # Adds archived_at automatically (if all_records_archivable is set to true)
57
+ t.timestamp archive: true # Adds archived_at timestamp
58
+ t.timestamp archive: false # Does NOT add archived_at timestamp
59
+ end
57
60
 
58
- # - or -
61
+ add_timestamp :table_name
59
62
 
60
- # Adds archived_at timestamp
61
- t.timestamp archive: true
62
-
63
- # - or -
64
-
65
- # Does NOT add archived_at timestamp
66
- t.timestamp archive: false
67
-
68
- # - or -
69
-
70
- # Manual column (null constraint must be false)
71
- add_column :your_model, :archived_at, :datetime
63
+ add_column :table_name, :archived_at, :datetime # Manual column (null constraint must be false)
72
64
  end
73
65
  end
74
66
  ```
@@ -6,7 +6,7 @@ require 'active_support'
6
6
  require 'lite/archive/version'
7
7
  require 'lite/archive/railtie' if defined?(Rails)
8
8
 
9
- %w[configuration table_definition methods scopes base].each do |name|
9
+ %w[configuration schema_statement table_definition methods scopes base].each do |name|
10
10
  require "lite/archive/#{name}"
11
11
  end
12
12
 
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lite
4
+ module Archive
5
+ module SchemaStatement
6
+
7
+ def add_timestamps(table_name, **options)
8
+ options[:null] = false if options[:null].nil?
9
+ options[:precision] ||= 6 if supports_datetime_with_precision?
10
+
11
+ add_column(table_name, :created_at, :datetime, **options)
12
+ add_column(table_name, :updated_at, :datetime, **options)
13
+
14
+ return unless Lite::Archive.configuration.all_records_archivable == true
15
+ return if options[:archive] == false
16
+
17
+ options[:null] = true
18
+ add_column(table_name, :archived_at, :datetime, **options)
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+
25
+ ActiveRecord::Migration.prepend(Lite::Archive::SchemaStatement)
@@ -4,8 +4,9 @@ module Lite
4
4
  module Archive
5
5
  module TableDefinition
6
6
 
7
- def timestamps(*args)
8
- options = args.extract_options!
7
+ def timestamps(**options)
8
+ options[:null] = false if options[:null].nil?
9
+ options[:precision] ||= 6 if @conn.supports_datetime_with_precision?
9
10
 
10
11
  column(:created_at, :datetime, **options)
11
12
  column(:updated_at, :datetime, **options)
@@ -21,4 +22,5 @@ module Lite
21
22
  end
22
23
  end
23
24
 
25
+ ActiveRecord::ConnectionAdapters::Table.prepend(Lite::Archive::TableDefinition)
24
26
  ActiveRecord::ConnectionAdapters::TableDefinition.prepend(Lite::Archive::TableDefinition)
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Archive
5
5
 
6
- VERSION ||= '1.0.6'
6
+ VERSION ||= '1.0.7'
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.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-03 00:00:00.000000000 Z
11
+ date: 2020-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -222,6 +222,7 @@ files:
222
222
  - lib/lite/archive/configuration.rb
223
223
  - lib/lite/archive/methods.rb
224
224
  - lib/lite/archive/railtie.rb
225
+ - lib/lite/archive/schema_statement.rb
225
226
  - lib/lite/archive/scopes.rb
226
227
  - lib/lite/archive/table_definition.rb
227
228
  - lib/lite/archive/version.rb