leadtune 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,7 +17,7 @@ module Leadtune
17
17
 
18
18
  # Simplify the process of submitting prospects to LeadTune for duplicate
19
19
  # checking and appraisal.
20
- #
20
+ #
21
21
  # For details about the LeadTune API, see: http://leadtune.com/api
22
22
  #
23
23
  # == Dynamic Factor Access
@@ -105,14 +105,14 @@ module Leadtune
105
105
  # The Array returned has been extended to include two methods,
106
106
  # +duplicates+ and +non_duplicates+. Each returns the appraisals of the
107
107
  # target_buyers for whom this lead is or is not a known duplicate.
108
-
108
+
109
109
  def appraisals
110
110
  @decision ||= {}
111
111
  @decision["appraisals"]
112
112
  end
113
113
 
114
114
  # Return a hash of the factors specified for this Prospect.
115
-
115
+
116
116
  def factors
117
117
  @factors
118
118
  end
@@ -137,7 +137,7 @@ module Leadtune
137
137
  def organization #:nodoc:
138
138
  @factors["organization"] || @config.organization
139
139
  end
140
-
140
+
141
141
  def prospect_id #:nodoc:
142
142
  @factors["prospect_id"]
143
143
  end
@@ -179,13 +179,13 @@ module Leadtune
179
179
  end
180
180
 
181
181
 
182
- private
182
+ private
183
183
 
184
184
  CURL_OPTIONS = ["username", "password", "timeout", "leadtune_host",] #:nodoc:
185
185
 
186
186
  def post_data #:nodoc:
187
- @factors.merge("decision" => @decision,
188
- "organization" => @config.organization)
187
+ @factors.merge("decision" => @decision,
188
+ "organization" => organization)
189
189
  end
190
190
 
191
191
  def load_options_and_factors(options) #:nodoc:
data/lib/leadtune/rest.rb CHANGED
@@ -86,7 +86,7 @@ module Leadtune
86
86
  def build_get_url #:nodoc:
87
87
  params = {:organization => @post_data["organization"],}
88
88
  if @post_data["prospect_ref"]
89
- params.merge!(:prospect_ref => @post_data["prospect_ref"])
89
+ params.merge!(:prospect_ref => @post_data["prospect_ref"])
90
90
  end
91
91
 
92
92
  URI.join(build_put_url, "?" + Leadtune::Util.to_params(params)).to_s
@@ -5,5 +5,5 @@
5
5
  # Copyright 2010 LeadTune LLC
6
6
 
7
7
  module Leadtune
8
- VERSION = "0.0.4"
8
+ VERSION = "0.0.5"
9
9
  end
data/spec/get.rb CHANGED
@@ -10,20 +10,18 @@ require "rubygems"
10
10
  require "pp"
11
11
  require File.join(File.dirname(__FILE__), "../lib/leadtune")
12
12
 
13
-
14
13
  begin
15
- p = Leadtune::Prospect.new do |p|
16
- p.organization = "AcmeU"
17
- p.username = "admin@acme.edu"
18
- p.password = "admin"
19
- # p.leadtune_host = "http://localhost:8080"
20
- p.prospect_ref = "CRONIN"
21
- end
22
-
23
- p.get
14
+ p = Leadtune::Prospect.get({
15
+ :organization => "AcmeU",
16
+ :username => "admin@acme.edu",
17
+ :password => "admin",
18
+ # :leadtune_host => "http://localhost:8080",
19
+ :prospect_ref => "CRONIN",
20
+ # :prospect_id => "4ca3bae9a09801dd413d445c",
21
+ })
24
22
  pp p.factors
25
23
 
