pipejump 0.4.0 → 0.4.1
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/.rspec +3 -1
- data/Gemfile +2 -2
- data/Gemfile.lock +7 -8
- data/lib/pipejump.rb +2 -1
- data/lib/pipejump/base/resource.rb +2 -2
- data/lib/pipejump/base/util.rb +24 -0
- data/lib/pipejump/resources/contact.rb +15 -0
- data/lib/pipejump/version.rb +1 -1
- data/spec/pipejump/resources/contact_custom_fields_spec.rb +25 -0
- data/spec/pipejump/resources/contact_spec.rb +14 -1
- data/spec/pipejump/util_spec.rb +23 -0
- metadata +8 -3
data/.rspec
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
addressable (2.2.6)
|
5
|
-
crack (0.1.8)
|
6
4
|
diff-lcs (1.1.3)
|
5
|
+
fuubar (1.0.0)
|
6
|
+
rspec (~> 2.0)
|
7
|
+
rspec-instafail (~> 0.2.0)
|
8
|
+
ruby-progressbar (~> 0.0.10)
|
7
9
|
json (1.5.3)
|
8
10
|
rake (0.9.2)
|
9
11
|
rcov (0.9.10)
|
@@ -14,19 +16,16 @@ GEM
|
|
14
16
|
rspec-core (2.6.4)
|
15
17
|
rspec-expectations (2.6.0)
|
16
18
|
diff-lcs (~> 1.1.2)
|
19
|
+
rspec-instafail (0.2.4)
|
17
20
|
rspec-mocks (2.6.0)
|
18
|
-
|
19
|
-
webmock (1.7.5)
|
20
|
-
addressable (~> 2.2, > 2.2.5)
|
21
|
-
crack (>= 0.1.7)
|
21
|
+
ruby-progressbar (0.0.10)
|
22
22
|
|
23
23
|
PLATFORMS
|
24
24
|
ruby
|
25
25
|
|
26
26
|
DEPENDENCIES
|
27
|
+
fuubar
|
27
28
|
json
|
28
29
|
rake
|
29
30
|
rcov
|
30
31
|
rspec
|
31
|
-
vcr
|
32
|
-
webmock
|
data/lib/pipejump.rb
CHANGED
@@ -9,10 +9,11 @@ require 'pipejump/base/resource'
|
|
9
9
|
require 'pipejump/base/session'
|
10
10
|
require 'pipejump/base/errors'
|
11
11
|
require 'pipejump/base/connection'
|
12
|
+
require 'pipejump/base/util'
|
12
13
|
|
13
14
|
require 'pipejump/resources/account'
|
14
15
|
require 'pipejump/resources/deal'
|
15
16
|
require 'pipejump/resources/note'
|
16
17
|
require 'pipejump/resources/reminder'
|
17
18
|
require 'pipejump/resources/source'
|
18
|
-
require 'pipejump/resources/contact'
|
19
|
+
require 'pipejump/resources/contact'
|
@@ -144,7 +144,7 @@ module Pipejump
|
|
144
144
|
end
|
145
145
|
|
146
146
|
def inspect
|
147
|
-
"#<#{self.class} #{@attributes.collect { |pair| pair[1] =
|
147
|
+
"#<#{self.class} #{@attributes.collect { |pair| pair[1] = pair[1].inspect; pair.join(': ') }.join(', ')}>"
|
148
148
|
end
|
149
149
|
|
150
150
|
def element_path
|
@@ -187,4 +187,4 @@ module Pipejump
|
|
187
187
|
|
188
188
|
end
|
189
189
|
|
190
|
-
end
|
190
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Pipejump
|
2
|
+
|
3
|
+
module Util
|
4
|
+
|
5
|
+
def self.to_query(value, key = nil)
|
6
|
+
case value
|
7
|
+
when Hash then value.map { |k,v| to_query(v, append_key(key,k)) }.join('&')
|
8
|
+
when Array then value.map { |v| to_query(v, "#{key}[]") }.join('&')
|
9
|
+
when nil then ''
|
10
|
+
else
|
11
|
+
"#{key}=#{CGI.escape(value.to_s)}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def self.append_key(root_key, key)
|
18
|
+
root_key.nil? ? key : "#{root_key}[#{key.to_s}]"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
@@ -227,10 +227,25 @@ module Pipejump
|
|
227
227
|
|
228
228
|
def before_save
|
229
229
|
@attributes.delete('organisation')
|
230
|
+
@attributes.delete('organisation_name')
|
230
231
|
@attributes.delete('linkedin_display')
|
231
232
|
@attributes.delete('tags_joined_by_comma')
|
232
233
|
end
|
233
234
|
|
235
|
+
def to_query
|
236
|
+
Pipejump::Util.to_query(:contact => @attributes)
|
237
|
+
end
|
238
|
+
|
239
|
+
def load(attrs = {}) #:nodoc:
|
240
|
+
super
|
241
|
+
fields = @attributes['custom_fields'] || {}
|
242
|
+
@attributes['custom_fields'] = fields.inject({}) do |memo, field|
|
243
|
+
memo[field.first] = field.last['value']
|
244
|
+
memo
|
245
|
+
end
|
246
|
+
@attributes
|
247
|
+
end
|
248
|
+
|
234
249
|
end
|
235
250
|
|
236
251
|
end
|
data/lib/pipejump/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pipejump::Contact do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@session = PipejumpSpec.session
|
7
|
+
@contact = @session.contacts.create(:name => 'contact1'+uuid)
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
@contact.destroy
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#custom_fields" do
|
15
|
+
|
16
|
+
it "returns a hash of custom fields" do
|
17
|
+
@contact.custom_fields['test_field'] = 'yaaay'
|
18
|
+
@contact.save.should == true
|
19
|
+
|
20
|
+
@session.contacts.find(@contact.id).custom_fields['test_field'].should =='yaaay'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
@@ -98,4 +98,17 @@ describe Pipejump::Contact do
|
|
98
98
|
|
99
99
|
end
|
100
100
|
|
101
|
-
|
101
|
+
describe "#custom_fields" do
|
102
|
+
|
103
|
+
it "returns a hash of custom fields" do
|
104
|
+
@contact1.name = 'AAA TESTING ONE'
|
105
|
+
@contact1.custom_fields['test_field'] = 'yaaay'
|
106
|
+
@contact1.save
|
107
|
+
|
108
|
+
puts @contact1.inspect
|
109
|
+
|
110
|
+
@session.contacts.find(@contact1.id).custom_fields['test_field']['value'].should =='yaaay'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Pipejump::Util do
|
4
|
+
|
5
|
+
describe ".to_query" do
|
6
|
+
|
7
|
+
it "works with a simple hash" do
|
8
|
+
result = Pipejump::Util.to_query :a => 1, :b => 1
|
9
|
+
result.should == "a=1&b=1"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "works with a nested hash" do
|
13
|
+
result = Pipejump::Util.to_query :a => 1, :b => { :c => 1 }
|
14
|
+
result.should == "a=1&b[c]=1"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "works with an array" do
|
18
|
+
result = Pipejump::Util.to_query :a => [1,2]
|
19
|
+
result.should == "a[]=1&a[]=2"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipejump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-06-21 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: Base API Ruby client
|
17
17
|
email: marcin@futuresimple.com
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/pipejump/base/errors.rb
|
35
35
|
- lib/pipejump/base/resource.rb
|
36
36
|
- lib/pipejump/base/session.rb
|
37
|
+
- lib/pipejump/base/util.rb
|
37
38
|
- lib/pipejump/resources/account.rb
|
38
39
|
- lib/pipejump/resources/contact.rb
|
39
40
|
- lib/pipejump/resources/deal.rb
|
@@ -45,12 +46,14 @@ files:
|
|
45
46
|
- spec/connection.sample.yml
|
46
47
|
- spec/pipejump/resources/contact/note_spec.rb
|
47
48
|
- spec/pipejump/resources/contact/reminder_spec.rb
|
49
|
+
- spec/pipejump/resources/contact_custom_fields_spec.rb
|
48
50
|
- spec/pipejump/resources/contact_spec.rb
|
49
51
|
- spec/pipejump/resources/deal/note_spec.rb
|
50
52
|
- spec/pipejump/resources/deal/reminder_spec.rb
|
51
53
|
- spec/pipejump/resources/deal_spec.rb
|
52
54
|
- spec/pipejump/resources/source_spec.rb
|
53
55
|
- spec/pipejump/session_spec.rb
|
56
|
+
- spec/pipejump/util_spec.rb
|
54
57
|
- spec/spec_helper.rb
|
55
58
|
homepage: http://futuresimple.com/api
|
56
59
|
licenses: []
|
@@ -72,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
75
|
version: '0'
|
73
76
|
requirements: []
|
74
77
|
rubyforge_project: pipejump
|
75
|
-
rubygems_version: 1.8.
|
78
|
+
rubygems_version: 1.8.24
|
76
79
|
signing_key:
|
77
80
|
specification_version: 3
|
78
81
|
summary: Base API Ruby client
|
@@ -80,11 +83,13 @@ test_files:
|
|
80
83
|
- spec/connection.sample.yml
|
81
84
|
- spec/pipejump/resources/contact/note_spec.rb
|
82
85
|
- spec/pipejump/resources/contact/reminder_spec.rb
|
86
|
+
- spec/pipejump/resources/contact_custom_fields_spec.rb
|
83
87
|
- spec/pipejump/resources/contact_spec.rb
|
84
88
|
- spec/pipejump/resources/deal/note_spec.rb
|
85
89
|
- spec/pipejump/resources/deal/reminder_spec.rb
|
86
90
|
- spec/pipejump/resources/deal_spec.rb
|
87
91
|
- spec/pipejump/resources/source_spec.rb
|
88
92
|
- spec/pipejump/session_spec.rb
|
93
|
+
- spec/pipejump/util_spec.rb
|
89
94
|
- spec/spec_helper.rb
|
90
95
|
has_rdoc:
|