leadtune 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@ GEM
10
10
  remote: http://rubygems.org/
11
11
  specs:
12
12
  addressable (2.2.1)
13
- columnize (0.3.1)
13
+ columnize (0.3.2)
14
14
  crack (0.1.8)
15
15
  curb (0.7.8)
16
16
  diff-lcs (1.1.2)
@@ -26,10 +26,10 @@ GEM
26
26
  rspec-expectations (2.0.0.beta.19)
27
27
  diff-lcs (>= 1.1.2)
28
28
  rspec-mocks (2.0.0.beta.19)
29
- ruby-debug (0.10.3)
29
+ ruby-debug (0.10.4)
30
30
  columnize (>= 0.1)
31
- ruby-debug-base (~> 0.10.3.0)
32
- ruby-debug-base (0.10.3)
31
+ ruby-debug-base (~> 0.10.4.0)
32
+ ruby-debug-base (0.10.4)
33
33
  linecache (>= 0.3)
34
34
  tcpsocket-wait (1.0.0)
35
35
 
@@ -48,8 +48,8 @@ An attempt was made to allow for an ActiveModel-like interface.
48
48
  :api_key => "DeadB33fDeadB33fDeadB33fDeadB33fDeadB33f", # required (See Leadtune::Config)
49
49
  :organization => "LOL", # required (See Leadtune::Config)
50
50
  :event => "offers_prepared", # required
51
- :email => "test@example.com" # required
52
- :target_buyers => ["TB-LOL", "AcmeU",] # required
51
+ :email => "test@example.com", # required
52
+ :target_buyers => ["TB-LOL", "AcmeU"], # required
53
53
  # ... include optional factors here, see http://leadtune.com/factors for details
54
54
  })
55
55
 
@@ -57,7 +57,7 @@ An attempt was made to allow for an ActiveModel-like interface.
57
57
 
58
58
  prospect = Leadtune::Prospect.post do |p|
59
59
  p.event = "offers_prepared"
60
- p.email = "test@example.com"
60
+ p.email = "test@example.com"
61
61
  ... and so on
62
62
  end
63
63
 
@@ -65,7 +65,7 @@ An attempt was made to allow for an ActiveModel-like interface.
65
65
 
66
66
  prospect = Leadtune::Prospect.new
67
67
  prospect.event = "offers_prepared"
68
- prosepct.email = "test@example.com"
68
+ prospect.email = "test@example.com"
69
69
  ... and so on
70
70
  prospect.post
71
71
 
@@ -7,13 +7,13 @@
7
7
  module Leadtune
8
8
 
9
9
  class Config #:nodoc:all
10
-
11
- attr_accessor :environment, :leadtune_host, :api_key, :timeout
10
+ attr_accessor :environment, :leadtune_host, :api_key, :timeout, :query_params
12
11
 
13
12
  @@leadtune_host = nil
14
13
  @@api_key = nil
15
14
  @@organization = nil
16
15
  @@timeout = nil
16
+ @@query_params = nil
17
17
 
18
18
  def self.api_key=(api_key)
19
19
  @@api_key = api_key
@@ -31,6 +31,10 @@ module Leadtune
31
31
  @@timeout = timeout
32
32
  end
33
33
 
34
+ def self.query_params=(query_params)
35
+ @@query_params = query_params
36
+ end
37
+
34
38
  def api_key
35
39
  @api_key ||= @@api_key
36
40
  end
@@ -39,6 +43,10 @@ module Leadtune
39
43
  @timeout ||= @@timeout || DEFAULT_TIMEOUT
40
44
  end
41
45
 
46
+ def query_params
47
+ @query_params ||= @@query_params
48
+ end
49
+
42
50
  def organization
43
51
  @@organization
44
52
  end
@@ -55,7 +63,7 @@ module Leadtune
55
63
  if ENV.include?("APP_ENV")
56
64
  "production" == ENV["APP_ENV"]
57
65
  else
