analytics-ruby 0.2.0 → 0.3.0
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/History.md +4 -0
- data/lib/analytics-ruby.rb +5 -0
- data/lib/analytics-ruby/client.rb +29 -0
- data/lib/analytics-ruby/version.rb +1 -1
- data/spec/client_spec.rb +18 -0
- data/spec/module_spec.rb +15 -0
- data/spec/spec_helper.rb +3 -0
- metadata +12 -13
- data/analytics-ruby-0.1.4.gem +0 -0
data/History.md
CHANGED
data/lib/analytics-ruby.rb
CHANGED
@@ -102,6 +102,35 @@ module AnalyticsRuby
|
|
102
102
|
action: 'identify' })
|
103
103
|
end
|
104
104
|
|
105
|
+
# public: Aliases a user from one id to another
|
106
|
+
#
|
107
|
+
# options - Hash
|
108
|
+
# :from - String of the id to alias from
|
109
|
+
# :to - String of the id to alias to
|
110
|
+
# :timestamp - Time of when the alias occured (optional)
|
111
|
+
# :context - Hash of context (optional)
|
112
|
+
def alias(options)
|
113
|
+
|
114
|
+
check_secret
|
115
|
+
|
116
|
+
from = options[:from].to_s
|
117
|
+
to = options[:to].to_s
|
118
|
+
timestamp = options[:timestamp] || Time.new
|
119
|
+
context = options[:context] || {}
|
120
|
+
|
121
|
+
ensure_user(from)
|
122
|
+
ensure_user(to)
|
123
|
+
check_timestamp(timestamp)
|
124
|
+
|
125
|
+
add_context(context)
|
126
|
+
|
127
|
+
enqueue({ from: from,
|
128
|
+
to: to,
|
129
|
+
context: context,
|
130
|
+
timestamp: timestamp.iso8601,
|
131
|
+
action: 'alias' })
|
132
|
+
end
|
133
|
+
|
105
134
|
# public: Returns the number of queued messages
|
106
135
|
#
|
107
136
|
# returns Fixnum of messages in the queue
|
data/spec/client_spec.rb
CHANGED
@@ -50,6 +50,24 @@ describe Analytics::Client do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
describe '#alias' do
|
54
|
+
before :all do
|
55
|
+
@client = Analytics::Client.new secret: AnalyticsHelpers::SECRET
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should error without from' do
|
59
|
+
expect { @client.alias to: 1234 }.to raise_error(ArgumentError)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should error without to' do
|
63
|
+
expect { @client.alias from: 1234 }.to raise_error(ArgumentError)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should not error with the required options' do
|
67
|
+
@client.alias AnalyticsHelpers::ALIAS
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
53
71
|
describe '#flush' do
|
54
72
|
before(:all) do
|
55
73
|
@client = Analytics::Client.new secret: AnalyticsHelpers::SECRET
|
data/spec/module_spec.rb
CHANGED
@@ -56,6 +56,21 @@ describe Analytics do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
describe '#alias' do
|
60
|
+
it 'should error without from' do
|
61
|
+
expect { Analytics.alias to: 1234 }.to raise_error(ArgumentError)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should error without to' do
|
65
|
+
expect { Analytics.alias from: 1234 }.to raise_error(ArgumentError)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should not error with the required options' do
|
69
|
+
Analytics.alias AnalyticsHelpers::ALIAS
|
70
|
+
sleep(1)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
59
74
|
describe '#flush' do
|
60
75
|
|
61
76
|
it 'should flush without error' do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: analytics-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
16
|
-
requirement: &
|
16
|
+
requirement: &20475340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -24,10 +24,10 @@ dependencies:
|
|
24
24
|
version: '0.10'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *20475340
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: faraday_middleware
|
30
|
-
requirement: &
|
30
|
+
requirement: &23402460 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ! '>='
|
@@ -38,10 +38,10 @@ dependencies:
|
|
38
38
|
version: '0.10'
|
39
39
|
type: :runtime
|
40
40
|
prerelease: false
|
41
|
-
version_requirements: *
|
41
|
+
version_requirements: *23402460
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: multi_json
|
44
|
-
requirement: &
|
44
|
+
requirement: &23401720 !ruby/object:Gem::Requirement
|
45
45
|
none: false
|
46
46
|
requirements:
|
47
47
|
- - ~>
|
@@ -49,10 +49,10 @@ dependencies:
|
|
49
49
|
version: '1.0'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
|
-
version_requirements: *
|
52
|
+
version_requirements: *23401720
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: rake
|
55
|
-
requirement: &
|
55
|
+
requirement: &23401340 !ruby/object:Gem::Requirement
|
56
56
|
none: false
|
57
57
|
requirements:
|
58
58
|
- - ! '>='
|
@@ -60,10 +60,10 @@ dependencies:
|
|
60
60
|
version: '0'
|
61
61
|
type: :development
|
62
62
|
prerelease: false
|
63
|
-
version_requirements: *
|
63
|
+
version_requirements: *23401340
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
65
|
name: rspec
|
66
|
-
requirement: &
|
66
|
+
requirement: &23400880 !ruby/object:Gem::Requirement
|
67
67
|
none: false
|
68
68
|
requirements:
|
69
69
|
- - ! '>='
|
@@ -71,7 +71,7 @@ dependencies:
|
|
71
71
|
version: '0'
|
72
72
|
type: :development
|
73
73
|
prerelease: false
|
74
|
-
version_requirements: *
|
74
|
+
version_requirements: *23400880
|
75
75
|
description: The Segment.io ruby analytics library
|
76
76
|
email: friends@segment.io
|
77
77
|
executables: []
|
@@ -88,7 +88,6 @@ files:
|
|
88
88
|
- lib/analytics-ruby/version.rb
|
89
89
|
- lib/analytics-ruby/json.rb
|
90
90
|
- lib/analytics-ruby/client.rb
|
91
|
-
- analytics-ruby-0.1.4.gem
|
92
91
|
- History.md
|
93
92
|
- analytics-ruby.gemspec
|
94
93
|
- Rakefile
|
data/analytics-ruby-0.1.4.gem
DELETED
Binary file
|