26
- pp Leadtune::Prospect.new({:prospect_id => "4c92f8d6b34601dd5ecac030",
24
+ pp Leadtune::Prospect.new({:prospect_id => "4ca3bd94a09801dd5b3d445c",
27
25
  :username => "admin@acme.edu",
28
26
  :password => "admin",
29
27
  :organization => "AcmeU",}).get.factors
@@ -10,7 +10,7 @@ require "spec_helper"
10
10
 
11
11
  describe Leadtune::Prospect do
12
12
 
13
- subject do
13
+ subject do
14
14
  Leadtune::Prospect.new({"prospect_id" => "deadfish",
15
15
  "email" => "bar@baz.com",
16
16
  "target_buyers" => ["AcmeU", "Bravo", "ConvU",],
@@ -32,7 +32,7 @@ describe Leadtune::Prospect do
32
32
  subject.my_new_factor.should == 5
33
33
  end
34
34
  end
35
-
35
+
36
36
  describe "#get" do
37
37
  before(:each) do
38
38
  stub_request(:any, /.*leadtune.*/).to_return(:body => fake_curb_response)
@@ -92,7 +92,24 @@ describe Leadtune::Prospect do
92
92
  it "uses the initializer value" do
93
93
  subject.organization.should == "init_org"
94
94
  end
95
- end
95
+ end
96
+ end
97
+
98
+ describe("#organization") do
99
+ before(:each) {setup_initializer}
100
+ after(:each) {teardown_initializer}
101
+
102
+ it "reads first from factors" do
103
+ subject.organization = "funky_chicken"
104
+
105
+ subject.organization.should == "funky_chicken"
106
+ end
107
+
108
+ it "falls back to @config if not in factors" do
109
+ subject.organization = nil
110
+
111
+ subject.organization.should == "init_org"
112
+ end
96
113
  end
97
114
 
98
115
 
data/spec/post.rb CHANGED
@@ -7,7 +7,6 @@
7
7
  # Copyright 2010 LeadTune LLC
8
8
 
9
9
  require "rubygems"
10
- require "ruby-debug"
11
10
  require "pp"
12
11
  require File.join(File.dirname(__FILE__), "../lib/leadtune")
13
12
 
@@ -18,7 +17,7 @@ p = Leadtune::Prospect.post do |p|
18
17
  p.password = "admin"
19
18
  p.email = "test@example.com"
20
19
  p.target_buyers = ["AcmeU", "Bravo", "ConvU",]
21
- #p.leadtune_host = "http://localhost:8080"
20
+ # p.leadtune_host = "http://localhost:8080"
22
21
  end
23
22
 
24
23
  pp p.factors
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eric Wollesen
@@ -30,10 +30,10 @@ dependencies:
30
30
  - 0
31
31
  - 0
32
32
  version: 1.0.0
33
- prerelease: false
34
33
  requirement: *id001
35
34
  type: :development
36
35
  name: bundler
36
+ prerelease: false
37
37
  - !ruby/object:Gem::Dependency
38
38
  version_requirements: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
@@ -44,10 +44,10 @@ dependencies:
44
44
  segments:
45
45
  - 0
46
46
  version: "0"
47
- prerelease: false
48
47
  requirement: *id002
49
48
  type: :development
50
49
  name: ruby-debug
50
+ prerelease: false
51
51
  - !ruby/object:Gem::Dependency
52
52
  version_requirements: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
@@ -62,10 +62,10 @@ dependencies:
62
62
  - beta
63
63
  - 19
64
64
  version: 2.0.0.beta.19
65
- prerelease: false
66
65
  requirement: *id003
67
66
  type: :development
68
67
  name: rspec
68
+ prerelease: false
69
69
  - !ruby/object:Gem::Dependency
70
70
  version_requirements: &id004 !ruby/object:Gem::Requirement
71
71
  none: false
@@ -80,10 +80,10 @@ dependencies:
80
80
  - beta
81
81
  - 19
82
82
  version: 2.0.0.beta.19
83
- prerelease: false
84
83
  requirement: *id004
85
84
  type: :development
86
85
  name: rspec-core
86
+ prerelease: false
87
87
  - !ruby/object:Gem::Dependency
88
88
  version_requirements: &id005 !ruby/object:Gem::Requirement
89
89
  none: false
@@ -98,10 +98,10 @@ dependencies:
98
98
  - beta
99
99
  - 19
100
100
  version: 2.0.0.beta.19
101
- prerelease: false
102
101
  requirement: *id005
103
102
  type: :development
104
103
  name: rspec-expectations
104
+ prerelease: false
105
105
  - !ruby/object:Gem::Dependency
106
106
  version_requirements: &id006 !ruby/object:Gem::Requirement
107
107
  none: false
@@ -116,10 +116,10 @@ dependencies:
116
116
  - beta
117
117
  - 19
118
118
  version: 2.0.0.beta.19
119
- prerelease: false
120
119
  requirement: *id006
121
120
  type: :development
122
121
  name: rspec-mocks
122
+ prerelease: false
123
123
  - !ruby/object:Gem::Dependency
124
124
  version_requirements: &id007 !ruby/object:Gem::Requirement
125
125
  none: false
@@ -130,10 +130,10 @@ dependencies:
130
130
  segments:
131
131
  - 0
132
132
  version: "0"
133
- prerelease: false
134
133
  requirement: *id007
135
134
  type: :development
136
135
  name: webmock
136
+ prerelease: false
137
137
  - !ruby/object:Gem::Dependency
138
138
  version_requirements: &id008 !ruby/object:Gem::Requirement
139
139
  none: false
@@ -144,10 +144,10 @@ dependencies:
144
144
  segments:
145
145
  - 0
146
146
  version: "0"
147
- prerelease: false
148
147
  requirement: *id008
149
148
  type: :development
150
149
  name: tcpsocket-wait
150
+ prerelease: false
151
151
  - !ruby/object:Gem::Dependency
152
152
  version_requirements: &id009 !ruby/object:Gem::Requirement
153
153
  none: false
@@ -158,10 +158,10 @@ dependencies:
158
158
  segments:
159
159
  - 0
160
160
  version: "0"
161
- prerelease: false
162
161
  requirement: *id009
163
162
  type: :runtime
164
163
  name: rake
164
+ prerelease: false
165
165
  - !ruby/object:Gem::Dependency
166
166
  version_requirements: &id010 !ruby/object:Gem::Requirement
167
167
  none: false
@@ -172,10 +172,10 @@ dependencies:
172
172
  segments:
173
173
  - 0
174
174
  version: "0"
175
- prerelease: false
176
175
  requirement: *id010
177
176
  type: :runtime
178
177
  name: curb
178
+ prerelease: false
179
179
  - !ruby/object:Gem::Dependency
180
180
  version_requirements: &id011 !ruby/object:Gem::Requirement
181
181
  none: false
@@ -186,10 +186,10 @@ dependencies:
186
186
  segments:
187
187
  - 0
188
188
  version: "0"
189
- prerelease: false
190
189
  requirement: *id011
191
190
  type: :runtime
192
191
  name: json
192
+ prerelease: false
193
193
  description: LeadTune Ruby API Gem
194
194
  email:
195
195
  - devs@leadtune.com