58
- defined?(Rails) && Rails.env.production? ||
66
+ defined?(Rails) && "production" == Rails.env ||
59
67
  "production" == ENV["RACK_ENV"] ||
60
68
  "production" == ENV["RAILS_ENV"] ||
61
69
  defined?(RAILS_ENV) && "production" == RAILS_ENV
@@ -9,6 +9,7 @@ require "json"
9
9
 
10
10
  module Leadtune
11
11
  class Rest #:nodoc:all
12
+ PROSPECTS_PATH = "/prospects"
12
13
 
13
14
  attr_reader :response
14
15
 
@@ -95,8 +96,16 @@ module Leadtune
95
96
  end
96
97
  end
97
98
 
99
+ def build_optional_query_params
100
+ if @config.query_params
101
+ "?" + Leadtune::Util.to_params(@config.query_params)
102
+ else
103
+ ""
104
+ end
105
+ end
106
+
98
107
  def build_post_url #:nodoc:
99
- URI.join(@config.leadtune_host, "/prospects").to_s
108
+ URI.join(@config.leadtune_host, PROSPECTS_PATH, build_optional_query_params).to_s
100
109
  end
101
110
 
102
111
  def build_get_url #:nodoc:
@@ -110,7 +119,7 @@ module Leadtune
110
119
  end
111
120
 
112
121
  def build_put_url #:nodoc:
113
- path = "/prospects"
122
+ path = PROSPECTS_PATH
114
123
  path += "/#{@post_data["prospect_id"]}" if @post_data["prospect_id"]
115
124
  # I would use URI.join, but there's a bug in its implementation in 1.8.6
116
125
  @config.leadtune_host + path
@@ -5,5 +5,5 @@
5
5
  # Copyright 2010 LeadTune LLC
6
6
 
7
7
  module Leadtune
8
- VERSION = "0.0.8"
8
+ VERSION = "0.0.9"
9
9
  end
@@ -42,5 +42,11 @@ describe Leadtune::Config do
42
42
 
43
43
  Leadtune::Config.new.leadtune_host.should == "http://bad_url_for_test"
44
44
  end
45
+
46
+ it "query_params" do
47
+ Leadtune::Config.query_params = {"foo" => "bar"}
48
+
49
+ Leadtune::Config.new.query_params.should == {"foo" => "bar"}
50
+ end
45
51
  end
46
52
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leadtune
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eric Wollesen
@@ -15,11 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-05 00:00:00 -06:00
18
+ date: 2011-05-23 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
23
  none: false
24
24
  requirements:
25
25
  - - ">="
@@ -30,12 +30,12 @@ dependencies:
30
30
  - 0
31
31
  - 0
32
32
  version: 1.0.0
33
- requirement: *id001
34
33
  type: :development
35
34
  name: bundler
36
35
  prerelease: false
36
+ version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ">="
@@ -44,12 +44,12 @@ dependencies:
44
44
  segments:
45
45
  - 0
46
46
  version: "0"
47
- requirement: *id002
48
47
  type: :development
49
48
  name: ruby-debug
50
49
  prerelease: false
50
+ version_requirements: *id002
51
51
  - !ruby/object:Gem::Dependency
52
- version_requirements: &id003 !ruby/object:Gem::Requirement
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - "="
@@ -62,12 +62,12 @@ dependencies:
62
62
  - beta
63
63
  - 19
64
64
  version: 2.0.0.beta.19
65
- requirement: *id003
66
65
  type: :development
67
66
  name: rspec
68
67
  prerelease: false
68
+ version_requirements: *id003
69
69
  - !ruby/object:Gem::Dependency
70
- version_requirements: &id004 !ruby/object:Gem::Requirement
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
71
  none: false
72
72
  requirements:
73
73
  - - "="
@@ -80,12 +80,12 @@ dependencies:
80
80
  - beta
81
81
  - 19
82
82
  version: 2.0.0.beta.19
83
- requirement: *id004
84
83
  type: :development
