vero 0.0.4 → 0.1.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/Gemfile.lock +15 -0
- data/README.markdown +14 -8
- data/info +10 -0
- data/lib/vero/app.rb +9 -1
- data/lib/vero/config.rb +5 -14
- data/lib/vero/trackable.rb +38 -7
- data/lib/vero/version.rb +1 -1
- data/lib/vero.rb +8 -1
- data/spec/lib/app_spec.rb +14 -2
- data/spec/lib/config_spec.rb +11 -15
- data/spec/lib/trackable_spec.rb +94 -28
- data/spec/support/user_support.rb +28 -0
- data/vero.gemspec +4 -2
- metadata +35 -2
data/Gemfile.lock
CHANGED
@@ -3,6 +3,8 @@ PATH
|
|
3
3
|
specs:
|
4
4
|
vero (0.0.4)
|
5
5
|
delayed_job
|
6
|
+
delayed_job_active_record
|
7
|
+
delayed_job_mongoid
|
6
8
|
rest-client
|
7
9
|
|
8
10
|
GEM
|
@@ -36,6 +38,7 @@ GEM
|
|
36
38
|
i18n (~> 0.6)
|
37
39
|
multi_json (~> 1.0)
|
38
40
|
arel (3.0.2)
|
41
|
+
bson (1.6.4)
|
39
42
|
builder (3.0.0)
|
40
43
|
columnize (0.3.6)
|
41
44
|
debugger (1.1.3)
|
@@ -47,6 +50,12 @@ GEM
|
|
47
50
|
debugger-ruby_core_source (1.1.3)
|
48
51
|
delayed_job (3.0.3)
|
49
52
|
activesupport (~> 3.0)
|
53
|
+
delayed_job_active_record (0.3.2)
|
54
|
+
activerecord (> 2.1.0)
|
55
|
+
delayed_job (~> 3.0.0)
|
56
|
+
delayed_job_mongoid (1.0.8)
|
57
|
+
delayed_job (~> 3.0.0)
|
58
|
+
mongoid (>= 2.0)
|
50
59
|
diff-lcs (1.1.3)
|
51
60
|
erubis (2.7.0)
|
52
61
|
hike (1.2.1)
|
@@ -58,6 +67,12 @@ GEM
|
|
58
67
|
mime-types (~> 1.16)
|
59
68
|
treetop (~> 1.4.8)
|
60
69
|
mime-types (1.18)
|
70
|
+
mongo (1.6.2)
|
71
|
+
bson (~> 1.6.2)
|
72
|
+
mongoid (2.4.11)
|
73
|
+
activemodel (~> 3.1)
|
74
|
+
mongo (<= 1.6.2)
|
75
|
+
tzinfo (~> 0.3.22)
|
61
76
|
multi_json (1.3.6)
|
62
77
|
polyglot (0.3.3)
|
63
78
|
rack (1.4.1)
|
data/README.markdown
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# vero
|
2
2
|
|
3
|
-
vero makes it easy to interact with Vero's REST API from your Rails 3.x app. Vero is a user lifecycle platform that allows you to engage and re-engage your customer base via email, based on the actions they perform in your software.
|
3
|
+
vero makes it easy to interact with Vero's REST API from your Rails 3.x app. Vero is a user lifecycle platform that allows you to engage and re-engage your customer base via email, based on the actions they perform in your software.
|
4
|
+
|
5
|
+
For more information about the platform, [click here](http://getvero.com) to visit Vero.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -12,7 +14,7 @@ Or install the gem:
|
|
12
14
|
|
13
15
|
gem install 'vero'
|
14
16
|
|
15
|
-
Create a [Vero account](http://getvero.com). Create an initializer in your config folder called vero.rb with the following:
|
17
|
+
Create a [Vero account](http://getvero.com). Create an initializer in your config/initializers folder called vero.rb with the following:
|
16
18
|
|
17
19
|
# config/initializers/vero.rb
|
18
20
|
Vero::App.init do |config|
|
@@ -22,6 +24,10 @@ Create a [Vero account](http://getvero.com). Create an initializer in your confi
|
|
22
24
|
|
23
25
|
You will be able to find your API key and secret by logging into Vero and clicking the 'Account' button at the top of the page.
|
24
26
|
|
27
|
+
By default, events are sent asynchronously using DelayedJob. To force all events to be sent synchronously, add the following line to your initializer:
|
28
|
+
|
29
|
+
config.async = false
|
30
|
+
|
25
31
|
## Setup tracking
|
26
32
|
|
27
33
|
You will need to define who should be tracked and what information about them you'd like to send to Vero. In this example we'll track users:
|
@@ -50,21 +56,21 @@ Each symbol passed to trackable should reference either an instance method or an
|
|
50
56
|
end
|
51
57
|
end
|
52
58
|
|
53
|
-
|
54
|
-
|
55
|
-
If the user's email address is stored in a different field, you can do the following:
|
59
|
+
There is one caveat, email (or email_address) is a required field. If the user's email address is stored under a different field, you can do the following:
|
56
60
|
|
57
61
|
# app/models/user.rb
|
58
62
|
class User < ActiveRecord::Base
|
59
63
|
include Vero::Trackable
|
60
64
|
trackable :email
|
61
65
|
|
62
|
-
def email; self.
|
66
|
+
def email; self.primary_contact; end
|
63
67
|
end
|
64
68
|
|
65
69
|
## Sending events
|
66
70
|
|
67
|
-
|
71
|
+
Events can be sent by any model which has been previously marked as trackable.
|
72
|
+
|
73
|
+
To send an event:
|
68
74
|
|
69
75
|
# app/controllers/contests_controller.rb
|
70
76
|
class ContestsController < ActionController::Base
|
@@ -88,7 +94,7 @@ To send an event, call the #track instance method on a model that is trackable.
|
|
88
94
|
end
|
89
95
|
end
|
90
96
|
|
91
|
-
You may want to send additional data about
|
97
|
+
You may want to send additional data about an event:
|
92
98
|
|
93
99
|
# app/controllers/contests_controller.rb
|
94
100
|
class ContestsController < ActionController::Base
|
data/info
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Logfile created on 2012-06-09 15:46:52 -0700 by logger.rb/31641
|
2
|
+
Vero: Error attempting to track event: {:auth_token=>"YWJjZDEyMzQ6ZWZnaDU2Nzg=", :development_mode=>true, :event_name=>"test_event", :identity=>{:email=>"durkster@gmail.com", :age=>20}, :data=>{:test=>1}, :cta=>"test"} error: Connection refused - connect(2)
|
3
|
+
Vero: Error attempting to track event: {:auth_token=>"YWJjZDEyMzQ6ZWZnaDU2Nzg=", :development_mode=>true, :event_name=>"test_event", :identity=>{:email=>"durkster@gmail.com", :age=>20}, :data=>{:test=>1}, :cta=>"test"} error: Connection refused - connect(2)
|
4
|
+
Vero: Error attempting to track event: {:auth_token=>"YWJjZDEyMzQ6ZWZnaDU2Nzg=", :development_mode=>true, :event_name=>"test_event", :identity=>{:email=>"durkster@gmail.com", :age=>20}, :data=>{:test=>1}, :cta=>"test"} error: Connection refused - connect(2)
|
5
|
+
Vero: Error attempting to track event: {:auth_token=>"YWJjZDEyMzQ6ZWZnaDU2Nzg=", :development_mode=>true, :event_name=>"test_event", :identity=>{:email=>"durkster@gmail.com", :age=>20}, :data=>{:test=>1}, :cta=>"test"} error: Connection refused - connect(2)
|
6
|
+
Vero: Error attempting to track event: {:auth_token=>"YWJjZDEyMzQ6ZWZnaDU2Nzg=", :development_mode=>true, :event_name=>"test_event", :identity=>{:email=>"durkster@gmail.com", :age=>20}, :data=>{:test=>1}, :cta=>"test"} error: Connection refused - connect(2)
|
7
|
+
Vero: Error attempting to track event: {:auth_token=>"YWJjZDEyMzQ6ZWZnaDU2Nzg=", :development_mode=>true, :event_name=>"test_event", :identity=>-4237502754608315000, :data=>{:test=>1}, :cta=>"test"} error: Connection refused - connect(2)
|
8
|
+
Vero: Error attempting to track event: {:auth_token=>"YWJjZDEyMzQ6ZWZnaDU2Nzg=", :development_mode=>true, :event_name=>"test_event", :identity=>{:email=>"durkster@gmail.com", :age=>20}, :data=>{:test=>1}, :cta=>"test"} error: Connection refused - connect(2)
|
9
|
+
Vero: Error attempting to track event: {:auth_token=>"YWJjZDEyMzQ6ZWZnaDU2Nzg=", :development_mode=>true, :event_name=>"test_event", :identity=>-2674137733832633223, :data=>{:test=>1}, :cta=>"test"} error: Connection refused - connect(2)
|
10
|
+
Vero: Error attempting to track event: {:auth_token=>"YWJjZDEyMzQ6ZWZnaDU2Nzg=", :development_mode=>true, :event_name=>"test_event", :identity=>{:email=>"durkster@gmail.com", :age=>20}, :data=>{:test=>1}, :cta=>"test"} error: Connection refused - connect(2)
|
data/lib/vero/app.rb
CHANGED
@@ -6,13 +6,21 @@ module Vero
|
|
6
6
|
@@config = Config.new
|
7
7
|
|
8
8
|
if block_given?
|
9
|
-
block.call
|
9
|
+
block.call(self.config)
|
10
10
|
@@config.configured = true
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
def self.reset!
|
15
|
+
@@config = nil
|
16
|
+
end
|
17
|
+
|
14
18
|
def self.config
|
15
19
|
@@config
|
16
20
|
end
|
21
|
+
|
22
|
+
def self.configured?
|
23
|
+
self.config && self.config.configured
|
24
|
+
end
|
17
25
|
end
|
18
26
|
end
|
data/lib/vero/config.rb
CHANGED
@@ -4,17 +4,17 @@ module Vero
|
|
4
4
|
attr_accessor :api_key, :secret, :development_mode, :async, :configured
|
5
5
|
|
6
6
|
def initialize
|
7
|
-
self.configured
|
8
|
-
self.development_mode = Rails.env.
|
9
|
-
self.async
|
7
|
+
self.configured = false
|
8
|
+
self.development_mode = !Rails.env.production?
|
9
|
+
self.async = true
|
10
10
|
end
|
11
11
|
|
12
12
|
def request_params
|
13
13
|
temp = {}
|
14
14
|
|
15
15
|
temp_auth_token = self.auth_token
|
16
|
-
temp[:auth_token]
|
17
|
-
temp[:development_mode] = self.
|
16
|
+
temp[:auth_token] = temp_auth_token unless temp_auth_token.nil?
|
17
|
+
temp[:development_mode] = self.development_mode unless self.development_mode.nil?
|
18
18
|
|
19
19
|
temp
|
20
20
|
end
|
@@ -25,16 +25,7 @@ module Vero
|
|
25
25
|
|
26
26
|
def auth_token
|
27
27
|
return if api_key.blank? || secret.blank?
|
28
|
-
|
29
28
|
Base64::encode64("#{api_key}:#{secret}").gsub(/[\n ]/, '')
|
30
29
|
end
|
31
|
-
|
32
|
-
def development?
|
33
|
-
self.development_mode || !Rails.env.production?
|
34
|
-
end
|
35
|
-
|
36
|
-
def configured?
|
37
|
-
self.configured
|
38
|
-
end
|
39
30
|
end
|
40
31
|
end
|
data/lib/vero/trackable.rb
CHANGED
@@ -4,28 +4,40 @@ require 'vero/jobs/rest_post_job'
|
|
4
4
|
module Vero
|
5
5
|
module Trackable
|
6
6
|
def self.included(base)
|
7
|
-
|
7
|
+
@vero_trackable_map = []
|
8
8
|
base.extend(ClassMethods)
|
9
9
|
end
|
10
10
|
|
11
11
|
module ClassMethods
|
12
12
|
def trackable(*args)
|
13
|
-
|
13
|
+
if @vero_trackable_map.kind_of?(Array)
|
14
|
+
@vero_trackable_map = (@vero_trackable_map << args).flatten
|
15
|
+
else
|
16
|
+
@vero_trackable_map = args
|
17
|
+
end
|
14
18
|
end
|
15
19
|
|
16
20
|
def trackable_map
|
17
|
-
|
21
|
+
@vero_trackable_map
|
22
|
+
end
|
23
|
+
|
24
|
+
def trackable_map_reset!
|
25
|
+
@vero_trackable_map = nil
|
18
26
|
end
|
19
27
|
end
|
20
28
|
|
21
29
|
def to_vero
|
22
|
-
self.class.trackable_map.inject({}) do |hash, symbol|
|
30
|
+
result = self.class.trackable_map.inject({}) do |hash, symbol|
|
23
31
|
hash[symbol] = self.send(symbol)
|
24
32
|
hash
|
25
33
|
end
|
34
|
+
|
35
|
+
result[:email] = result.delete(:email_address) if result.has_key?(:email_address)
|
36
|
+
result
|
26
37
|
end
|
27
38
|
|
28
39
|
def track(event_name, event_data = {}, cta = '')
|
40
|
+
validate_configured!
|
29
41
|
validate_track_params!(event_name, event_data, cta)
|
30
42
|
|
31
43
|
config = Vero::App.config
|
@@ -38,16 +50,35 @@ module Vero
|
|
38
50
|
|
39
51
|
private
|
40
52
|
def post_now(url, params)
|
41
|
-
|
42
|
-
|
53
|
+
begin
|
54
|
+
job = Vero::Jobs::RestPostJob.new(url, params)
|
55
|
+
job.perform
|
56
|
+
rescue => e
|
57
|
+
Rails.logger.info "Vero: Error attempting to track event: #{params.to_s} error: #{e.message}"
|
58
|
+
end
|
43
59
|
end
|
44
60
|
|
45
61
|
def post_later(url, params)
|
46
62
|
job = Vero::Jobs::RestPostJob.new(url, params)
|
47
|
-
|
63
|
+
|
64
|
+
begin
|
65
|
+
::Delayed::Job.enqueue job
|
66
|
+
rescue ActiveRecord::StatementInvalid => e
|
67
|
+
if e.message == "Could not find table 'delayed_jobs'"
|
68
|
+
raise "To send ratings asynchronously, you must configure delayed_job. Run `rails generate delayed_job:active_record` then `rake db:migrate`."
|
69
|
+
else
|
70
|
+
raise e
|
71
|
+
end
|
72
|
+
end
|
48
73
|
'success'
|
49
74
|
end
|
50
75
|
|
76
|
+
def validate_configured!
|
77
|
+
unless Vero::App.configured?
|
78
|
+
raise "You must configure the 'vero' gem. Visit https://bitbucket.org/semblance/vero/overview for more details."
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
51
82
|
def validate_track_params!(event_name, event_data, cta)
|
52
83
|
result = true
|
53
84
|
|
data/lib/vero/version.rb
CHANGED
data/lib/vero.rb
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
require 'rails'
|
2
2
|
|
3
3
|
module Vero
|
4
|
-
autoload :Session, 'vero/session'
|
5
4
|
autoload :Config, 'vero/config'
|
6
5
|
autoload :App, 'vero/app'
|
7
6
|
autoload :Trackable, 'vero/trackable'
|
7
|
+
end
|
8
|
+
|
9
|
+
if defined? ActiveRecord
|
10
|
+
require 'delayed_job_active_record'
|
11
|
+
end
|
12
|
+
|
13
|
+
if defined? Mongoid
|
14
|
+
require 'delayed_job_mongoid'
|
8
15
|
end
|
data/spec/lib/app_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Vero::App do
|
4
|
-
describe
|
4
|
+
describe :init do
|
5
5
|
it "should create a Config object" do
|
6
6
|
Vero::App.config.should be_nil
|
7
7
|
Vero::App.init {}
|
@@ -10,7 +10,7 @@ describe Vero::App do
|
|
10
10
|
|
11
11
|
it "should ignore configuring the config if no block is provided" do
|
12
12
|
Vero::App.init
|
13
|
-
Vero::App.
|
13
|
+
Vero::App.configured?.should be_false
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should pass configuration defined in the block to the config file" do
|
@@ -22,5 +22,17 @@ describe Vero::App do
|
|
22
22
|
end
|
23
23
|
Vero::App.config.api_key.should == "abcd1234"
|
24
24
|
end
|
25
|
+
|
26
|
+
it "should init should be able to set async" do
|
27
|
+
Vero::App.init do |c|
|
28
|
+
c.async = false
|
29
|
+
end
|
30
|
+
Vero::App.config.async.should be_false
|
31
|
+
|
32
|
+
Vero::App.init do |c|
|
33
|
+
c.async = true
|
34
|
+
end
|
35
|
+
Vero::App.config.async.should be_true
|
36
|
+
end
|
25
37
|
end
|
26
38
|
end
|
data/spec/lib/config_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe Vero::Config do
|
|
9
9
|
@config.async.should be_true
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe :auth_token do
|
13
13
|
it "should return nil if either api_key or secret are not set" do
|
14
14
|
@config.api_key = nil
|
15
15
|
@config.secret = "abcd"
|
@@ -31,7 +31,7 @@ describe Vero::Config do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe
|
34
|
+
describe :request_params do
|
35
35
|
it "should return a hash of auth_token and development_mode if they are set" do
|
36
36
|
@config.api_key = nil
|
37
37
|
@config.secret = nil
|
@@ -47,7 +47,7 @@ describe Vero::Config do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
describe
|
50
|
+
describe :domain do
|
51
51
|
it "should return www.getvero.com when not set" do
|
52
52
|
@config.domain.should == 'www.getvero.com'
|
53
53
|
@config.domain = 'blah.com'
|
@@ -60,25 +60,21 @@ describe Vero::Config do
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
describe
|
64
|
-
it "should return
|
65
|
-
@config.development_mode = true
|
66
|
-
@config.development?.should be_true
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should return true when development_mode is false but Rails.env is either development or test" do
|
70
|
-
@config.development_mode = false
|
71
|
-
|
63
|
+
describe :development_mode do
|
64
|
+
it "by default it should return true when Rails.env is either development or test" do
|
72
65
|
stub_env('development') {
|
73
|
-
|
66
|
+
config = Vero::Config.new
|
67
|
+
config.development_mode.should be_true
|
74
68
|
}
|
75
69
|
|
76
70
|
stub_env('test') {
|
77
|
-
|
71
|
+
config = Vero::Config.new
|
72
|
+
config.development_mode.should be_true
|
78
73
|
}
|
79
74
|
|
80
75
|
stub_env('production') {
|
81
|
-
|
76
|
+
config = Vero::Config.new
|
77
|
+
config.development_mode.should be_false
|
82
78
|
}
|
83
79
|
end
|
84
80
|
end
|
data/spec/lib/trackable_spec.rb
CHANGED
@@ -1,17 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Vero::Trackable do
|
4
|
-
|
5
|
-
Vero::App.init do |c|
|
6
|
-
c.api_key = 'abcd1234'
|
7
|
-
c.secret = 'efgh5678'
|
8
|
-
c.async = false
|
9
|
-
end
|
10
|
-
@user = User.new
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#track" do
|
4
|
+
context "the gem has not been configured" do
|
14
5
|
before :each do
|
6
|
+
Vero::App.reset!
|
15
7
|
@request_params = {
|
16
8
|
event_name: 'test_event',
|
17
9
|
auth_token: 'YWJjZDEyMzQ6ZWZnaDU2Nzg=',
|
@@ -21,31 +13,105 @@ describe Vero::Trackable do
|
|
21
13
|
development_mode: true
|
22
14
|
}
|
23
15
|
@url = "http://www.getvero.com/api/v1/track.json"
|
16
|
+
@user = User.new
|
17
|
+
end
|
18
|
+
|
19
|
+
describe :track do
|
20
|
+
it "should raise an error" do
|
21
|
+
@user.stub(:post_later).and_return('success')
|
22
|
+
expect { @user.track(@request_params[:event_name], @request_params[:data], 'test') }.to raise_error
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "the gem has been configured" do
|
28
|
+
before :each do
|
29
|
+
Vero::App.init do |c|
|
30
|
+
c.api_key = 'abcd1234'
|
31
|
+
c.secret = 'efgh5678'
|
32
|
+
c.async = false
|
33
|
+
end
|
34
|
+
@user = User.new
|
24
35
|
end
|
25
36
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
37
|
+
describe :track do
|
38
|
+
before :each do
|
39
|
+
@request_params = {
|
40
|
+
event_name: 'test_event',
|
41
|
+
auth_token: 'YWJjZDEyMzQ6ZWZnaDU2Nzg=',
|
42
|
+
identity: {email: 'durkster@gmail.com', age: 20},
|
43
|
+
data: { test: 1 },
|
44
|
+
cta: 'test',
|
45
|
+
development_mode: true
|
46
|
+
}
|
47
|
+
@url = "http://www.getvero.com/api/v1/track.json"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should not send a track request when the required parameters are invalid" do
|
51
|
+
@user.stub(:post_now).and_return(200)
|
52
|
+
|
53
|
+
expect { @user.track(nil) }.to raise_error
|
54
|
+
expect { @user.track('') }.to raise_error
|
55
|
+
expect { @user.track('test', '') }.to raise_error
|
56
|
+
expect { @user.track('test', {}, 8) }.to raise_error
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should send a track request when async is set to false" do
|
60
|
+
@user.stub(:post_now).and_return(200)
|
61
|
+
@user.should_receive(:post_now).with(@url, @request_params).at_least(:once)
|
62
|
+
@user.track(@request_params[:event_name], @request_params[:data], 'test').should == 200
|
63
|
+
@user.track(@request_params[:event_name]).should == 200
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should create a delayed job when async is set to true" do
|
67
|
+
@user.stub(:post_later).and_return('success')
|
68
|
+
@user.should_receive(:post_later).with(@url, @request_params).at_least(:once)
|
69
|
+
|
70
|
+
Vero::App.config.async = true
|
71
|
+
@user.track(@request_params[:event_name], @request_params[:data], 'test').should == 'success'
|
72
|
+
@user.track(@request_params[:event_name]).should == 'success'
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should not raise an error when async is set to false and the request times out" do
|
76
|
+
Vero::App.config.async = false
|
77
|
+
Vero::App.config.domain = "localhost"
|
78
|
+
Rails.stub(:logger).and_return(Logger.new('info'))
|
79
|
+
|
80
|
+
expect { @user.track(@request_params[:event_name], @request_params[:data], 'test') }.to_not raise_error
|
81
|
+
end
|
31
82
|
end
|
32
83
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
84
|
+
describe :trackable do
|
85
|
+
after :each do
|
86
|
+
User.trackable_map_reset!
|
87
|
+
User.trackable :email, :age
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should build an array of trackable params" do
|
91
|
+
User.trackable_map_reset!
|
92
|
+
User.trackable :email, :age
|
93
|
+
User.trackable_map.should == [:email, :age]
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should append new trackable items to an existing trackable map" do
|
97
|
+
User.trackable_map_reset!
|
98
|
+
User.trackable :email, :age
|
99
|
+
User.trackable :hair_colour
|
100
|
+
User.trackable_map.should == [:email, :age, :hair_colour]
|
101
|
+
end
|
40
102
|
end
|
41
103
|
|
42
|
-
|
43
|
-
|
104
|
+
describe :to_vero do
|
105
|
+
it "should return a hash of all values mapped by trackable" do
|
106
|
+
user = User.new
|
107
|
+
user.to_vero.should == {email: 'durkster@gmail.com', age: 20}
|
108
|
+
|
109
|
+
user = UserWithoutEmail.new
|
110
|
+
user.to_vero.should == {email: 'durkster@gmail.com', age: 20}
|
44
111
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
expect { @user.track('test', {}, 8) }.to raise_error
|
112
|
+
user = UserWithEmailAddress.new
|
113
|
+
user.to_vero.should == {email: 'durkster@gmail.com', age: 20}
|
114
|
+
end
|
49
115
|
end
|
50
116
|
end
|
51
117
|
end
|
@@ -8,6 +8,34 @@ class User
|
|
8
8
|
'durkster@gmail.com'
|
9
9
|
end
|
10
10
|
|
11
|
+
def age
|
12
|
+
20
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class UserWithoutEmail
|
17
|
+
include Vero::Trackable
|
18
|
+
trackable :email, :age
|
19
|
+
|
20
|
+
def email; self.primary_contact; end
|
21
|
+
|
22
|
+
def primary_contact
|
23
|
+
'durkster@gmail.com'
|
24
|
+
end
|
25
|
+
|
26
|
+
def age
|
27
|
+
20
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class UserWithEmailAddress
|
32
|
+
include Vero::Trackable
|
33
|
+
trackable :email_address, :age
|
34
|
+
|
35
|
+
def email_address
|
36
|
+
'durkster@gmail.com'
|
37
|
+
end
|
38
|
+
|
11
39
|
def age
|
12
40
|
20
|
13
41
|
end
|
data/vero.gemspec
CHANGED
@@ -6,7 +6,7 @@ require "vero/version"
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "vero"
|
8
8
|
s.version = Vero::VERSION.dup
|
9
|
-
s.date = "2012-06-
|
9
|
+
s.date = "2012-06-09"
|
10
10
|
s.summary = "Rails 3.x gem for Vero"
|
11
11
|
s.email = "support@getvero.com"
|
12
12
|
s.homepage = "http://getvero.com/"
|
@@ -14,7 +14,9 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
dependencies = [
|
16
16
|
[:runtime, 'rest-client'],
|
17
|
-
[:runtime, 'delayed_job']
|
17
|
+
[:runtime, 'delayed_job'],
|
18
|
+
[:runtime, 'delayed_job_active_record'],
|
19
|
+
[:runtime, 'delayed_job_mongoid']
|
18
20
|
]
|
19
21
|
|
20
22
|
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.0
|
4
|
+
version: 0.1.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: 2012-06-
|
12
|
+
date: 2012-06-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -43,6 +43,38 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: delayed_job_active_record
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: delayed_job_mongoid
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
46
78
|
description:
|
47
79
|
email: support@getvero.com
|
48
80
|
executables: []
|
@@ -51,6 +83,7 @@ extra_rdoc_files: []
|
|
51
83
|
files:
|
52
84
|
- Gemfile
|
53
85
|
- Gemfile.lock
|
86
|
+
- info
|
54
87
|
- lib/vero/app.rb
|
55
88
|
- lib/vero/config.rb
|
56
89
|
- lib/vero/jobs/rest_post_job.rb
|