vero 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +15 -1
  3. data/Gemfile.lock +95 -73
  4. data/README.markdown +145 -121
  5. data/lib/generators/vero_generator.rb +18 -19
  6. data/lib/vero.rb +7 -3
  7. data/lib/vero/api.rb +14 -4
  8. data/lib/vero/api/base_api.rb +11 -10
  9. data/lib/vero/api/events/track_api.rb +5 -3
  10. data/lib/vero/api/users/delete_api.rb +21 -0
  11. data/lib/vero/api/users/edit_api.rb +5 -3
  12. data/lib/vero/api/users/edit_tags_api.rb +7 -5
  13. data/lib/vero/api/users/reidentify_api.rb +5 -3
  14. data/lib/vero/api/users/resubscribe_api.rb +3 -1
  15. data/lib/vero/api/users/track_api.rb +5 -3
  16. data/lib/vero/api/users/unsubscribe_api.rb +3 -1
  17. data/lib/vero/app.rb +4 -2
  18. data/lib/vero/config.rb +11 -8
  19. data/lib/vero/context.rb +9 -11
  20. data/lib/vero/context/api.rb +9 -7
  21. data/lib/vero/dsl.rb +3 -1
  22. data/lib/vero/railtie.rb +5 -3
  23. data/lib/vero/sender.rb +12 -31
  24. data/lib/vero/senders/base.rb +3 -1
  25. data/lib/vero/senders/delayed_job.rb +7 -7
  26. data/lib/vero/senders/invalid.rb +5 -3
  27. data/lib/vero/senders/resque.rb +8 -8
  28. data/lib/vero/senders/sidekiq.rb +3 -1
  29. data/lib/vero/senders/{thread.rb → sucker_punch.rb} +5 -3
  30. data/lib/vero/trackable.rb +4 -2
  31. data/lib/vero/trackable/base.rb +10 -9
  32. data/lib/vero/trackable/interface.rb +3 -1
  33. data/lib/vero/utility/ext.rb +3 -1
  34. data/lib/vero/utility/logger.rb +4 -6
  35. data/lib/vero/version.rb +3 -1
  36. data/lib/vero/view_helpers/javascript.rb +20 -20
  37. data/spec/lib/api/base_api_spec.rb +10 -8
  38. data/spec/lib/api/events/track_api_spec.rb +23 -21
  39. data/spec/lib/api/users/delete_api_spec.rb +33 -0
  40. data/spec/lib/api/users/edit_api_spec.rb +12 -10
  41. data/spec/lib/api/users/edit_tags_api_spec.rb +22 -20
  42. data/spec/lib/api/users/reidentify_spec.rb +16 -14
  43. data/spec/lib/api/users/resubscribe_api_spec.rb +16 -10
  44. data/spec/lib/api/users/track_api_spec.rb +21 -19
  45. data/spec/lib/api/users/unsubscribe_api_spec.rb +12 -10
  46. data/spec/lib/api_spec.rb +29 -24
  47. data/spec/lib/app_spec.rb +12 -10
  48. data/spec/lib/config_spec.rb +31 -29
  49. data/spec/lib/context_spec.rb +13 -11
  50. data/spec/lib/dsl_spec.rb +3 -1
  51. data/spec/lib/sender_spec.rb +12 -24
  52. data/spec/lib/senders/sidekiq_spec.rb +16 -9
  53. data/spec/lib/trackable_spec.rb +88 -114
  54. data/spec/lib/view_helpers_spec.rb +12 -8
  55. data/spec/spec_helper.rb +10 -4
  56. data/spec/support/base_config_shared_examples.rb +5 -3
  57. data/spec/support/user_support.rb +15 -7
  58. data/spec/support/vero_user_support.rb +4 -2
  59. data/vero.gemspec +14 -30
  60. metadata +30 -125
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc379e2eaa97b37404afab58dc1a69dee2a4549b
4
- data.tar.gz: aa4f5aefc12a29b4710ec2ba253a437531ef9641
3
+ metadata.gz: 613bdd22722909307a31f9216cadf88cdbab3ef8
4
+ data.tar.gz: 75cf2287ad113db6da85c725ad2e60e4241198bb
5
5
  SHA512:
