vero 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.7.0
2
+
3
+ - **girl_friday has been replaced by sucker_punch**. The most significant
4
+ effect of this change is that Ruby 1.8.7 will no longer be supported.
5
+
1
6
  ## 0.6.0
2
7
 
3
8
  - **All APIs using the `trackable` interface will now pass up an `:id`** (if
@@ -2,9 +2,9 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  vero (0.6.0)
5
- girl_friday (>= 0.11.2)
6
5
  json
7
6
  rest-client
7
+ sucker_punch (~> 1.0)
8
8
 
9
9
  GEM
10
10
  remote: http://rubygems.org/
@@ -38,7 +38,8 @@ GEM
38
38
  multi_json (~> 1.0)
39
39
  arel (3.0.2)
40
40
  builder (3.0.4)
41
- connection_pool (1.1.0)
41
+ celluloid (0.15.2)
42
+ timers (~> 1.1.0)
42
43
  delayed_job (3.0.5)
43
44
  activesupport (~> 3.0)
44
45
  delayed_job_active_record (0.4.4)
@@ -46,9 +47,6 @@ GEM
46
47
  delayed_job (~> 3.0)
47
48
  diff-lcs (1.2.4)
48
49
  erubis (2.7.0)
49
- girl_friday (0.11.2)
50
- connection_pool (~> 1.0)
51
- rubinius-actor
52
50
  hike (1.2.2)
53
51
  i18n (0.6.1)
54
52
  journey (1.0.4)
@@ -61,6 +59,7 @@ GEM
61
59
  mime-types (1.23)
62
60
  mono_logger (1.0.1)
63
61
  multi_json (1.7.2)
62
+ netrc (0.7.7)
64
63
  polyglot (0.3.3)
65
64
  rack (1.4.5)
66
65
  rack-cache (1.2)
@@ -98,8 +97,9 @@ GEM
98
97
  redis-namespace (~> 1.2)
99
98
  sinatra (>= 0.9.2)
100
99
  vegas (~> 0.1.2)
101
- rest-client (1.6.7)
102
- mime-types (>= 1.16)
100
+ rest-client (1.7.2)
101
+ mime-types (>= 1.16, < 3.0)
102
+ netrc (~> 0.7)
103
103
  rspec (2.13.0)
104
104
  rspec-core (~> 2.13.0)
105
105
  rspec-expectations (~> 2.13.0)
@@ -108,9 +108,6 @@ GEM
108
108
  rspec-expectations (2.13.0)
109
109
  diff-lcs (>= 1.1.3, < 2.0)
110
110
  rspec-mocks (2.13.1)
111
- rubinius-actor (0.0.2)
112
- rubinius-core-api
113
- rubinius-core-api (0.0.1)
114
111
  sinatra (1.3.6)
115
112
  rack (~> 1.4)
116
113
  rack-protection (~> 1.3)
@@ -120,8 +117,11 @@ GEM
120
117
  multi_json (~> 1.0)
121
118
  rack (~> 1.0)
122
119
  tilt (~> 1.1, != 1.3.0)
120
+ sucker_punch (1.1)
121
+ celluloid (~> 0.15.2)
123
122
  thor (0.18.1)
124
123
  tilt (1.3.7)
124
+ timers (1.1.0)
125
125
  treetop (1.4.12)
126
126
  polyglot
127
127
  polyglot (>= 0.3.1)
@@ -39,19 +39,20 @@ We recommend that you select one of the supported queue-based alternatives:
39
39
  config.async = :delayed_job # DelayedJob
40
40
  config.async = :resque # Resque (recommended)
41
41
 
42
- **Note:** Background threads are not supported by Ruby 1.8.7 or earlier.
43
- You must explicitly set `config.async` to either `:none`, `:delayed_job` or
44
- `:resque`.
45
-
46
42
  **Note:** If you're using Mongoid with DelayedJob, you must add
47
43
  `gem "delayed_job_mongoid"` to your Gemfile.
48
44
 
49
- Finally, vero will automatically choose whether to send requests to your
45
+ vero will automatically choose whether to send requests to your
50
46
  **development** or **live** environment if you are using Rails 3.x. You can
51
47
  override this in your initializer:
52
48
 
53
49
  config.development_mode = true # or false
54
50
 
51
+ Finally, if you wish to disable vero requests when running your automated tests,
52
+ add the following line to your initializer:
53
+
54
+ config.disabled = Rails.env.test?
55
+
55
56
  ## Setup tracking
56
57
 
57
58
  You will need to define who should be tracked and what information about them
@@ -217,7 +218,7 @@ outlined in Installation. Now you can call the API using the following methods:
217
218
 
218
219
  This gem is distributed under the MIT License.
219
220
 
220
- Copyright (C) 2013 Vero (Invc Me Inc.)
221
+ Copyright (C) 2014 Vero (Invc Me Inc.)
221
222
 
222
223
  Permission is hereby granted, free of charge, to any person obtaining a copy of
223
224
  this software and associated documentation files (the "Software"), to deal in
@@ -1,26 +1,28 @@
1
1
  require 'json'
2
- require 'girl_friday'
2
+ require 'sucker_punch'
3
3
 
4
4
  module Vero
5
- module Senders
6
- class Thread
7
- VERO_SENDER_QUEUE = ::GirlFriday::WorkQueue.new(:vero_queue, :size => 1) do |msg|
8
- api_class = msg[:api_class]
9
- domain = msg[:domain]
10
- options = msg[:options]
5
+ class SuckerPunchWorker
6
+ include SuckerPunch::Job
11
7
 
12
- options_s = JSON.dump(options)
13
- begin
14
- api_class.perform(domain, options)
15
- Vero::App.log(self, "method: #{api_class.name}, options: #{options_s}, response: job performed")
16
- rescue => e
17
- Vero::App.log(self, "method: #{api_class.name}, options: #{options_s}, response: #{e.message}")
18
- end
8
+ def perform(api_class, domain, options)
9
+ new_options = {}
10
+ options.each { |k,v| new_options[k.to_sym] = v }
11
+
12
+ begin
13
+ api_class.new(domain, new_options).perform
14
+ Vero::App.log(self, "method: #{api_class.name}, options: #{options.to_json}, response: job performed")
15
+ rescue => e
16
+ Vero::App.log(self, "method: #{api_class.name}, options: #{options.to_json}, response: #{e.message}")
19
17
  end
18
+ end
19
+ end
20
20
 
21
+ module Senders
22
+ class Thread
21
23
  def call(api_class, domain, options)
22
- !!VERO_SENDER_QUEUE.push(:api_class => api_class, :domain => domain, :options => options)
24
+ Vero::SuckerPunchWorker.new.async.perform(api_class, domain, options)
23
25
  end
24
26
  end
25
27
  end
26
- end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module Vero
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
3
3
  end
@@ -8,21 +8,6 @@ describe Vero::Sender do
8
8
  subject.senders.should be_a(Hash)
9
9
  end
10
10
 
11
- context 'when using Ruby 1.8' do
12
- before do
13
- stub_const('RUBY_VERSION', '1.8.7')
14
- end
15
-
16
- it "should have a default set of senders (true, false, none, thread)" do
17
- subject.senders.should == {
18
- true => Vero::Senders::Invalid,
19
- false => Vero::Senders::Base,
20
- :none => Vero::Senders::Base,
21
- :thread => Vero::Senders::Invalid,
22
- }
23
- end
24
- end
25
-
26
11
  context 'when using Ruby with verion greater than 1.8.7' do
27
12
  before do
28
13
  stub_const('RUBY_VERSION', '1.9.3')
@@ -1,10 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- def vero_context(user, logging = true, async = false)
3
+ def vero_context(user, logging = true, async = false, disabled = true)
4
4
  context = Vero::Context.new(Vero::App.default_context)
5
5
  context.subject = user
6
6
  context.config.logging = logging
7
7
  context.config.async = async
8
+ context.config.disabled = disabled
8
9
 
9
10
  context
10
11
  end
@@ -76,23 +77,17 @@ describe Vero::Trackable do
76
77
  end
77
78
 
78
79
  context 'when set to be async' do
79
- before { @user.stub(:with_vero_context).and_return vero_context(@user, true, true) }
80
-
81
- context 'using Ruby 1.8.7' do
82
- before { stub_const('RUBY_VERSION', '1.8.7') }
83
-
84
- it 'raises an error' do
85
- expect { @user.track!(@request_params[:event_name], @request_params[:data]) }.to raise_error
86
- expect { @user.track!(@request_params[:event_name]) }.to raise_error
87
- end
80
+ before do
81
+ @context = vero_context(@user, true, true)
82
+ @user.stub(:with_vero_context).and_return(@context)
88
83
  end
89
84
 
90
85
  context 'not using Ruby 1.8.7' do
91
86
  before { stub_const('RUBY_VERSION', '1.9.3') }
92
87
 
93
88
  it 'sends' do
94
- @user.track!(@request_params[:event_name], @request_params[:data]).should be_true
95
- @user.track!(@request_params[:event_name]).should be_true
89
+ @user.track!(@request_params[:event_name], @request_params[:data]).should be_nil
90
+ @user.track!(@request_params[:event_name]).should be_nil
96
91
  end
97
92
  end
98
93
  end
@@ -120,23 +115,15 @@ describe Vero::Trackable do
120
115
 
121
116
  context 'when set to use async' do
122
117
  before do
123
- context = vero_context(@user, false, true)
124
- @user.stub(:with_vero_context).and_return(context)
125
- end
126
-
127
- context 'and using Ruby 1.8.7' do
128
- before { stub_const('RUBY_VERSION', '1.8.7') }
129
-
130
- it 'raises an error' do
131
- expect { @user.identify! }.to raise_error
132
- end
118
+ @context = vero_context(@user, false, true)
119
+ @user.stub(:with_vero_context).and_return(@context)
133
120
  end
134
121
 
135
122
  context 'and not using Ruby 1.8.7' do
136
123
  before { stub_const('RUBY_VERSION', '1.9.3') }
137
124
 
138
125
  it 'sends' do
139
- @user.identify!.should be_true
126
+ @user.identify!.should be_nil
140
127
  end
141
128
  end
142
129
  end
@@ -165,19 +152,16 @@ describe Vero::Trackable do
165
152
  end
166
153
 
167
154
  context 'when set to use async' do
168
- let(:my_context) { Vero::Context.new(Vero::App.default_context) }
169
-
170
155
  before do
171
- my_context.subject = @user
172
- my_context.config.async = true
173
-
174
- @user.stub(:with_vero_context).and_return(my_context)
156
+ @context = vero_context(@user, false, true)
157
+ @user.stub(:with_vero_context).and_return(@context)
175
158
  end
176
159
 
177
160
  context 'and using Ruby 1.8.7' do
178
161
  before { stub_const('RUBY_VERSION', '1.8.7') }
179
162
 
180
163
  it 'raises an error' do
164
+ @context.config.disabled = false
181
165
  expect { @user.with_vero_context.update_user! }.to raise_error
182
166
  end
183
167
  end
@@ -186,7 +170,7 @@ describe Vero::Trackable do
186
170
  before { stub_const('RUBY_VERSION', '1.9.3') }
187
171
 
188
172
  it 'sends' do
189
- @user.with_vero_context.update_user!.should be_true
173
+ @user.with_vero_context.update_user!.should be_nil
190
174
  end
191
175
  end
192
176
  end
@@ -224,7 +208,7 @@ describe Vero::Trackable do
224
208
 
225
209
  @user.stub(:with_vero_context).and_return(context)
226
210
 
227
- @user.with_vero_context.update_user_tags!.should be_true
211
+ @user.with_vero_context.update_user_tags!.should be_nil
228
212
  end
229
213
  end
230
214
  end
@@ -252,28 +236,16 @@ describe Vero::Trackable do
252
236
  end
253
237
 
254
238
  context 'when using async' do
255
- let(:my_context) { Vero::Context.new(Vero::App.default_context) }
256
-
257
239
  before do
258
- my_context.subject = @user
259
- my_context.config.async = true
260
-
261
- @user.stub(:with_vero_context).and_return(my_context)
262
- end
263
-
264
- context 'and using Ruby 1.8.7' do
265
- before { stub_const('RUBY_VERSION', '1.8.7') }
266
-
267
- it 'raises an error' do
268
- expect { @user.with_vero_context.unsubscribe! }.to raise_error
269
- end
240
+ @context = vero_context(@user, false, true)
241
+ @user.stub(:with_vero_context).and_return(@context)
270
242
  end
271
243
 
272
244
  context 'and using Ruby 1.9.3' do
273
245
  before { stub_const('RUBY_VERSION', '1.9.3') }
274
246
 
275
247
  it 'sends' do
276
- @user.with_vero_context.unsubscribe!.should be_true
248
+ @user.with_vero_context.unsubscribe!.should be_nil
277
249
  end
278
250
  end
279
251
  end
@@ -342,6 +314,12 @@ describe Vero::Trackable do
342
314
  user = UserWithPrivateExtras.new
343
315
  user.to_vero.should == {:email => 'durkster@gmail.com', :age => 26, :_user_type => "UserWithPrivateExtras"}
344
316
  end
317
+
318
+ it "should allow extras to be provided instead :id or :email" do
319
+ user = UserWithOnlyExtras.new
320
+ user.properties = {:email => user.email}
321
+ user.to_vero.should == {:email => 'durkster@gmail.com', :_user_type => "UserWithOnlyExtras"}
322
+ end
345
323
  end
346
324
 
347
325
  describe :with_vero_context do
@@ -2,6 +2,7 @@ require 'rubygems'
2
2
  require 'bundler/setup'
3
3
  require 'vero'
4
4
  require 'json'
5
+ require 'sucker_punch/testing/inline'
5
6
 
6
7
  Dir[::File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
7
8
 
@@ -14,4 +15,4 @@ def stub_env(new_env, &block)
14
15
  block.call
15
16
  ensure
16
17
  Rails.instance_variable_set("@_env", ActiveSupport::StringInquirer.new(original_env))
17
- end
18
+ end
@@ -91,4 +91,15 @@ class UserWithPrivateExtras
91
91
  def properties
92
92
  {:age => 26}
93
93
  end
94
+ end
95
+
96
+ class UserWithOnlyExtras
97
+ include Vero::Trackable
98
+ trackable({:extras => :properties})
99
+
100
+ attr_accessor :properties
101
+
102
+ def email
103
+ 'durkster@gmail.com'
104
+ end
94
105
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  [:development, 'resque'],
21
21
  [:runtime, 'json'],
22
22
  [:runtime, 'rest-client'],
23
- [:runtime, 'girl_friday', ">= 0.11.2"]
23
+ [:runtime, 'sucker_punch', '~> 1.0']
24
24
  ]
25
25
 
26
26
  s.files = Dir['**/*']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
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: 2014-04-14 00:00:00.000000000 Z
12
+ date: 2014-07-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -124,21 +124,21 @@ dependencies:
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  - !ruby/object:Gem::Dependency
127
- name: girl_friday
127
+ name: sucker_punch
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  none: false
130
130
  requirements:
131
- - - ! '>='
131
+ - - ~>
132
132
  - !ruby/object:Gem::Version
133
- version: 0.11.2
133
+ version: '1.0'
134
134
  type: :runtime
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  none: false
138
138
  requirements:
139
- - - ! '>='
139
+ - - ~>
140
140
  - !ruby/object:Gem::Version
141
- version: 0.11.2
141
+ version: '1.0'
142
142
  description:
143
143
  email: support@getvero.com
144
144
  executables: []