protokoll 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/protokoll/auto_increment.rb +9 -27
- data/lib/protokoll/version.rb +1 -1
- data/test/dummy/log/test.log +10565 -0
- data/test/protokoll_test.rb +7 -8
- metadata +6 -6
@@ -63,39 +63,21 @@ module Protokoll
|
|
63
63
|
(pattern =~ /[#]+/ and $&).length
|
64
64
|
end
|
65
65
|
|
66
|
-
def time_outdated?(pattern, record_date)
|
67
|
-
if (pattern.include? "%y") # year
|
68
|
-
return true if Time.now.year > record_date.year
|
69
|
-
end
|
70
|
-
|
71
|
-
if (pattern.include? "%m") # month
|
72
|
-
return true if Time.now.month > record_date.month
|
73
|
-
end
|
74
|
-
|
75
|
-
if (pattern.include? "%d") # day
|
76
|
-
return true if Time.now.day > record_date.day
|
77
|
-
end
|
78
|
-
|
79
|
-
if (pattern.include? "%H") # hour
|
80
|
-
return true if Time.now.hour > record_date.hour
|
81
|
-
end
|
82
|
-
|
83
|
-
if (pattern.include? "%M") # minute
|
84
|
-
return true if Time.now.minute > record_date.min
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
66
|
def outdated?(record)
|
89
67
|
Time.now.strftime(update_event).to_i > record.created_at.strftime(update_event).to_i
|
90
68
|
end
|
91
69
|
|
70
|
+
# BUG 1 : If using %y%m# and only year changes (user stays
|
71
|
+
# more then one year without updating the model) counter doesn't updates!
|
92
72
|
def update_event
|
93
73
|
pattern = options[:pattern]
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
74
|
+
event = String.new
|
75
|
+
|
76
|
+
event += "%Y" if pattern.include? "%y" or pattern.include? "%Y"
|
77
|
+
event += "%m" if pattern.include? "%m"
|
78
|
+
event += "%H" if pattern.include? "%H"
|
79
|
+
event += "%M" if pattern.include? "%M"
|
80
|
+
event
|
99
81
|
end
|
100
82
|
|
101
83
|
end
|
data/lib/protokoll/version.rb
CHANGED