estore_conventions 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/VERSION +1 -1
- data/estore_conventions.gemspec +1 -1
- data/lib/estore_conventions.rb +17 -19
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTkzNzViMjU2NjhmZDgzMjJiMjZmZGMyZDJjNzMxMDBlMjU3NzlkMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzJiZmYyOWFiMDUxYzMzODYzOGFiMjc5ODBhMDk2YWZlNGI2ZTQ1OA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTY1Mjg5M2UwNGU1ZGVmMWJmYmJlMmMwYzc4NDk5MzVlYzEyNDA2OTRjZDc0
|
10
|
+
YzIyOTNhZjVmYTM5NTc0OTU4NDQ0MzE1NWYzYTVlZTAxMmE5MzAyNTQ1NWEx
|
11
|
+
NjRhOTBlMjgzNmQ2M2FiNTE4ODAzOTJhY2NiZjZmZjUxMzU2NWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDk0MzMzOThlNDhhYmE0Y2UzNTEzNDQyZWRkM2I4YWZlMzgzNWM3MjFhZDY3
|
14
|
+
ZWVkZDU3NGEyZWFhNjc3Y2I3ODYxNGNjM2Y5YjIwZDkxN2Q3ZjNmZWIzY2Fm
|
15
|
+
ZDk5N2Q3OGI4NDQ2YWM1ZTlkZTExYmIyYjQ1YzdjNjlmMzYzYzg=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.9
|
data/estore_conventions.gemspec
CHANGED
data/lib/estore_conventions.rb
CHANGED
@@ -36,31 +36,29 @@ module EstoreConventions
|
|
36
36
|
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
time_frame = (DateTime.now + 1.day).beginning_of_day - time_frame
|
39
|
+
def archived_attribute(attribute, time_frame=(30.days))
|
40
|
+
# normalize time since we are returning today as a whole day
|
41
|
+
time_frame = (DateTime.now + 1.day).beginning_of_day - time_frame
|
43
42
|
|
44
|
-
|
45
|
-
|
43
|
+
# transform papertrail objects to reify objects
|
44
|
+
a = self.versions.map {|v| v.reify }
|
46
45
|
|
47
|
-
|
48
|
-
|
46
|
+
# get rid of nil first version
|
47
|
+
a.compact!
|
49
48
|
|
50
|
-
|
51
|
-
|
49
|
+
# add the current object to the array
|
50
|
+
a << self
|
52
51
|
|
53
|
-
|
54
|
-
|
52
|
+
# weed out old entries
|
53
|
+
a.delete_if {|x| x.rails_updated_at <= time_frame }
|
55
54
|
|
56
|
-
|
57
|
-
|
55
|
+
# sort hash based on key
|
56
|
+
a.sort_by!{|x| x.rails_updated_at }
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
58
|
+
# transform reify objects into hash of {date => value}
|
59
|
+
a.reduce({}) do |hsh,val|
|
60
|
+
hsh[val.rails_updated_at.strftime('%Y-%m-%d')] = val.send(attribute)
|
61
|
+
hsh
|
64
62
|
end
|
65
63
|
end
|
66
64
|
|