estore_conventions 0.1.7 → 0.1.8

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Njg2YTMzNzA5YjZiNzAzMWQ1NDhkYmU1OGRiZGM3ZWE3Nzk2YTMwZQ==
4
+ OGM4Y2Y4MjZjOWRkYjU1M2U1MTYwODVlOGUyZTg2ODZmNTIxYzgzZQ==
5
5
  data.tar.gz: !binary |-
6
- ZTViODc1ZjU5ZjMwNjJmNTRiZmMwZWUzYmJjOWMxNmY3ODJkY2VlMQ==
6
+ NTMwMmZhZDYzNjljNmEyZDM4YTM0ZWVmYjFjNjg1NTk4NTg1NTEzOQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTUwYzRhMjIxMTAwNjM3MThhODc5MzU4NTk2NGZmMGY1MWQyNzZhYmY3ZDI5
10
- ZDI5NmU4OGFmY2UzMjVmM2QxMjY3YjA4ODYzM2FlNWJkODc1ZGIxOTIwYzlk
11
- MjUwYTU0NTQ3YmY2NGIzM2ExMTFmYWYxNjY4NDUzMGUzN2ExYTg=
9
+ ZDBkODQ2ZDc0MDExZjNkNWIzNzYyMGZjYjFkZjE1ODcxYTY3NGJmZmZmYTli
10
+ OGY5NjdiNDhjMTJkMjM3NmJkNjA4OTY4MDA2ZDcxNTZjYjhkNjdhNTJhYzFm
11
+ Njg1MDZiYzkyOWZhNTFiNTNiMzk3NmM1Mzk5MTUyZjljMDFiNGY=
12
12
  data.tar.gz: !binary |-
13
- NWZlNDFkMDc5MzVlY2MyYjY4ZTdmYjJmYzVlMGVmZWI4MTkyNDUzMGRlNmZi
14
- YzI0ZjZlM2M1OTNkMWQ1NjA0MzFjY2UyMWIyNThlNTdiZjc1ZDQxZjU4MzA4
15
- Y2UwZjA0YTU1NmZkNzE4MjIxMTg0OWRmNTRhNGU2YTZkNDllMjY=
13
+ MzA3ZTQ5Y2MyZmE4NGJmNTNkZjEzMmMyMTk2YTg3ZDZhM2Q5MjNlMjIxY2E2
14
+ NzY3NWQ0NjdjOTQ5NDFiODUwZGE4ZmE3ZTMyYmY0MjM3NDY0YmIwNmJlMTE3
15
+ NWM4NzY3OWY2Y2E0YTY5NzE0MGNkMGMzYTA3YmUzYzJkYWJjZGM=
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p194
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.1.8
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "estore_conventions"
8
- s.version = "0.1.7"
8
+ s.version = "0.1.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andrew Callahan"]
12
- s.date = "2013-10-01"
12
+ s.date = "2013-10-09"
13
13
  s.description = "abstracting out things"
14
14
  s.email = "andrew.callahan@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
+ ".ruby-version",
21
22
  "Gemfile",
22
23
  "Gemfile.lock",
23
24
  "LICENSE.txt",
@@ -36,6 +36,34 @@ module EstoreConventions
36
36
 
37
37
  end
38
38
 
39
+ module InstanceMethods
40
+ def archived_attribute(attribute, time_frame=(30.days))
41
+ # normalize time since we are returning today as a whole day
42
+ time_frame = (DateTime.now + 1.day).beginning_of_day - time_frame
43
+
44
+ # transform papertrail objects to reify objects
45
+ a = self.versions.map {|v| v.reify }
46
+
47
+ # get rid of nil first version
48
+ a.compact!
49
+
50
+ # add the current object to the array
51
+ a << self
52
+
53
+ # weed out old entries
54
+ a.delete_if {|x| x.rails_updated_at <= time_frame }
55
+
56
+ # sort hash based on key
57
+ a.sort_by!{|x| x.rails_updated_at }
58
+
59
+ # transform reify objects into hash of {date => value}
60
+ a.reduce({}) do |hsh,val|
61
+ hsh[val.rails_updated_at.strftime('%Y-%m-%d')] = val.send(attribute)
62
+ hsh
63
+ end
64
+ end
65
+ end
66
+
39
67
  def timestamp_attributes_for_create
40
68
  super << :rails_created_at
41
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: estore_conventions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Callahan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-01 00:00:00.000000000 Z
11
+ date: 2013-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acts-as-taggable-on
@@ -117,6 +117,7 @@ extra_rdoc_files:
117
117
  - README.rdoc
118
118
  files:
119
119
  - .document
120
+ - .ruby-version
120
121
  - Gemfile
121
122
  - Gemfile.lock
122
123
  - LICENSE.txt