analytics-ruby 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +35 -0
- data/History.md +4 -0
- data/lib/analytics-ruby/client.rb +9 -0
- data/lib/analytics-ruby/consumer.rb +3 -0
- data/lib/analytics-ruby/util.rb +13 -0
- data/lib/analytics-ruby/version.rb +1 -1
- data/spec/client_spec.rb +16 -0
- data/spec/consumer_spec.rb +8 -0
- metadata +55 -22
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
analytics-ruby (0.3.2)
|
5
|
+
faraday (>= 0.8, < 0.10)
|
6
|
+
faraday_middleware (>= 0.8, < 0.10)
|
7
|
+
multi_json (~> 1.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
diff-lcs (1.2.4)
|
13
|
+
faraday (0.8.8)
|
14
|
+
multipart-post (~> 1.2.0)
|
15
|
+
faraday_middleware (0.9.0)
|
16
|
+
faraday (>= 0.7.4, < 0.9)
|
17
|
+
multi_json (1.7.7)
|
18
|
+
multipart-post (1.2.0)
|
19
|
+
rake (10.1.0)
|
20
|
+
rspec (2.14.1)
|
21
|
+
rspec-core (~> 2.14.0)
|
22
|
+
rspec-expectations (~> 2.14.0)
|
23
|
+
rspec-mocks (~> 2.14.0)
|
24
|
+
rspec-core (2.14.4)
|
25
|
+
rspec-expectations (2.14.0)
|
26
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
27
|
+
rspec-mocks (2.14.2)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
analytics-ruby!
|
34
|
+
rake
|
35
|
+
rspec
|
data/History.md
CHANGED
@@ -4,6 +4,7 @@ require 'thread'
|
|
4
4
|
require 'analytics-ruby/defaults'
|
5
5
|
require 'analytics-ruby/consumer'
|
6
6
|
require 'analytics-ruby/request'
|
7
|
+
require 'analytics-ruby/util'
|
7
8
|
|
8
9
|
module AnalyticsRuby
|
9
10
|
|
@@ -17,6 +18,8 @@ module AnalyticsRuby
|
|
17
18
|
# :on_error - Proc which handles error calls from the API
|
18
19
|
def initialize(options = {})
|
19
20
|
|
21
|
+
Util.symbolize_keys!(options)
|
22
|
+
|
20
23
|
@queue = Queue.new
|
21
24
|
@secret = options[:secret]
|
22
25
|
@max_queue_size = options[:max_queue_size] || AnalyticsRuby::Defaults::Queue::MAX_SIZE
|
@@ -49,6 +52,8 @@ module AnalyticsRuby
|
|
49
52
|
|
50
53
|
check_secret
|
51
54
|
|
55
|
+
Util.symbolize_keys!(options)
|
56
|
+
|
52
57
|
event = options[:event]
|
53
58
|
user_id = options[:user_id].to_s
|
54
59
|
properties = options[:properties] || {}
|
@@ -85,6 +90,8 @@ module AnalyticsRuby
|
|
85
90
|
|
86
91
|
check_secret
|
87
92
|
|
93
|
+
Util.symbolize_keys!(options)
|
94
|
+
|
88
95
|
user_id = options[:user_id].to_s
|
89
96
|
traits = options[:traits] || {}
|
90
97
|
timestamp = options[:timestamp] || Time.new
|
@@ -115,6 +122,8 @@ module AnalyticsRuby
|
|
115
122
|
|
116
123
|
check_secret
|
117
124
|
|
125
|
+
Util.symbolize_keys!(options)
|
126
|
+
|
118
127
|
from = options[:from].to_s
|
119
128
|
to = options[:to].to_s
|
120
129
|
timestamp = options[:timestamp] || Time.new
|
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
2
|
require 'analytics-ruby/defaults'
|
3
3
|
require 'analytics-ruby/request'
|
4
|
+
require 'analytics-ruby/util'
|
4
5
|
|
5
6
|
module AnalyticsRuby
|
6
7
|
|
@@ -18,6 +19,8 @@ module AnalyticsRuby
|
|
18
19
|
# on_error - Proc of what to do on an error
|
19
20
|
#
|
20
21
|
def initialize(queue, secret, options = {})
|
22
|
+
Util.symbolize_keys!(options)
|
23
|
+
|
21
24
|
@queue = queue
|
22
25
|
@secret = secret
|
23
26
|
@batch_size = options[:batch_size] || AnalyticsRuby::Defaults::Queue::BATCH_SIZE
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Util
|
2
|
+
def self.symbolize_keys(hash)
|
3
|
+
hash.inject({}) { |memo, (k,v)| memo[k.to_sym] = v; memo }
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.symbolize_keys!(hash)
|
7
|
+
hash.replace symbolize_keys(hash)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.stringify_keys(hash)
|
11
|
+
hash.inject({}) { |memo, (k,v)| memo[k.to_s] = v; memo }
|
12
|
+
end
|
13
|
+
end
|
data/spec/client_spec.rb
CHANGED
@@ -13,6 +13,10 @@ describe Analytics::Client do
|
|
13
13
|
it 'should not error if a secret is supplied' do
|
14
14
|
Analytics::Client.new secret: AnalyticsHelpers::SECRET
|
15
15
|
end
|
16
|
+
|
17
|
+
it 'should not error if a secret is supplied as a string' do
|
18
|
+
Analytics::Client.new 'secret' => AnalyticsHelpers::SECRET
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
18
22
|
describe '#track' do
|
@@ -38,6 +42,10 @@ describe Analytics::Client do
|
|
38
42
|
it 'should not error with the required options' do
|
39
43
|
@client.track AnalyticsHelpers::Queued::TRACK
|
40
44
|
end
|
45
|
+
|
46
|
+
it 'should not error when given string keys' do
|
47
|
+
@client.track Util.stringify_keys(AnalyticsHelpers::Queued::TRACK)
|
48
|
+
end
|
41
49
|
end
|
42
50
|
|
43
51
|
|
@@ -54,6 +62,10 @@ describe Analytics::Client do
|
|
54
62
|
it 'should not error with the required options' do
|
55
63
|
@client.identify AnalyticsHelpers::Queued::IDENTIFY
|
56
64
|
end
|
65
|
+
|
66
|
+
it 'should not error with the required options as strings' do
|
67
|
+
@client.identify Util.stringify_keys(AnalyticsHelpers::Queued::IDENTIFY)
|
68
|
+
end
|
57
69
|
end
|
58
70
|
|
59
71
|
describe '#alias' do
|
@@ -72,6 +84,10 @@ describe Analytics::Client do
|
|
72
84
|
it 'should not error with the required options' do
|
73
85
|
@client.alias AnalyticsHelpers::ALIAS
|
74
86
|
end
|
87
|
+
|
88
|
+
it 'should not error with the required options as strings' do
|
89
|
+
@client.alias Util.stringify_keys(AnalyticsHelpers::ALIAS)
|
90
|
+
end
|
75
91
|
end
|
76
92
|
|
77
93
|
describe '#flush' do
|
data/spec/consumer_spec.rb
CHANGED
@@ -4,6 +4,14 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Analytics::Consumer do
|
6
6
|
|
7
|
+
describe "#init" do
|
8
|
+
it 'accepts string keys' do
|
9
|
+
queue = Queue.new
|
10
|
+
consumer = Analytics::Consumer.new(queue, 'secret', 'batch_size' => 100)
|
11
|
+
consumer.instance_variable_get(:@batch_size).should == 100
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
7
15
|
describe '#flush' do
|
8
16
|
|
9
17
|
it 'should not error if the endpoint is unreachable' do
|
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.3.
|
4
|
+
version: 0.3.3
|
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-08-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -24,10 +24,18 @@ dependencies:
|
|
24
24
|
version: '0.10'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.8'
|
33
|
+
- - <
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0.10'
|
28
36
|
- !ruby/object:Gem::Dependency
|
29
37
|
name: faraday_middleware
|
30
|
-
requirement:
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
31
39
|
none: false
|
32
40
|
requirements:
|
33
41
|
- - ! '>='
|
@@ -38,10 +46,18 @@ dependencies:
|
|
38
46
|
version: '0.10'
|
39
47
|
type: :runtime
|
40
48
|
prerelease: false
|
41
|
-
version_requirements:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.8'
|
55
|
+
- - <
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0.10'
|
42
58
|
- !ruby/object:Gem::Dependency
|
43
59
|
name: multi_json
|
44
|
-
requirement:
|
60
|
+
requirement: !ruby/object:Gem::Requirement
|
45
61
|
none: false
|
46
62
|
requirements:
|
47
63
|
- - ~>
|
@@ -49,10 +65,15 @@ dependencies:
|
|
49
65
|
version: '1.0'
|
50
66
|
type: :runtime
|
51
67
|
prerelease: false
|
52
|
-
version_requirements:
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '1.0'
|
53
74
|
- !ruby/object:Gem::Dependency
|
54
75
|
name: rake
|
55
|
-
requirement:
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
56
77
|
none: false
|
57
78
|
requirements:
|
58
79
|
- - ! '>='
|
@@ -60,10 +81,15 @@ dependencies:
|
|
60
81
|
version: '0'
|
61
82
|
type: :development
|
62
83
|
prerelease: false
|
63
|
-
version_requirements:
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
64
90
|
- !ruby/object:Gem::Dependency
|
65
91
|
name: rspec
|
66
|
-
requirement:
|
92
|
+
requirement: !ruby/object:Gem::Requirement
|
67
93
|
none: false
|
68
94
|
requirements:
|
69
95
|
- - ! '>='
|
@@ -71,30 +97,37 @@ dependencies:
|
|
71
97
|
version: '0'
|
72
98
|
type: :development
|
73
99
|
prerelease: false
|
74
|
-
version_requirements:
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
75
106
|
description: The Segment.io ruby analytics library
|
76
107
|
email: friends@segment.io
|
77
108
|
executables: []
|
78
109
|
extensions: []
|
79
110
|
extra_rdoc_files: []
|
80
111
|
files:
|
112
|
+
- analytics-ruby.gemspec
|
81
113
|
- Gemfile
|
82
|
-
-
|
83
|
-
-
|
84
|
-
- lib/analytics-ruby/
|
85
|
-
- lib/analytics-ruby/defaults.rb
|
114
|
+
- Gemfile.lock
|
115
|
+
- History.md
|
116
|
+
- lib/analytics-ruby/client.rb
|
86
117
|
- lib/analytics-ruby/consumer.rb
|
118
|
+
- lib/analytics-ruby/defaults.rb
|
119
|
+
- lib/analytics-ruby/json.rb
|
87
120
|
- lib/analytics-ruby/request.rb
|
121
|
+
- lib/analytics-ruby/response.rb
|
122
|
+
- lib/analytics-ruby/util.rb
|
88
123
|
- lib/analytics-ruby/version.rb
|
89
|
-
- lib/analytics-ruby
|
90
|
-
- lib/analytics-ruby/client.rb
|
91
|
-
- History.md
|
92
|
-
- analytics-ruby.gemspec
|
124
|
+
- lib/analytics-ruby.rb
|
93
125
|
- Rakefile
|
126
|
+
- README.md
|
94
127
|
- spec/client_spec.rb
|
128
|
+
- spec/consumer_spec.rb
|
95
129
|
- spec/module_spec.rb
|
96
130
|
- spec/spec_helper.rb
|
97
|
-
- spec/consumer_spec.rb
|
98
131
|
homepage: https://github.com/segmentio/analytics-ruby
|
99
132
|
licenses: []
|
100
133
|
post_install_message:
|
@@ -115,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
148
|
version: '0'
|
116
149
|
requirements: []
|
117
150
|
rubyforge_project:
|
118
|
-
rubygems_version: 1.8.
|
151
|
+
rubygems_version: 1.8.25
|
119
152
|
signing_key:
|
120
153
|
specification_version: 3
|
121
154
|
summary: Segment.io analytics library
|