trackoid 0.3.0 → 0.3.1
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 +14 -0
- data/VERSION +1 -1
- data/lib/trackoid/reader_extender.rb +11 -7
- data/spec/reader_extender_spec.rb +19 -0
- data/trackoid.gemspec +2 -2
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -315,9 +315,23 @@ 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.1 - Implemented 'to_f' into ReaderExtender to be compatible with
|
319
|
+
ActionView::Template
|
320
|
+
Using "%.1f" % number gave "Can't convert to float"
|
321
|
+
|
322
|
+
- Renamed the internal field of ReaderExtender to "total" so that
|
323
|
+
converting to json automatically gives you:
|
324
|
+
|
325
|
+
{
|
326
|
+
"total": <total value>
|
327
|
+
"hours": [<hours array>]
|
328
|
+
}
|
329
|
+
|
318
330
|
0.3.0 - Biggest change ever. Read <b>Changes for TZ support</b> above.
|
319
331
|
<b>YOU WILL NEED A MIGRATION FOR EXISTING DATA</b>
|
320
332
|
|
333
|
+
------
|
334
|
+
|
321
335
|
0.2.0 - Added 'reset' and 'erase' methods to tracker fields:
|
322
336
|
* Reset does the same as "set" but also sets aggregate fields.
|
323
337
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
@@ -20,7 +20,7 @@ module Mongoid #:nodoc:
|
|
20
20
|
#
|
21
21
|
class ReaderExtender
|
22
22
|
def initialize(number, hours)
|
23
|
-
@
|
23
|
+
@total = number
|
24
24
|
@hours = hours
|
25
25
|
end
|
26
26
|
|
@@ -29,21 +29,25 @@ module Mongoid #:nodoc:
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def to_s
|
32
|
-
@
|
32
|
+
@total.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_f
|
36
|
+
@total.to_f
|
33
37
|
end
|
34
38
|
|
35
39
|
def ==(other)
|
36
|
-
@
|
40
|
+
@total == other
|
37
41
|
end
|
38
42
|
|
39
43
|
def <=>(other)
|
40
|
-
@
|
44
|
+
@total <=> other
|
41
45
|
end
|
42
46
|
|
43
47
|
def +(other)
|
44
|
-
return @
|
48
|
+
return @total + other unless other.is_a?(ReaderExtender)
|
45
49
|
|
46
|
-
@
|
50
|
+
@total = @total + other
|
47
51
|
@hours = @hours.zip(other.hourly).map!(&:sum)
|
48
52
|
self
|
49
53
|
end
|
@@ -55,7 +59,7 @@ module Mongoid #:nodoc:
|
|
55
59
|
# to the underliying FixNum
|
56
60
|
#
|
57
61
|
def method_missing(name, *args, &blk)
|
58
|
-
ret = @
|
62
|
+
ret = @total.send(name, *args, &blk)
|
59
63
|
ret.is_a?(Numeric) ? ReaderExtender.new(ret, @hours) : ret
|
60
64
|
end
|
61
65
|
end
|
@@ -8,6 +8,25 @@ describe Mongoid::Tracking::ReaderExtender do
|
|
8
8
|
(num * 10).should == 50
|
9
9
|
end
|
10
10
|
|
11
|
+
it "should behave like a float" do
|
12
|
+
num = Mongoid::Tracking::ReaderExtender.new(5, [])
|
13
|
+
num.should == 5.0
|
14
|
+
num.should < 10.0
|
15
|
+
(num * 10.0).should == 50.0
|
16
|
+
end
|
17
|
+
|
18
|
+
it "to_f should return a Float (for ActionView::Template compat.)" do
|
19
|
+
num = Mongoid::Tracking::ReaderExtender.new(5, [])
|
20
|
+
num.to_f.should == 5.0
|
21
|
+
num.to_f.should be_kind_of(Float)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "as_json should return a 'total' and a 'hours' member" do
|
25
|
+
json = Mongoid::Tracking::ReaderExtender.new(5, []).as_json
|
26
|
+
json.should have_key("total")
|
27
|
+
json.should have_key("hours")
|
28
|
+
end
|
29
|
+
|
11
30
|
it "should be able to add additional data to it" do
|
12
31
|
num = Mongoid::Tracking::ReaderExtender.new(5, [1, 2, 3, 4])
|
13
32
|
num.hourly.should == [1, 2, 3, 4]
|
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.
|
8
|
+
s.version = "0.3.1"
|
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-
|
12
|
+
s.date = %q{2011-04-16}
|
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
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 1
|
9
|
+
version: 0.3.1
|
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-
|
17
|
+
date: 2011-04-16 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|