6
- metadata.gz: 8fea3136272e976ebf31f6703d746dff1e8fcaa85d1161ace2463a31918d0e653a8a5497db2eab7fe573e5f4030c5ef0f946e2dbded9e3217776cab3a06226bf
7
- data.tar.gz: 6afbcb7b24fe63f0264d2e40e3bdaa1528ee8f92540ff9263272f3324b54fabdeb8a3cbf4938e374027f326e2340c0185fbac237681c1616945dc7a56398bfc3
6
+ metadata.gz: c2096897426a341a5eb32081d8a3590341befb1b4d02d9c46898b7945568fe7e0bf47bcacb634c3f4068e4fd4ac2ed06aae2776696a3bc33532e0483a0d7678c
7
+ data.tar.gz: 8c0edb41c39c2ef8a475ffdec1b05012b147f5ad415eb9887b8b8d338a74b2f0bae3edc4e894b2782e80f4ef84a22e19d0b4918809ca48104d55bdc180daca04
data/Gemfile CHANGED
@@ -1,3 +1,17 @@
1
- source "http://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'http://rubygems.org'
2
4
 
3
5
  gemspec
6
+
7
+ group :development, :test do
8
+ gem 'delayed_job', '~> 3.0.0'
9
+ gem 'delayed_job_active_record'
10
+ gem 'rails', '~> 3.0'
11
+ gem 'resque'
12
+ gem 'sidekiq', '~> 3.5.1'
13
+ gem 'sucker_punch', '~> 1.6.0'
14
+ end
15
+
16
+ gem 'rspec', group: :test
17
+ gem 'rubocop', group: :development
@@ -1,20 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vero (0.9.0)
4
+ vero (0.10.0)
5
5
  json
6
6
  rest-client
7
- sucker_punch (~> 1.6.0)
8
7
 
9
8
  GEM
10
9
  remote: http://rubygems.org/
11
10
  specs:
12
- actionmailer (3.2.22)
13
- actionpack (= 3.2.22)
11
+ actionmailer (3.2.22.5)
12
+ actionpack (= 3.2.22.5)
14
13
  mail (~> 2.5.4)
15
- actionpack (3.2.22)
16
- activemodel (= 3.2.22)
17
- activesupport (= 3.2.22)
14
+ actionpack (3.2.22.5)
15
+ activemodel (= 3.2.22.5)
16
+ activesupport (= 3.2.22.5)
18
17
  builder (~> 3.0.0)
19
18
  erubis (~> 2.7.0)
20
19
  journey (~> 1.0.4)
@@ -22,23 +21,24 @@ GEM
22
21
  rack-cache (~> 1.2)
23
22
  rack-test (~> 0.6.1)
24
23
  sprockets (~> 2.2.1)
25
- activemodel (3.2.22)
26
- activesupport (= 3.2.22)
24
+ activemodel (3.2.22.5)
25
+ activesupport (= 3.2.22.5)
27
26
  builder (~> 3.0.0)
28
- activerecord (3.2.22)
29
- activemodel (= 3.2.22)
30
- activesupport (= 3.2.22)
27
+ activerecord (3.2.22.5)
28
+ activemodel (= 3.2.22.5)
29
+ activesupport (= 3.2.22.5)
31
30
  arel (~> 3.0.2)
32
31
  tzinfo (~> 0.3.29)
33
- activeresource (3.2.22)
34
- activemodel (= 3.2.22)
35
- activesupport (= 3.2.22)
36
- activesupport (3.2.22)
32
+ activeresource (3.2.22.5)
33
+ activemodel (= 3.2.22.5)
34
+ activesupport (= 3.2.22.5)
35
+ activesupport (3.2.22.5)
37
36
  i18n (~> 0.6, >= 0.6.4)
38
37
  multi_json (~> 1.0)
39
38
  arel (3.0.3)
39
+ ast (2.4.1)
40
40
  builder (3.0.4)
41
- celluloid (0.17.2)
41
+ celluloid (0.17.4)
42
42
  celluloid-essentials
43
43
  celluloid-extras
44
44
  celluloid-fsm
