esilverberg-google_otg 1.0.2 → 1.0.4
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.
- data/VERSION +1 -1
- data/google_otg.gemspec +2 -2
- data/lib/google_otg.rb +6 -5
- metadata +2 -2
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.4
|
data/google_otg.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{google_otg}
|
|
8
|
-
s.version = "1.0.
|
|
8
|
+
s.version = "1.0.4"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["esilverberg"]
|
|
12
|
-
s.date = %q{2009-09-
|
|
12
|
+
s.date = %q{2009-09-25}
|
|
13
13
|
s.description = %q{Include Google's Over Time Graph in your app}
|
|
14
14
|
s.email = %q{eric@ericsilverberg.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/google_otg.rb
CHANGED
|
@@ -127,13 +127,14 @@ eos
|
|
|
127
127
|
end
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
tz = args.has_key?(:time_zone) ? args[:time_zone] : ActiveSupport::TimeZone['UTC']
|
|
131
|
+
Time.zone = tz
|
|
130
132
|
label = args.has_key?(:label) ? args[:label] : "Value"
|
|
131
133
|
time_fn = args.has_key?(:time_fn) ? args[:time_fn] : lambda {|h| h.created_at }
|
|
132
134
|
range = args.has_key?(:range) ? args[:range] : DEFAULT_RANGE
|
|
133
135
|
x_label_format = args.has_key?(:x_label_format) ? args[:x_label_format] : "%A %I:%M%p"
|
|
134
136
|
|
|
135
137
|
max_y = 0
|
|
136
|
-
tz = args.has_key?(:time_zone) ? args[:time_zone] : ActiveSupport::TimeZone['UTC']
|
|
137
138
|
hits_dict = {}
|
|
138
139
|
hits.each { |h|
|
|
139
140
|
hits_dict[time_fn.call(h)] = h
|
|
@@ -142,15 +143,15 @@ eos
|
|
|
142
143
|
total = 0
|
|
143
144
|
|
|
144
145
|
points = []
|
|
145
|
-
now_floored = Time.at((Time.now.to_i/(60*range))*(60*range))
|
|
146
|
+
now_floored = Time.at((Time.now.to_i/(60*range))*(60*range))
|
|
146
147
|
current = hits.length > 0 ? time_fn.call(hits[0]) : now_floored
|
|
147
148
|
|
|
148
|
-
while (current <= now_floored
|
|
149
|
+
while (current <= now_floored && range > 0) do
|
|
149
150
|
if hits_dict[current]
|
|
150
151
|
count = hits_dict[current].count.to_i
|
|
151
152
|
max_y = count if count > max_y
|
|
152
153
|
|
|
153
|
-
date =
|
|
154
|
+
date = time_fn.call(hits_dict[current])
|
|
154
155
|
date_key = date.to_i
|
|
155
156
|
date_value = date.strftime(x_label_format)
|
|
156
157
|
|
|
@@ -158,7 +159,7 @@ eos
|
|
|
158
159
|
total += count
|
|
159
160
|
else
|
|
160
161
|
|
|
161
|
-
date =
|
|
162
|
+
date = current
|
|
162
163
|
date_key = date.to_i
|
|
163
164
|
date_value = date.strftime(x_label_format)
|
|
164
165
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: esilverberg-google_otg
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- esilverberg
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-09-
|
|
12
|
+
date: 2009-09-25 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|