attributes_history 0.1.1 → 0.2.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: fcb6638b56060a71aae14c1ff659cad9aab0ac22735060daf79a6821f0f40f16
4
- data.tar.gz: 80dc1bf040c6cfbad8165eca6aa92c8fe4e6b1fb4c2264f90eebc9eb0b126a19
3
+ metadata.gz: bcb1f022b908387c199bf5bd3e0a6e244fa1cd9086b788027c5499b44a73d6d4
4
+ data.tar.gz: 27f508b9705d7eab06e1d9f45cf037e4daaf6e700df4eb5d8ed8687052c32e36
5
5
  SHA512:
6
- metadata.gz: f1b57eb2d44dc32ce5181eb8bd5c221398ec09893eded14701aabad0de47dc9c84bc7a5d650bb600b7c7b5c1f04f791ebe2d6ded5d507c2f74c32116e6aa2956
7
- data.tar.gz: 57c58b2cd0c78a704863830a792e5e4cfb10b26be0b9091b5450e50c5e2e61ba1c3bb4d1a13c5214ec3f3056694d030ecd90602367909a4b8b5f82369f881931
6
+ metadata.gz: ec16bb7605efa23209706931059f5caeac3ae0a93619e503fe335b1e1cf7d607b9cbc0e86be4afaa8573365e1872d77482dd80e4aa59cfe7a068b62b0b41eb13
7
+ data.tar.gz: f776637cf760554a7e75f7c95bb3a602ce1e25bdb3ae3b685b9e9fc1e442471fce2fb6d11c33ced13455b493f18765d1904a0d0abcd599e162cc43313ad4fe91
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'bundler/setup'
3
5
  rescue LoadError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AttributesHistory
2
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
  require_relative 'history_saver'
3
5
  require_relative 'history_retriever'
@@ -46,7 +48,7 @@ module AttributesHistory
46
48
  def setup_history_callback(history_attributes, history_model)
47
49
  after_update do
48
50
  HistorySaver.new(self, history_attributes, history_model)
49
- .save_if_needed
51
+ .save_if_needed
50
52
  end
51
53
  end
52
54
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AttributesHistory
2
4
  class HistoryRetriever
3
5
  def initialize(object)
@@ -9,7 +11,7 @@ module AttributesHistory
9
11
  history_association = @object.class.history_association(attribute)
10
12
 
11
13
  history_entry = @cached_history[[history_association, date]] ||=
12
- find_entry_on(history_association, date)
14
+ find_entry_on(history_association, date)
13
15
 
14
16
  history_entry.public_send(attribute)
15
17
  end
@@ -18,7 +20,7 @@ module AttributesHistory
18
20
 
19
21
  def find_entry_on(history_association, date)
20
22
  @object.public_send(history_association)
21
- .where('recorded_on > ?', date).order(:recorded_on).first || @object
23
+ .where('recorded_on > ?', date).order(:recorded_on).first || @object
22
24
  end
23
25
  end
24
26
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AttributesHistory
2
4
  class HistorySaver
3
5
  def initialize(changed_object, history_attributes, history_model)
@@ -22,7 +24,7 @@ module AttributesHistory
22
24
  @object.class.history_association(@history_attributes.first)
23
25
 
24
26
  history_entry = @object.public_send(history_association)
25
- .find_or_initialize_by(recorded_on: Date.current)
27
+ .find_or_initialize_by(recorded_on: Date.current)
26
28
 
27
29
  # If there is an existing history record for today, just leave it as is,
28
30
  # otherwise, save the newly initialized one.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rspec/core'
2
4
 
3
5
  RSpec.configure do |config|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'attributes_history/gem_version.rb'
2
4
  require 'attributes_history/has_attributes_history.rb'
3
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attributes_history
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - draffensperger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-09 00:00:00.000000000 Z
11
+ date: 2024-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '3.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.2'
22
+ version: '8.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '3.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.2'
32
+ version: '8.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activesupport
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '3.0'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '6.2'
42
+ version: '8.0'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,91 +49,91 @@ dependencies:
49
49
  version: '3.0'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '6.2'
52
+ version: '8.0'
53
53
  - !ruby/object:Gem::Dependency
54
- name: rails
54
+ name: pry
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - "~>"
57
+ - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 6.1.0
59
+ version: '0'
60
60
  type: :development
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - "~>"
64
+ - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 6.1.0
66
+ version: '0'
67
67
  - !ruby/object:Gem::Dependency
68
- name: rspec-rails
68
+ name: pry-byebug
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - "~>"
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
- version: 3.8.0
73
+ version: '0'
74
74
  type: :development
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - "~>"
78
+ - - ">="
79
79
  - !ruby/object:Gem::Version
80
- version: 3.8.0
80
+ version: '0'
81
81
  - !ruby/object:Gem::Dependency
82
- name: rubocop
82
+ name: rails
83
83
  requirement: !ruby/object:Gem::Requirement
84
84
  requirements:
85
85
  - - "~>"
86
86
  - !ruby/object:Gem::Version
87
- version: 0.35.1
87
+ version: '7.0'
88
88
  type: :development
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: 0.35.1
94
+ version: '7.0'
95
95
  - !ruby/object:Gem::Dependency
96
- name: sqlite3
96
+ name: rspec-rails
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - ">="
99
+ - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: '0'
101
+ version: 3.8.0
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - ">="
106
+ - - "~>"
107
107
  - !ruby/object:Gem::Version
108
- version: '0'
108
+ version: 3.8.0
109
109
  - !ruby/object:Gem::Dependency
110
- name: pry
110
+ name: rubocop
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - ">="
113
+ - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: '0'
115
+ version: 0.61.0
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - ">="
120
+ - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: '0'
122
+ version: 0.61.0
123
123
  - !ruby/object:Gem::Dependency
124
- name: pry-byebug
124
+ name: sqlite3
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ">="
127
+ - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '0'
129
+ version: '1.7'
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - ">="
134
+ - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: '0'
136
+ version: '1.7'
137
137
  description: Date-granular history for specified model fields. Compact & easy to query.
138
138
  email:
139
139
  - d.raffensperger@gmail.com
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  requirements: []
172
- rubygems_version: 3.1.2
172
+ rubygems_version: 3.5.9
173
173
  signing_key:
174
174
  specification_version: 4
175
175
  summary: Date-granular history for specified model fields. Compact & easy to query.