@@ -53,89 +53,108 @@ GEM
53
53
  timers (>= 4.1.1)
54
54
  celluloid-pool (0.20.5)
55
55
  timers (>= 4.1.1)
56
- celluloid-supervision (0.20.5)
56
+ celluloid-supervision (0.20.6)
57
57
  timers (>= 4.1.1)
58
- connection_pool (2.2.0)
58
+ concurrent-ruby (1.1.7)
59
+ connection_pool (2.2.3)
59
60
  delayed_job (3.0.5)
60
61
  activesupport (~> 3.0)
61
- delayed_job_active_record (4.0.3)
62
- activerecord (>= 3.0, < 5.0)
63
- delayed_job (>= 3.0, < 4.1)
64
- diff-lcs (1.2.5)
65
- domain_name (0.5.25)
62
+ delayed_job_active_record (4.1.4)
63
+ activerecord (>= 3.0, < 6.1)
64
+ delayed_job (>= 3.0, < 5)
65
+ diff-lcs (1.4.4)
66
+ domain_name (0.5.20190701)
66
67
  unf (>= 0.0.5, < 1.0.0)
67
68
  erubis (2.7.0)
68
69
  hike (1.2.3)
69
- hitimes (1.2.3)
70
- hitimes (1.2.3-java)
71
- http-cookie (1.0.2)
70
+ http-accept (1.7.0)
71
+ http-cookie (1.0.3)
72
72
  domain_name (~> 0.5)
73
- i18n (0.7.0)
73
+ i18n (0.9.5)
74
+ concurrent-ruby (~> 1.0)
74
75
  journey (1.0.4)
75
- json (1.8.3)
76
- json (1.8.3-java)
77
- mail (2.5.4)
76
+ json (1.8.6)
77
+ mail (2.5.5)
78
78
  mime-types (~> 1.16)
79
79
  treetop (~> 1.4.8)
80
80
  mime-types (1.25.1)
81
81
  mono_logger (1.1.0)
82
- multi_json (1.11.2)
83
- netrc (0.10.3)
82
+ multi_json (1.15.0)
83
+ netrc (0.11.0)
84
+ parallel (1.19.2)
85
+ parser (2.7.1.4)
86
+ ast (~> 2.4.1)
84
87
  polyglot (0.3.5)
85
88
  rack (1.4.7)
86
- rack-cache (1.2)
89
+ rack-cache (1.12.0)
87
90
  rack (>= 0.4)
88
- rack-protection (1.5.3)
91
+ rack-protection (1.5.5)
89
92
  rack
90
93
  rack-ssl (1.3.4)
91
94
  rack
92
95
  rack-test (0.6.3)
93
96
  rack (>= 1.0)
94
- rails (3.2.22)
95
- actionmailer (= 3.2.22)
96
- actionpack (= 3.2.22)
97
- activerecord (= 3.2.22)
98
- activeresource (= 3.2.22)
99
- activesupport (= 3.2.22)
97
+ rails (3.2.22.5)
98
+ actionmailer (= 3.2.22.5)
99
+ actionpack (= 3.2.22.5)
100
+ activerecord (= 3.2.22.5)
101
+ activeresource (= 3.2.22.5)
102
+ activesupport (= 3.2.22.5)
100
103
  bundler (~> 1.0)
101
- railties (= 3.2.22)
102
- railties (3.2.22)
103
- actionpack (= 3.2.22)
104
- activesupport (= 3.2.22)
104
+ railties (= 3.2.22.5)
105
+ railties (3.2.22.5)
106
+ actionpack (= 3.2.22.5)
107
+ activesupport (= 3.2.22.5)
105
108
  rack-ssl (~> 1.3.2)
106
109
  rake (>= 0.8.7)
107
110
  rdoc (~> 3.4)
108
111
  thor (>= 0.14.6, < 2.0)
109
- rake (10.4.2)
112
+ rainbow (3.0.0)
113
+ rake (13.0.1)
110
114
  rdoc (3.12.2)
111
115
  json (~> 1.4)
112
- redis (3.2.1)
113
- redis-namespace (1.5.2)
114
- redis (~> 3.0, >= 3.0.4)
115
- resque (1.25.2)
116
+ redis (3.3.5)
117
+ redis-namespace (1.8.0)
118
+ redis (>= 3.0.4)
119
+ regexp_parser (1.7.1)
120
+ resque (2.0.0)
116
121
  mono_logger (~> 1.0)
117
122
  multi_json (~> 1.0)
118
- redis-namespace (~> 1.3)
123
+ redis-namespace (~> 1.6)
119
124
  sinatra (>= 0.9.2)
120
125
  vegas (~> 0.1.2)
121
- rest-client (1.8.0)
126
+ rest-client (2.1.0)
127
+ http-accept (>= 1.7.0, < 2.0)
122
128
  http-cookie (>= 1.0.2, < 2.0)
123
- mime-types (>= 1.16, < 3.0)
124
- netrc (~> 0.7)
125
- rspec (3.3.0)
126
- rspec-core (~> 3.3.0)
127
- rspec-expectations (~> 3.3.0)
128
- rspec-mocks (~> 3.3.0)
129
- rspec-core (3.3.2)
130
- rspec-support (~> 3.3.0)
131
- rspec-expectations (3.3.1)
129
+ mime-types (>= 1.16, < 4.0)
130
+ netrc (~> 0.8)
131
+ rexml (3.2.4)
132
+ rspec (3.9.0)
133
+ rspec-core (~> 3.9.0)
134
+ rspec-expectations (~> 3.9.0)
135
+ rspec-mocks (~> 3.9.0)
136
+ rspec-core (3.9.2)
137
+ rspec-support (~> 3.9.3)
138
+ rspec-expectations (3.9.2)
132
139
  diff-lcs (>= 1.2.0, < 2.0)
133
- rspec-support (~> 3.3.0)
134
- rspec-mocks (3.3.2)
140
+ rspec-support (~> 3.9.0)
141
+ rspec-mocks (3.9.1)
135
142
  diff-lcs (>= 1.2.0, < 2.0)
136
- rspec-support (~> 3.3.0)
137
- rspec-support (3.3.0)
138
- sidekiq (3.5.1)
143
+ rspec-support (~> 3.9.0)
144
+ rspec-support (3.9.3)
145
+ rubocop (0.91.0)
146
+ parallel (~> 1.10)
147
+ parser (>= 2.7.1.1)
148
+ rainbow (>= 2.2.2, < 4.0)
149
+ regexp_parser (>= 1.7)
150
+ rexml
151
+ rubocop-ast (>= 0.4.0, < 1.0)
152
+ ruby-progressbar (~> 1.7)
153
+ unicode-display_width (>= 1.4.0, < 2.0)
154
+ rubocop-ast (0.4.1)
155
+ parser (>= 2.7.1.4)
156
+ ruby-progressbar (1.10.1)
157
+ sidekiq (3.5.4)
139
158
  celluloid (~> 0.17.2)
140
159
  connection_pool (~> 2.2, >= 2.2.0)
141
160
  json (~> 1.0)
@@ -152,23 +171,21 @@ GEM
152
171
  tilt (~> 1.1, != 1.3.0)
153
172
  sucker_punch (1.6.0)
154
173
  celluloid (~> 0.17.2)
155
- thor (0.19.1)
174
+ thor (1.0.1)
156
175
  tilt (1.4.1)
157
- timers (4.1.1)
158
- hitimes
176
+ timers (4.3.2)
159
177
  treetop (1.4.15)
160
178
  polyglot
161
179
  polyglot (>= 0.3.1)
162
- tzinfo (0.3.44)
180
+ tzinfo (0.3.57)
163
181
  unf (0.1.4)
164
182
  unf_ext
165
- unf (0.1.4-java)
166
- unf_ext (0.0.7.1)
183
+ unf_ext (0.0.7.7)
184
+ unicode-display_width (1.7.0)
167
185
  vegas (0.1.11)
168
186
  rack (>= 1.0.0)
169
187
 
170
188
  PLATFORMS
171
- java
172
189
  ruby
173
190
 
174
191
  DEPENDENCIES
@@ -177,5 +194,10 @@ DEPENDENCIES
177
194
  rails (~> 3.0)
