analytics-ruby-mock 0.0.3 → 0.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/lib/analytics_ruby_mock.rb +37 -16
- metadata +2 -2
data/lib/analytics_ruby_mock.rb
CHANGED
@@ -1,59 +1,80 @@
|
|
1
1
|
module AnalyticsRuby
|
2
2
|
module ClassMethods
|
3
|
+
attr_accessor :track_calls, :identify_calls, :alias_calls
|
4
|
+
|
5
|
+
#############################################################
|
6
|
+
# Track #####################################################
|
7
|
+
|
3
8
|
def track(options)
|
4
9
|
debug_message(:track, options)
|
5
10
|
|
6
|
-
initialize if @
|
7
|
-
@
|
11
|
+
initialize if @track_calls.nil?
|
12
|
+
@track_calls << options
|
8
13
|
end
|
9
14
|
|
10
15
|
def track_count
|
11
|
-
initialize if @
|
12
|
-
@
|
16
|
+
initialize if @track_calls.nil?
|
17
|
+
@track_calls.count
|
18
|
+
end
|
19
|
+
|
20
|
+
def track_events
|
21
|
+
@track_calls.collect { |t| t[:event] }
|
13
22
|
end
|
14
23
|
|
24
|
+
#############################################################
|
25
|
+
# Identify ##################################################
|
26
|
+
|
15
27
|
def identify(options)
|
16
28
|
debug_message(:identify, options)
|
17
29
|
|
18
|
-
initialize if @
|
19
|
-
@
|
30
|
+
initialize if @identify_calls.nil?
|
31
|
+
@identify_calls << options
|
20
32
|
end
|
21
33
|
|
22
34
|
def identify_count
|
23
|
-
initialize if @
|
24
|
-
@
|
35
|
+
initialize if @identify_calls.nil?
|
36
|
+
@identify_calls.count
|
25
37
|
end
|
26
38
|
|
39
|
+
#############################################################
|
40
|
+
# Alias #####################################################
|
41
|
+
|
27
42
|
def alias(options)
|
28
43
|
debug_message(:alias, options)
|
29
44
|
|
30
|
-
initialize if @
|
31
|
-
@
|
45
|
+
initialize if @alias_calls.nil?
|
46
|
+
@alias_calls << options
|
32
47
|
end
|
33
48
|
|
34
49
|
def alias_count
|
35
|
-
initialize if @
|
36
|
-
@
|
50
|
+
initialize if @alias_calls.nil?
|
51
|
+
@alias_calls.count
|
37
52
|
end
|
38
53
|
|
54
|
+
#############################################################
|
55
|
+
# Flush #####################################################
|
56
|
+
|
39
57
|
def flush
|
40
58
|
debug_message(:flush)
|
41
59
|
end
|
42
60
|
|
61
|
+
#############################################################
|
62
|
+
# Mock Interface ############################################
|
63
|
+
|
43
64
|
def debug
|
44
65
|
@debug = true
|
45
66
|
end
|
46
67
|
|
47
|
-
def
|
68
|
+
def clear
|
48
69
|
initialize
|
49
70
|
end
|
50
71
|
|
51
72
|
private
|
52
73
|
|
53
74
|
def initialize
|
54
|
-
@
|
55
|
-
@
|
56
|
-
@
|
75
|
+
@track_calls = []
|
76
|
+
@identify_calls = []
|
77
|
+
@alias_calls = []
|
57
78
|
end
|
58
79
|
|
59
80
|
def debug_message(method, options = nil)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: analytics-ruby-mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Capture all calls to segment.io and prevent them from being sent.
|
15
15
|
email: gavin@petrofeed.com
|