85
84
  name: rspec-core
86
85
  prerelease: false
86
+ version_requirements: *id004
87
87
  - !ruby/object:Gem::Dependency
88
- version_requirements: &id005 !ruby/object:Gem::Requirement
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
91
  - - "="
@@ -98,12 +98,12 @@ dependencies:
98
98
  - beta
99
99
  - 19
100
100
  version: 2.0.0.beta.19
101
- requirement: *id005
102
101
  type: :development
103
102
  name: rspec-expectations
104
103
  prerelease: false
104
+ version_requirements: *id005
105
105
  - !ruby/object:Gem::Dependency
106
- version_requirements: &id006 !ruby/object:Gem::Requirement
106
+ requirement: &id006 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
109
109
  - - "="
@@ -116,12 +116,12 @@ dependencies:
116
116
  - beta
117
117
  - 19
118
118
  version: 2.0.0.beta.19
119
- requirement: *id006
120
119
  type: :development
121
120
  name: rspec-mocks
122
121
  prerelease: false
122
+ version_requirements: *id006
123
123
  - !ruby/object:Gem::Dependency
124
- version_requirements: &id007 !ruby/object:Gem::Requirement
124
+ requirement: &id007 !ruby/object:Gem::Requirement
125
125
  none: false
126
126
  requirements:
127
127
  - - ">="
@@ -130,12 +130,12 @@ dependencies:
130
130
  segments:
131
131
  - 0
132
132
  version: "0"
133
- requirement: *id007
134
133
  type: :development
135
134
  name: webmock
136
135
  prerelease: false
136
+ version_requirements: *id007
137
137
  - !ruby/object:Gem::Dependency
138
- version_requirements: &id008 !ruby/object:Gem::Requirement
138
+ requirement: &id008 !ruby/object:Gem::Requirement
139
139
  none: false
140
140
  requirements:
141
141
  - - ">="
@@ -144,12 +144,12 @@ dependencies:
144
144
  segments:
145
145
  - 0
146
146
  version: "0"
147
- requirement: *id008
148
147
  type: :development
149
148
  name: tcpsocket-wait
150
149
  prerelease: false
150
+ version_requirements: *id008
151
151
  - !ruby/object:Gem::Dependency
152
- version_requirements: &id009 !ruby/object:Gem::Requirement
152
+ requirement: &id009 !ruby/object:Gem::Requirement
153
153
  none: false
154
154
  requirements:
155
155
  - - ">="
@@ -158,12 +158,12 @@ dependencies:
158
158
  segments:
159
159
  - 0
160
160
  version: "0"
161
- requirement: *id009
162
161
  type: :runtime
163
162
  name: rake
164
163
  prerelease: false
164
+ version_requirements: *id009
165
165
  - !ruby/object:Gem::Dependency
166
- version_requirements: &id010 !ruby/object:Gem::Requirement
166
+ requirement: &id010 !ruby/object:Gem::Requirement
167
167
  none: false
168
168
  requirements:
169
169
  - - ">="
@@ -172,12 +172,12 @@ dependencies:
172
172
  segments:
173
173
  - 0
174
174
  version: "0"
175
- requirement: *id010
176
175
  type: :runtime
177
176
  name: curb
178
177
  prerelease: false
178
+ version_requirements: *id010
179
179
  - !ruby/object:Gem::Dependency
180
- version_requirements: &id011 !ruby/object:Gem::Requirement
180
+ requirement: &id011 !ruby/object:Gem::Requirement
181
181
  none: false
182
182
  requirements:
183
183
  - - ">="
@@ -186,10 +186,10 @@ dependencies:
186
186
  segments:
187
187
  - 0
188
188
  version: "0"
189
- requirement: *id011
190
189
  type: :runtime
191
190
  name: json
192
191
  prerelease: false
192
+ version_requirements: *id011
193
193
  description: LeadTune Ruby API Gem
194
194
  email:
195
195
  - devs@leadtune.com