178
195
  resque
179
196
  rspec
197
+ rubocop
180
198
  sidekiq (~> 3.5.1)
199
+ sucker_punch (~> 1.6.0)
181
200
  vero!
201
+
202
+ BUNDLED WITH
203
+ 1.17.3
@@ -12,38 +12,47 @@ For more information about the platform, [click here](http://getvero.com).
12
12
 
13
13
  Include in your Gemfile:
14
14
 
15
- gem 'vero'
15
+ ```
16
+ gem 'vero'
17
+ ```
16
18
 
17
19
  Or install the gem:
18
20
 
19
- gem install vero
21
+ ```
22
+ gem install vero
23
+ ```
20
24
 
21
25
  Create an initializer in your config/initializers folder called vero.rb with the
22
26
  following:
23
27
 
24
- # config/initializers/vero.rb
25
- Vero::App.init do |config|
26
- if Rails.env.production?
27
- config.api_key = "Your Production API key goes here"
28
- config.secret = "Your Production API secret goes here"
29
- else
30
- config.api_key = "Your Development API key goes here"
31
- config.secret = "Your Development API secret goes here"
32
- end
33
- end
28
+ ```ruby
29
+ # config/initializers/vero.rb
30
+ Vero::App.init do |config|
31
+ if Rails.env.production?
32
+ config.api_key = "Your Production API key goes here"
33
+ config.secret = "Your Production API secret goes here"
34
+ else
35
+ config.api_key = "Your Development API key goes here"
36
+ config.secret = "Your Development API secret goes here"
37
+ end
38
+ end
39
+ ```
34
40
 
35
41
  You will be able to find your API key and secret by logging into Vero
36
42
  ([sign up](http://getvero.com) if you haven't already) and clicking the
37
43
  'Your Account' link at the top of the page then select 'API Keys'.
38
44
 
39
- By default, events are sent asynchronously using a background thread.
40
- We recommend that you select one of the supported queue-based alternatives:
45
+ By default, events are sent synchronously.
46
+ We recommend that you select one of the supported background thread/queue-based alternatives and add their
47
+ respective gem to your Gemfile:
41
48
 
42
- config.async = :none # Synchronously
43
- config.async = :thread # Background thread (default)
44
- config.async = :delayed_job # DelayedJob
45
- config.async = :sidekiq # Sidekiq
46
- config.async = :resque # Resque (recommended)
49
+ ```ruby
50
+ config.async = :none # Synchronously
51
+ config.async = :sucker_punch # SuckerPunch
52
+ config.async = :delayed_job # DelayedJob
53
+ config.async = :sidekiq # Sidekiq
54
+ config.async = :resque # Resque (recommended)
55
+ ```
47
56
 
48
57
  **Note:** If you're using Mongoid with DelayedJob, you must add
49
58
  `gem "delayed_job_mongoid"` to your Gemfile.
@@ -51,7 +60,9 @@ We recommend that you select one of the supported queue-based alternatives:
51
60
  Finally, if you wish to disable Vero requests when running your automated tests,
52
61
  add the following line to your initializer:
53
62
 
54
- config.disabled = Rails.env.test?
63
+ ```ruby
64
+ config.disabled = Rails.env.test?
65
+ ```
55
66
 
56
67
  If you have any additional questions, please contact support@getvero.com.
57
68
 
@@ -60,13 +71,15 @@ If you have any additional questions, please contact support@getvero.com.
60
71
  You will need to define who should be tracked and what information about them
61
72
  you would like sent to Vero. In this example we'll track users:
62
73
 
63
- # app/models/user.rb
64
- class User < ActiveRecord::Base
65
- include Vero::Trackable
66
- trackable :id, :email, :name
74
+ ```ruby
75
+ # app/models/user.rb
76
+ class User < ActiveRecord::Base
77
+ include Vero::Trackable
78
+ trackable :id, :email, :name
67
79
 
68
- ...
69
- end
80
+ # ...
81
+ end
82
+ ```
70
83
 
71
84
  As you can see we're saying that a User is trackable and that we'd like to pass
72
85
  up their user id, email address, and name.
@@ -74,17 +87,19 @@ up their user id, email address, and name.
74
87
  Each symbol passed to trackable should reference either an instance method or
75
88
  field. Therefore it's perfectly legal to do something like:
76
89
 
77
- # app/models/user.rb
78
- class User < ActiveRecord::Base
79
- include Vero::Trackable
80
- trackable :id, :email, :contest_count
90
+ ```ruby
91
+ # app/models/user.rb
92
+ class User < ActiveRecord::Base
93
+ include Vero::Trackable
94
+ trackable :id, :email, :contest_count
81
95
 
82
- has_many :contests
96
+ has_many :contests
83
97
 
84
- def contest_count
85
- self.contests.count
86
- end
87
- end
98
+ def contest_count
99
+ self.contests.count
100
+ end
101
+ end
102
+ ```
88
103
 
89
104
  There is one caveat: you must pass an "id" to the API in order to perform
90
105
  requests. In many cases the user "id" will simply be their email address. The
@@ -94,31 +109,35 @@ the "id".
94
109
  If the user's email address is stored under a different field, you can do the
95
110
  following:
96
111
 
97
- # app/models/user.rb
98
- class User < ActiveRecord::Base
99
- include Vero::Trackable
100
- trackable :id, :email
112
+ ```ruby
113
+ # app/models/user.rb
114
+ class User < ActiveRecord::Base
115
+ include Vero::Trackable
116
+ trackable :id, :email
101
117
 
102
- def email; self.primary_contact; end
103
- end
118
+ def email; self.primary_contact; end
119
+ end
120
+ ```
104
121
 
105
122
  Finally, you can track multiple properties stored in a Hash by doing the
106
123
  following:
107
124
 
108
- # app/models/user.rb
109
- class User < ActiveRecord::Base
110
- include Vero::Trackable
111
- trackable :id, :email, {:extras => :properties}
125
+ ```ruby
126
+ # app/models/user.rb
127
+ class User < ActiveRecord::Base
128
+ include Vero::Trackable
129
+ trackable :id, :email, {:extras => :properties}
112
130
 
113
- def email; self.primary_contact; end
131
+ def email; self.primary_contact; end
114
132
 
115
- def properties
116
- {
117
- :first_name => "James",
118
- :last_name => "Lamont"
119
- }
120
- end
121
- end
133
+ def properties
134
+ {
135
+ :first_name => "James",
136
+ :last_name => "Lamont"
137
+ }
138
+ end
139
+ end
140
+ ```
122
141
 
123
142
  **Note:** You may choose to bypass extending the `User` model by calling the
124
143
  API via [simple DSL](https://github.com/getvero/vero#simple-dsl) found below.
@@ -129,51 +148,54 @@ Events can be sent by any model which has been previously marked as trackable.
129
148
 
130
149
  To send an event:
131
150
 
132
- # app/controllers/contests_controller.rb
133
- class ContestsController < ActionController::Base
134
- before_filter :authenticate_user!
135
- ...
136
-
151
+ ```ruby
152
+ # app/controllers/contests_controller.rb
153
+ class ContestsController < ActionController::Base
154
+ before_filter :authenticate_user!
155
+ # ...
137
156
 
138
- def create
139
- @contest = current_user.contests.build(params[:contest])
157
+ def create
158
+ @contest = current_user.contests.build(params[:contest])
140
159
 
141
- if @contest.save
142
- # Tell Vero that a new contest has been created
143
- current_user.track!('new_contest_created')
160
+ if @contest.save
161
+ # Tell Vero that a new contest has been created
162
+ current_user.track!('new_contest_created')
144
163
 
145
- flash[:notice] = "New contest saved successfully!"
146
- redirect_to contests_path
147
- else
148
- flash[:alert] = "Unable to create your contest. Please review your details and try again."
149
- render 'new'
150
- end
151
- end
164
+ flash[:notice] = "New contest saved successfully!"
165
+ redirect_to contests_path
166
+ else
167
+ flash[:alert] = "Unable to create your contest. Please review your details and try again."
168
+ render 'new'
152
169
  end
170
+ end
171
+ end
172
+ ```
153
173
 
154
174
  You may want to send additional data about an event:
155
175
 
156
- # app/controllers/contests_controller.rb
157
- class ContestsController < ActionController::Base
158
- before_filter :authenticate_user!
159
- ...
176
+ ```ruby
177
+ # app/controllers/contests_controller.rb
178
+ class ContestsController < ActionController::Base
179
+ before_filter :authenticate_user!
180
+ # ...
160
181
 
161
182
 
162
- def create
163
- @contest = current_user.contests.build(params[:contest])
183
+ def create
184
+ @contest = current_user.contests.build(params[:contest])
164
185
 
165
- if @contest.save
166
- # Tell Vero that a new contest has been created, and the id and name
167
- current_user.track!('new_contest_created', {:id => @contest.id, :name => @content.name})
186
+ if @contest.save
187
+ # Tell Vero that a new contest has been created, and the id and name
188
+ current_user.track!('new_contest_created', {:id => @contest.id, :name => @content.name})
168
189
 
169
- flash[:notice] = "New contest saved successfully!"
170
- redirect_to contests_path
171
- else
172
- flash[:alert] = "Unable to create your contest. Please review your details and try again."
173
- render 'new'
174
- end
175
- end
190
+ flash[:notice] = "New contest saved successfully!"
191
+ redirect_to contests_path
192
+ else
193
+ flash[:alert] = "Unable to create your contest. Please review your details and try again."
194
+ render 'new'
176
195
  end
196
+ end
197
+ end
198
+ ```
177
199
 
178
200
  ## Simple DSL
179
201
 
@@ -183,41 +205,43 @@ using a simple DSL (thanks @jherdman) as you would from the Javascript library.
183
205
  First, ensure you've correctly configured the gem following the instructions as
184
206
  outlined in Installation. Now you can call the API using the following methods:
185
207
 
186
- class UsersController < ApplicationController
187
- include Vero::DSL
188
-
189
- def perform_action
190
- # Tracking an event
191
- vero.events.track!({
192
- :event_name => "test_event",
193
- :data => {:date => "2013-02-12 16:17"},
194
- :identity => {:id => 123, :email => "james@getvero.com"}
195
- })
196
- end
197
-
198
- def create
199
- # Identifying a user
200
- vero.users.track!({:id => 123, :data => {}})
201
- end
202
-
203
- def update
204
- # Editing a user
205
- vero.users.edit_user!({:id => 123, :changes => {:age => 25}})
206
-
207
- # Editing a user's tags
208
- vero.users.edit_user_tags!({:id => 123, :add => ["awesome"], :remove => []})
209
-
210
- # Changing a user's id
211
- vero.users.reidentify!({:id => 123, :new_id => "honeybadger@getvero.com"})
212
-
213
- # Resubscribing a user
214
- vero.users.resubscribe!({:id => 123})
215
- end
216
-
217
- def destroy
218
- vero.users.unsubscribe!({:id => 123})
219
- end
220
- end
208
+ ```ruby
209
+ class UsersController < ApplicationController
210
+ include Vero::DSL
211
+
212
+ def perform_action
213
+ # Tracking an event
214
+ vero.events.track!({
215
+ :event_name => "test_event",
216
+ :data => {:date => "2013-02-12 16:17"},
217
+ :identity => {:id => 123, :email => "james@getvero.com"}
218
+ })
219
+ end
220
+
221
+ def create
222
+ # Identifying a user
223
+ vero.users.track!({:id => 123, :data => {}})
224
+ end
225
+
226
+ def update
227
+ # Editing a user
228
+ vero.users.edit_user!({:id => 123, :changes => {:age => 25}})
229
+
230
+ # Editing a user's tags
231
+ vero.users.edit_user_tags!({:id => 123, :add => ["awesome"], :remove => []})
232
+
233
+ # Changing a user's id
234
+ vero.users.reidentify!({:id => 123, :new_id => "honeybadger@getvero.com"})
235
+
236
+ # Resubscribing a user
237
+ vero.users.resubscribe!({:id => 123})
238
+ end
239
+
240
+ def destroy
241
+ vero.users.unsubscribe!({:id => 123})
242
+ end
243
+ end
244
+ ```
221
245
 
222
246
  ## License Information
223
247