trackoid 0.3.3 → 0.3.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/README.rdoc CHANGED
@@ -315,6 +315,8 @@ Trackoid will correctly translate dates for you (hopefully) if you pass a date t
315
315
 
316
316
  = Revision History
317
317
 
318
+ 0.3.4 - Fixed midnight calculation for Time.whole_day
319
+
318
320
  0.3.3 - as_json should take a "options" hash as optional parameter.
319
321
 
320
322
  0.3.2 - ReaderExtender as_json sould not return the full "total" and
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
@@ -37,10 +37,7 @@ class Time
37
37
 
38
38
  # Returns a range to be enumerated using hours for the whole day
39
39
  def whole_day
40
- # We could have used 'beginning_of_day' from ActiveSupport, but don't
41
- # want to introduce a dependency (I've tried to avoid ActiveSupport
42
- # although you will be using it since it's introduced by Mongoid)
43
- midnight = Time.send(utc? ? :utc : :local, year, month, day)
40
+ midnight = utc? ? Time.utc(year, month, day) : Time.new(year, month, day, 0, 0, 0, utc_offset)
44
41
  midnight...(midnight + ::Range::DAYS)
45
42
  end
46
- end
43
+ end
data/spec/readers_spec.rb CHANGED
@@ -25,7 +25,6 @@ describe "Testing Readers with a model" do
25
25
  @mock.visits.on(range).should == [1, 2, 3]
26
26
  end
27
27
 
28
-
29
28
  it "should return the correct values for .all_values" do
30
29
  @mock.visits.set(1, "2010-07-11")
31
30
  @mock.visits.set(2, "2010-07-12")
@@ -42,7 +41,6 @@ describe "Testing Readers with a model" do
42
41
  @mock.visits.last_value.should == 10
43
42
  @mock.visits.first_value.should == 5
44
43
  end
45
-
46
44
  end
47
45
 
48
46
 
@@ -74,4 +72,3 @@ describe "Testing Readers with an empty model" do
74
72
  @mock.visits.all_values.should be_nil
75
73
  end
76
74
  end
77
-
@@ -245,5 +245,46 @@ describe Mongoid::Tracking do
245
245
  visits.last.hourly.should == [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
246
246
  end
247
247
 
248
+ it "A value set at 10am on Madrid should appear as 01am on San Francisco" do
249
+ ENV["TZ"] = "Europe/Madrid"
250
+
251
+ time = Time.parse("2011-04-19 10:00:00")
252
+ @mock.visits.inc(time)
253
+ visits = @mock.visits.on(time)
254
+ visits.hourly.should == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
255
+
256
+ ENV["TZ"] = "America/Los_Angeles"
257
+ time = Time.parse("2011-04-19 01:00:00")
258
+ visits = @mock.visits.on(time)
259
+ visits.hourly.should == [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
260
+ end
261
+
262
+ it "A value set at 10am on Madrid should appear as 01am on San Francisco (Using offsets)" do
263
+ ENV["TZ"] = "Europe/Madrid"
264
+
265
+ time = Time.parse("2011-04-19 10:00:00").getlocal(2.hours)
266
+ @mock.visits.inc(time)
267
+ visits = @mock.visits.on(time)
268
+ visits.hourly.should == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
269
+
270
+ time = Time.parse("2011-04-19 10:00:00").getlocal(-7.hours)
271
+ visits = @mock.visits.on(time)
272
+ visits.hourly.should == [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
273
+ end
274
+
275
+ it "A value set now on Madrid should appear shifted 9 hours on San Francisco (Using offsets)" do
276
+ ENV["TZ"] = "Europe/Madrid"
277
+
278
+ now = Time.now
279
+ time = now.getlocal(2.hours)
280
+ @mock.visits.inc(time)
281
+ visits = @mock.visits.on(time)
282
+ visits.hourly.should == Array.new(24, 0).tap {|a| a[time.hour] = 1}
283
+
284
+ time = now.getlocal(-7.hours)
285
+ visits = @mock.visits.on(time)
286
+ visits.hourly.should == Array.new(24, 0).tap {|a| a[time.hour] = 1}
287
+ end
288
+
248
289
  end
249
290
  end
data/trackoid.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{trackoid}
8
- s.version = "0.3.3"
8
+ s.version = "0.3.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jose Miguel Perez"]
12
- s.date = %q{2011-04-18}
12
+ s.date = %q{2011-04-19}
13
13
  s.description = %q{Trackoid uses an embeddable approach to track analytics data using the poweful features of MongoDB for scalability}
14
14
  s.email = %q{josemiguel@perezruiz.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 3
9
- version: 0.3.3
8
+ - 4
9
+ version: 0.3.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jose Miguel Perez
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-04-18 00:00:00 +02:00
17
+ date: 2011-04-19 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency