pack_rat 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/pack_rat.rb +36 -4
- data/pack_rat.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/pack_rat.rb
CHANGED
@@ -8,9 +8,7 @@ module PackRat
|
|
8
8
|
cattr_accessor :updated_attribute_name
|
9
9
|
self.updated_attribute_name ||= :updated_at
|
10
10
|
cattr_accessor :file_location
|
11
|
-
|
12
|
-
self.file_location ||= "#{Rails.root}/app/models/#{self.to_s.split('::').join('/').underscore.downcase}.rb" if defined? Rails && self.class != ActiveRecord::Base
|
13
|
-
self.file_digest ||= Digest::MD5.hexdigest(File.read(self.file_location)) if self.file_location
|
11
|
+
self.file_location = file_location_guesser
|
14
12
|
end
|
15
13
|
|
16
14
|
module Cacher
|
@@ -37,7 +35,41 @@ module PackRat
|
|
37
35
|
key << "/#{self.to_s}"
|
38
36
|
end
|
39
37
|
end
|
38
|
+
|
39
|
+
def file_digest
|
40
|
+
if self.file_location
|
41
|
+
begin
|
42
|
+
file = File.read(self.file_location)
|
43
|
+
Digest::MD5.hexdigest(file)
|
44
|
+
rescue
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def file_location_guesser
|
51
|
+
"#{Rails.root}/app/models/#{self.to_s.split('::').join('/').underscore.downcase}.rb" if defined? Rails
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
module ActiveRecordExtension
|
58
|
+
extend ActiveSupport::Concern
|
59
|
+
|
60
|
+
module ClassMethods
|
61
|
+
def inherited(child_class)
|
62
|
+
child_class.send(:include, PackRat::CacheHelper)
|
63
|
+
super
|
64
|
+
end
|
40
65
|
end
|
41
66
|
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
if defined? ActiveRecord::Base
|
71
|
+
ActiveRecord::Base.send(:include, PackRat::ActiveRecordExtension)
|
42
72
|
end
|
43
|
-
|
73
|
+
|
74
|
+
|
75
|
+
|
data/pack_rat.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: pack_rat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brian Goff
|
@@ -124,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
segments:
|
126
126
|
- 0
|
127
|
-
hash:
|
127
|
+
hash: 1465989135589430788
|
128
128
|
none: false
|
129
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
130
|
requirements:
|