contact-data 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f710aaded7b29a23aeeaba066b6ab44a3dccf35e
4
- data.tar.gz: 92d0d640a4b6dea1c394a459b51e1cef687b2415
3
+ metadata.gz: f59ba9c14cee2938fbf80b40f4a93da17dbd80ee
4
+ data.tar.gz: e113709bf3721ba919e808dd098e47043f06c51e
5
5
  SHA512:
6
- metadata.gz: ee1f83d6fc779a5c811ed36115c66104b8ac1d9578325883ae0413c7529926bf8552645457d0a98708f4033f0ad2ad4a6acbebc3c616ea185d30c97cd98b6d63
7
- data.tar.gz: 1cac72dde7c016f3936d0d6d9491c037890f447c2b3050964a8b6fa94a97da8a9cbfccb909a7893c31d3631ac972344fa041fcfac2f011b39a473a2037160918
6
+ metadata.gz: f502119985d44d6f3e2dc2ea578b9a028921d1da6db5421a5cca71d042cb2aa160c6b2a5875e541d90ec4f21611f4435cc73c69c08f5ce20b9478c4d3af11188
7
+ data.tar.gz: 119ff74bf7c08f43e976476600909463a744293ea86a671b2b3aa29cd0cf64cbccd8eee7bd166db66a6ec7c50b07ecce03c8ed2889addd3f2700a9d9da26ec81
data/.gitignore CHANGED
@@ -1,3 +1,6 @@
1
+ .DS_Store
2
+ ._*
3
+
1
4
  * Gem project, so don't check in:
2
5
  Gemfile.lock
3
6
 
data/.hound.yml CHANGED
@@ -1,20 +1,4 @@
1
- LineLength:
2
- Description: 'Limit lines to 120 characters.'
3
- Max: 120
4
- Enabled: true
5
-
6
- StringLiterals:
7
- EnforcedStyle: single_quotes
8
- Enabled: true
9
-
10
- FileName:
11
- Description: 'Use snake_case for source file names.'
12
- Enabled: false
13
-
14
- MethodLength:
15
- Description: 'Avoid methods longer than 10 lines of code.'
16
- Enabled: false
17
-
18
- Documentation:
19
- Description: 'Document classes and non-namespace modules.'
20
- Enabled: false
1
+ ---
2
+ ruby:
3
+ enabled: true
4
+ config_file: .rubocop.yml
data/.rubocop.yml CHANGED
@@ -1 +1,44 @@
1
- inherit_from: .hound.yml
1
+ ---
2
+ # These are OK:
3
+
4
+ StringLiterals:
5
+ EnforcedStyle: single_quotes
6
+ Enabled: true
7
+
8
+ DotPosition:
9
+ Description: 'Checks the position of the dot in multi-line method calls.'
10
+ EnforcedStyle: leading
11
+ Enabled: true
12
+
13
+ ClassAndModuleChildren:
14
+ Description: 'Checks style of children classes and modules.'
15
+ EnforcedStyle: nested
16
+ Enabled: true
17
+
18
+ Documentation:
19
+ Description: 'Document classes and non-namespace modules.'
20
+ Enabled: false
21
+
22
+ Output:
23
+ Description: 'Checks for calls to puts, print, etc.'
24
+ Enabled: false
25
+
26
+ ExtraSpacing:
27
+ Enabled: false
28
+
29
+ FileName:
30
+ Description: 'Use snake_case for source file names.'
31
+ Enabled: true
32
+
33
+ Eval:
34
+ Enabled: false
35
+
36
+ LineLength:
37
+ Max: 120
38
+ Enabled: true
39
+
40
+ FileName:
41
+ Description: 'Use snake_case for source file names.'
42
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
43
+ Enabled: false
44
+
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.5
1
+ 2.1.6
data/contact-data.gemspec CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |spec|
13
13
  spec.license = 'MIT'
14
14
 
15
15
  spec.files = `git ls-files`.split($RS)
16
- spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(/^(test|spec|features|coverage)\//)
16
+ spec.executables = spec.files.grep(%r{^bin\/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features|coverage)\/})
18
18
  spec.require_paths = ['lib']
19
19
 
20
20
  spec.add_runtime_dependency 'rest-client', '~> 1'
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'vcr', '~> 2'
30
30
  spec.add_development_dependency 'webmock', '~> 1'
31
31
  spec.add_development_dependency 'byebug', '~> 3'
32
+ spec.add_development_dependency 'rubocop', '~> 0.31'
32
33
  end
@@ -1,11 +1,13 @@
1
1
  # encoding: utf-8
2
+ require 'string'
3
+
2
4
  module ContactData
3
5
  class Deprecated
4
6
  class << self
5
7
  def search(name, contact_type = nil)
6
8
  options = {}
7
9
  options[:params] = { contact_type: contact_type } if contact_type
8
- Fetcher.get("name/#{Fetcher.encode_component name}", options)
10
+ Fetcher.get("name/#{name.encode_component}", options)
9
11
  end
10
12
 
11
13
  def find_contacts_in(text)
@@ -4,7 +4,9 @@ require 'contact-data/exception'
4
4
 
5
5
  module ContactData
6
6
  class Fetcher
7
- URL = 'http://public.xenapto.com'
7
+ attr_reader :http_method, :api_method, :options
8
+
9
+ URL = ENV['XENDATA_URL'] || 'http://public.xenapto.com'
8
10
  API = 'api/v2'
9
11
 
10
12
  LOGLEVEL = Logger::WARN
@@ -12,85 +14,87 @@ module ContactData
12
14
  class << self
13
15
  [:get, :post].each do |http_method|
14
16
  define_method(http_method) do |api_method, options = {}|
15
- log_level(options)
16
- url = get_url_from(api_method, options)
17
- result = fetch_and_parse url, http_method, options
18
- log_level(LOGLEVEL)
19
- result
17
+ new(http_method, api_method, options).parsed_json
20
18
  end
21
19
  end
20
+ end
21
+
22
+ def parsed_json
23
+ logger.info { "Parsing #{json.length} characters of JSON" }
24
+ JSON.parse(json, symbolize_names: true, allow_nan: true)
25
+ end
22
26
 
23
- def encode_component(string)
24
- Addressable::URI.encode_component(string, Addressable::URI::CharacterClasses::PATH)
27
+ def url
28
+ return @url if @url
29
+
30
+ if api_method.is_a?(String)
31
+ @url = "#{url_base}/#{api_method}"
32
+ else
33
+ @url = "#{api_base}/#{method_base}#{api_method}"
25
34
  end
26
35
 
27
- private
36
+ @url = "#{@url}.#{options[:format] || :json}" unless options[:noformat]
37
+ @url
38
+ end
28
39
 
29
- def get_url_from(api_method, options = {})
30
- if api_method.is_a?(String)
31
- url = "#{URL}/#{api_method}"
32
- elsif options[:base]
33
- url = "#{URL}/#{API}/#{options[:base]}/#{api_method}"
34
- else
35
- url = "#{URL}/#{API}/#{api_method}"
36
- end
40
+ private
37
41
 
38
- if options[:noformat]
39
- url
40
- else
41
- format = options[:format] || :json
42
- "#{url}.#{format}"
43
- end
44
- end
42
+ def initialize(h, a, o = {})
43
+ @http_method = h
44
+ @api_method = a
45
+ @options = o
46
+ set_log_level
47
+ end
45
48
 
46
- def fetch_and_parse(url, method = :get, options = {})
47
- json = fetch(url, method, options)
48
- logger.info { "Parsing #{json.length} characters of JSON" }
49
- parse json
50
- end
49
+ def url_base
50
+ @url_base ||= (options[:url_base] || URL)
51
+ end
51
52
 
52
- def fetch(url, method = :get, options = {})
53
- args = args_from url, method, options
54
- logger.info { "Using #{method.to_s.upcase} for #{url}" }
55
- logger.info { "Args: #{args}" }
53
+ def api_base
54
+ @api_base ||= "#{url_base}/#{options[:api_base] || API}"
55
+ end
56
56
 
57
- begin
58
- RestClient::Request.new(args).execute
59
- rescue RestClient::Exception => e
60
- raise ContactData::FetchError, "#{e.message} when trying to #{method.to_s.upcase} url: #{url}", e.backtrace
61
- end
62
- end
57
+ def method_base
58
+ @method_base ||= (options.key?(:base) ? "#{options[:base]}/" : '')
59
+ end
63
60
 
64
- def args_from(url, method, options)
65
- args = { url: url, method: method }
66
- args[:headers] = { params: options[:params] } if options.key? :params
61
+ def display_method
62
+ @display_method ||= http_method.to_s.upcase
63
+ end
67
64
 
68
- [
69
- :method, :url, :headers, :cookies, :payload, :user, :password, :timeout,
70
- :max_redirects, :open_timeout, :raw_response, :processed_headers,
71
- :ssl_opts, :verify_ssl, :ssl_client_cert, :ssl_client_key, :ssl_ca_file,
72
- :ssl_ca_path, :ssl_cert_store, :ssl_verify_callback,
73
- :ssl_verify_callback_warnings, :ssl_version, :ssl_ciphers
74
- ].each { |key| args[key] = options[key] if options.key? key }
65
+ def json
66
+ return @json if @json
67
+ logger.info { "Using #{display_method} for #{url}" }
68
+ @json = RestClient::Request.new(args).execute
69
+ rescue RestClient::Exception => e
70
+ raise ContactData::FetchError, "#{e.message} when trying to #{display_method} url: #{url}", e.backtrace
71
+ end
75
72
 
76
- args
77
- end
73
+ def args
74
+ return @args if @args
78
75
 
79
- def parse(json)
80
- JSON.parse(json, symbolize_names: true, allow_nan: true)
81
- end
76
+ @args = { url: url, method: http_method }
77
+ @args[:headers] = { params: options[:params] } if options.key? :params
82
78
 
83
- def logger
84
- @logger ||= Logger.new(STDOUT)
85
- end
79
+ [
80
+ :method, :url, :headers, :cookies, :payload, :user, :password, :timeout, :max_redirects, :open_timeout,
81
+ :raw_response, :processed_headers, :ssl_opts, :verify_ssl, :ssl_client_cert, :ssl_client_key, :ssl_ca_file,
82
+ :ssl_ca_path, :ssl_cert_store, :ssl_verify_callback, :ssl_verify_callback_warnings, :ssl_version, :ssl_ciphers
83
+ ].each { |key| @args[key] = options[key] if options.key? key }
86
84
 
87
- def log_level(options = {})
88
- logger.level = if options.is_a?(Hash)
89
- options[:verbose] ? Logger::INFO : LOGLEVEL
90
- else
91
- options
92
- end
93
- end
85
+ @args
86
+ end
87
+
88
+ def verbose?
89
+ options[:verbose]
90
+ end
91
+
92
+ def logger
93
+ @logger ||= Logger.new(STDOUT)
94
+ end
95
+
96
+ def set_log_level
97
+ logger.level = verbose? ? Logger::INFO : LOGLEVEL
94
98
  end
95
99
  end
96
100
  end
@@ -1,31 +1,20 @@
1
1
  # encoding: utf-8
2
2
  module ContactData
3
3
  class Link
4
+ extend ContactData
4
5
  BASE = :links
5
6
 
6
7
  class << self
7
8
  def latest(params = {})
8
- Fetcher.get :latest, options_from(params)
9
+ Fetcher.get :latest, params.to_options(BASE)
9
10
  end
10
11
 
11
12
  def info(params = {})
12
- Fetcher.get :info, options_from(params)
13
+ Fetcher.get :info, params.to_options(BASE)
13
14
  end
14
15
 
15
16
  def search(params = {})
16
- Fetcher.get :search, options_from(params)
17
- end
18
-
19
- private
20
-
21
- def options_from(params = {})
22
- options = { base: BASE }
23
-
24
- params = { url: params } if params.is_a? String
25
-
26
- options[:verbose] = params.delete(:verbose) if params.key? :verbose
27
- options[:params] = params unless params.empty?
28
- options
17
+ Fetcher.get :search, params.to_options(BASE)
29
18
  end
30
19
  end
31
20
  end
@@ -0,0 +1,2 @@
1
+ module ContactData
2
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ module ContactData
3
+ class Text
4
+ extend ContactData
5
+ BASE = :text
6
+
7
+ def self.search(text = nil, params = {})
8
+ Fetcher.post :search, params.to_options(BASE, text)
9
+ end
10
+ end
11
+ end
@@ -1,4 +1,4 @@
1
1
  # Gem version
2
2
  module ContactData
3
- VERSION = '0.2.3'
3
+ VERSION = '0.3.0'
4
4
  end
data/lib/contact-data.rb CHANGED
@@ -2,7 +2,10 @@
2
2
  require 'addressable/uri'
3
3
  require 'json'
4
4
  require 'logger'
5
+ require 'hash'
6
+ require 'contact-data/options'
5
7
  require 'contact-data/contact'
6
8
  require 'contact-data/link'
9
+ require 'contact-data/text'
7
10
  require 'contact-data/fetcher'
8
11
  require 'contact-data/deprecated'
data/lib/hash.rb ADDED
@@ -0,0 +1,11 @@
1
+ class Hash
2
+ def to_options(base, text = nil)
3
+ o = { base: base }
4
+
5
+ [:verbose, :url_base, :api_base, :format, :noformat].each { |k| o[k] = delete(k) if key?(k) }
6
+
7
+ o[:payload] = { text: text } if text
8
+ o[:params] = self unless empty?
9
+ o
10
+ end
11
+ end
data/lib/string.rb ADDED
@@ -0,0 +1,9 @@
1
+ class String
2
+ def encode_component
3
+ Addressable::URI.encode_component(self, Addressable::URI::CharacterClasses::PATH)
4
+ end
5
+
6
+ def to_options(base)
7
+ { url: self }.to_options(base)
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'contact-data'
4
+
5
+ describe ContactData::Text do
6
+ let(:text) do
7
+ <<-HTML
8
+ <span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);"
9
+ class=""><b class="">From: </b></span>
10
+ <span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;"
11
+ class="">Max Williams<a href="mailto:max.williams@pusher-4.mail.intercom.io"
12
+ class="">max.williams@pusher-4.mail.intercom.io</a>&gt;<br class=""></span>
13
+ HTML
14
+ end
15
+
16
+ it 'gets metadata about text' do
17
+ VCR.use_cassette('text_search') do
18
+ result = ContactData::Text.search text, verbose: true
19
+ expect(result).to be_a(Hash)
20
+ expect(result[:contacts]).to include('neue')
21
+ expect(result[:contacts]).not_to include('max-williams')
22
+ end
23
+ end
24
+
25
+ it 'gets metadata about html, correctly identifying the text elements' do
26
+ VCR.use_cassette('text_search') do
27
+ result = ContactData::Text.search text, input_format: :html, verbose: true
28
+ expect(result).to be_a(Hash)
29
+ expect(result[:contacts]).not_to include('neue')
30
+ expect(result[:contacts]).to include('max-williams')
31
+ end
32
+ end
33
+ end
data/spec/fetcher_spec.rb CHANGED
@@ -5,6 +5,7 @@ require 'contact-data'
5
5
  describe ContactData::Fetcher do
6
6
  let(:method) { 'method' }
7
7
  let(:url) { ContactData::Fetcher::URL }
8
+ let(:url2) { 'http://example.com' }
8
9
 
9
10
  it 'adds diagnostic information to a RestClient exception' do
10
11
  RestClient::Request.any_instance.stub(:execute).and_raise RestClient::InternalServerError.new(nil, 500)
@@ -20,13 +21,14 @@ describe ContactData::Fetcher do
20
21
  [
21
22
  { method: method, options: {}, url: "#{url}/method.json" },
22
23
  { method: :method, options: {}, url: "#{url}/api/v2/method.json" },
23
- { method: :method, options: { base: 'base' }, url: "#{url}/api/v2/base/method.json" }
24
+ { method: :method, options: { base: 'base' }, url: "#{url}/api/v2/base/method.json" },
25
+ { method: :method, options: { url_base: url2 }, url: "#{url2}/api/v2/method.json" }
24
26
  ].each do |url_data|
25
27
  puts "#{url_data[:method].class}\t#{url_data[:options]}"
26
28
  expect(
27
- ContactData::Fetcher.__send__(
28
- :get_url_from, url_data[:method], url_data[:options]
29
- )
29
+ ContactData::Fetcher.new(
30
+ :get, url_data[:method], url_data[:options]
31
+ ).url
30
32
  ).to eq(url_data[:url])
31
33
  end
32
34
  end
@@ -92,4 +92,88 @@ http_interactions:
92
92
  Assigned Numbers Authority","news_source":"Internet Assigned Numbers Authority","summary":null,"version":"v2"}'
93
93
  http_version:
94
94
  recorded_at: Thu, 19 Jun 2014 12:24:59 GMT
95
- recorded_with: VCR 2.9.2
95
+ - request:
96
+ method: get
97
+ uri: http://public.xenapto.com/api/v2/info.json?url=http://iana.org
98
+ body:
99
+ encoding: US-ASCII
100
+ string: ''
101
+ headers:
102
+ Accept:
103
+ - "*/*; q=0.5, application/xml"
104
+ Accept-Encoding:
105
+ - gzip, deflate
106
+ User-Agent:
107
+ - Ruby
108
+ response:
109
+ status:
110
+ code: 404
111
+ message: Not Found
112
+ headers:
113
+ Date:
114
+ - Fri, 15 May 2015 10:32:21 GMT
115
+ Status:
116
+ - 404 Not Found
117
+ Connection:
118
+ - close
119
+ Content-Type:
120
+ - application/xml; charset=utf-8
121
+ Content-Length:
122
+ - '104'
123
+ X-Request-Id:
124
+ - 94f8f175-2999-48a5-8bf8-f6e1a9d77c35
125
+ X-Runtime:
126
+ - '0.029021'
127
+ body:
128
+ encoding: UTF-8
129
+ string: |
130
+ <?xml version="1.0" encoding="UTF-8"?>
131
+ <hash>
132
+ <status>404</status>
133
+ <error>Not Found</error>
134
+ </hash>
135
+ http_version:
136
+ recorded_at: Fri, 15 May 2015 10:32:21 GMT
137
+ - request:
138
+ method: get
139
+ uri: http://public.xenapto.com/api/v2/search.json?url=http://iana.org
140
+ body:
141
+ encoding: US-ASCII
142
+ string: ''
143
+ headers:
144
+ Accept:
145
+ - "*/*; q=0.5, application/xml"
146
+ Accept-Encoding:
147
+ - gzip, deflate
148
+ User-Agent:
149
+ - Ruby
150
+ response:
151
+ status:
152
+ code: 404
153
+ message: Not Found
154
+ headers:
155
+ Date:
156
+ - Fri, 15 May 2015 10:32:21 GMT
157
+ Status:
158
+ - 404 Not Found
159
+ Connection:
160
+ - close
161
+ Content-Type:
162
+ - application/xml; charset=utf-8
163
+ Content-Length:
164
+ - '104'
165
+ X-Request-Id:
166
+ - 40193489-7b00-43de-9ddc-fb3dfd8ad553
167
+ X-Runtime:
168
+ - '0.033578'
169
+ body:
170
+ encoding: UTF-8
171
+ string: |
172
+ <?xml version="1.0" encoding="UTF-8"?>
173
+ <hash>
174
+ <status>404</status>
175
+ <error>Not Found</error>
176
+ </hash>
177
+ http_version:
178
+ recorded_at: Fri, 15 May 2015 10:32:22 GMT
179
+ recorded_with: VCR 2.9.3
@@ -216236,4 +216236,46 @@ http_interactions:
216236
216236
  Data Startup Duetto Raises $2.1M From Trinity, Marc Benioff, Many More","updated_at":"2014-07-28T12:30:54Z","url":"http://techcrunch.com/2012/04/19/duetto-seed-round/"}]'
216237
216237
  http_version:
216238
216238
  recorded_at: Tue, 29 Jul 2014 13:28:12 GMT
216239
- recorded_with: VCR 2.9.2
216239
+ - request:
216240
+ method: get
216241
+ uri: http://public.xenapto.com/api/v2/latest.json?since=2014-07-28%2012:12:20%20%2B0100
216242
+ body:
216243
+ encoding: US-ASCII
216244
+ string: ''
216245
+ headers:
216246
+ Accept:
216247
+ - "*/*; q=0.5, application/xml"
216248
+ Accept-Encoding:
216249
+ - gzip, deflate
216250
+ User-Agent:
216251
+ - Ruby
216252
+ response:
216253
+ status:
216254
+ code: 404
216255
+ message: Not Found
216256
+ headers:
216257
+ Date:
216258
+ - Fri, 15 May 2015 10:32:23 GMT
216259
+ Status:
216260
+ - 404 Not Found
216261
+ Connection:
216262
+ - close
216263
+ Content-Type:
216264
+ - application/xml; charset=utf-8
216265
+ Content-Length:
216266
+ - '104'
216267
+ X-Request-Id:
216268
+ - fc837b1b-d5fd-406b-963e-126a7bdf518b
216269
+ X-Runtime:
216270
+ - '0.016432'
216271
+ body:
216272
+ encoding: UTF-8
216273
+ string: |
216274
+ <?xml version="1.0" encoding="UTF-8"?>
216275
+ <hash>
216276
+ <status>404</status>
216277
+ <error>Not Found</error>
216278
+ </hash>
216279
+ http_version:
216280
+ recorded_at: Fri, 15 May 2015 10:32:23 GMT
216281
+ recorded_with: VCR 2.9.3
@@ -53,6 +53,48 @@ http_interactions:
53
53
  Jones","identity_slug":"dxj00029","service":"fsa","url":"http://www.fsa.gov.uk/register//indivbasicdetails.do?sid=282759"},{"contact_type":"person","description":"Derek
54
54
  Jones","identity_slug":"dxj01164","service":"fsa","url":"http://www.fsa.gov.uk/register//indivbasicdetails.do?sid=490042"},{"contact_type":"person","description":"Derek
55
55
  Jones","identity_slug":"dxj01321","service":"fsa","url":"http://www.fsa.gov.uk/register//indivbasicdetails.do?sid=729794"},{"contact_type":"person","description":null,"identity_slug":"pub/derek-jones/15/b2/55b","service":"linked_in","url":"http://www.linkedin.com/pub/derek-jones/15/b2/55b"},{"contact_type":"person","description":null,"identity_slug":"http://www.dereknakano.com","service":"url","url":"http://www.dereknakano.com"}],"relationships":[],"links":[]}'
56
- http_version:
56
+ http_version:
57
57
  recorded_at: Tue, 11 Nov 2014 16:28:14 GMT
58
+ - request:
59
+ method: get
60
+ uri: http://public.xenapto.com/api/v2/search.json?name=Derek%20Jones%20III
61
+ body:
62
+ encoding: US-ASCII
63
+ string: ''
64
+ headers:
65
+ Accept:
66
+ - "*/*; q=0.5, application/xml"
67
+ Accept-Encoding:
68
+ - gzip, deflate
69
+ User-Agent:
70
+ - Ruby
71
+ response:
72
+ status:
73
+ code: 404
74
+ message: Not Found
75
+ headers:
76
+ Date:
77
+ - Fri, 15 May 2015 10:32:25 GMT
78
+ Status:
79
+ - 404 Not Found
80
+ Connection:
81
+ - close
82
+ Content-Type:
83
+ - application/xml; charset=utf-8
84
+ Content-Length:
85
+ - '104'
86
+ X-Request-Id:
87
+ - 5ddfb1b7-2ec9-4a50-83cc-aefe01f8eb85
88
+ X-Runtime:
89
+ - '0.007916'
90
+ body:
91
+ encoding: UTF-8
92
+ string: |
93
+ <?xml version="1.0" encoding="UTF-8"?>
94
+ <hash>
95
+ <status>404</status>
96
+ <error>Not Found</error>
97
+ </hash>
98
+ http_version:
99
+ recorded_at: Fri, 15 May 2015 10:32:25 GMT
58
100
  recorded_with: VCR 2.9.3
@@ -46,4 +46,46 @@ http_interactions:
46
46
  Thomas Edward Jones","page_link":"/derek-jones","source_created_at":null,"source_id":165075,"source_namespace":"users","source_slug":"derek-jones","source_updated_at":null,"website":null,"source_links":[],"source_funding_rounds":[],"source_relationships":[],"source_identities":[{"description":null,"service":"angel_list","slug":"derek-jones","url":"https://angel.co/derek-jones"},{"description":null,"service":"avatar","slug":"https://d1qb2nb5cznatu.cloudfront.net/users/165075-medium_jpg?1405505118","url":"https://d1qb2nb5cznatu.cloudfront.net/users/165075-medium_jpg?1405505118"},{"description":null,"service":"linked_in","slug":"pub/derek-jones/15/b2/55b","url":"http://www.linkedin.com/pub/derek-jones/15/b2/55b"},{"description":null,"service":"domain","slug":"dereknakano.com","url":"http://www.dereknakano.com"},{"description":null,"service":"url","slug":"http://www.dereknakano.com","url":"http://www.dereknakano.com"}],"counterparty_relationships":[]}]}'
47
47
  http_version:
48
48
  recorded_at: Fri, 06 Feb 2015 17:38:54 GMT
49
+ - request:
50
+ method: get
51
+ uri: http://public.xenapto.com/api/v2/from.json?slug=derek-jones&source=angel_list
52
+ body:
53
+ encoding: US-ASCII
54
+ string: ''
55
+ headers:
56
+ Accept:
57
+ - "*/*; q=0.5, application/xml"
58
+ Accept-Encoding:
59
+ - gzip, deflate
60
+ User-Agent:
61
+ - Ruby
62
+ response:
63
+ status:
64
+ code: 404
65
+ message: Not Found
66
+ headers:
67
+ Date:
68
+ - Fri, 15 May 2015 10:32:25 GMT
69
+ Status:
70
+ - 404 Not Found
71
+ Connection:
72
+ - close
73
+ Content-Type:
74
+ - application/xml; charset=utf-8
75
+ Content-Length:
76
+ - '104'
77
+ X-Request-Id:
78
+ - 40998415-32f2-473b-958c-0f8fdbf48110
79
+ X-Runtime:
80
+ - '0.016751'
81
+ body:
82
+ encoding: UTF-8
83
+ string: |
84
+ <?xml version="1.0" encoding="UTF-8"?>
85
+ <hash>
86
+ <status>404</status>
87
+ <error>Not Found</error>
88
+ </hash>
89
+ http_version:
90
+ recorded_at: Fri, 15 May 2015 10:32:25 GMT
49
91
  recorded_with: VCR 2.9.3
@@ -0,0 +1,106 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://public.xenapto.com/api/v2/text/search.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: text=%20%20%20%20%20%20%3Cspan%20style%3D%22font-family%3A%20-webkit-system-font%2C%20Helvetica%20Neue%2C%20Helvetica%2C%20sans-serif%3B%20color%3Argba(0%2C%200%2C%200%2C%201.0)%3B%22%0A%20%20%20%20%20%20class%3D%22%22%3E%3Cb%20class%3D%22%22%3EFrom%3A%20%3C%2Fb%3E%3C%2Fspan%3E%0A%20%20%20%20%20%20%3Cspan%20style%3D%22font-family%3A%20-webkit-system-font%2C%20Helvetica%20Neue%2C%20Helvetica%2C%20sans-serif%3B%22%0A%20%20%20%20%20%20class%3D%22%22%3EMax%20Williams%3Ca%20href%3D%22mailto%3Amax.williams%40pusher-4.mail.intercom.io%22%0A%20%20%20%20%20%20class%3D%22%22%3Emax.williams%40pusher-4.mail.intercom.io%3C%2Fa%3E%26gt%3B%3Cbr%20class%3D%22%22%3E%3C%2Fspan%3E%0A
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Length:
15
+ - '673'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Fri, 15 May 2015 12:51:41 GMT
27
+ Status:
28
+ - 200 OK
29
+ Connection:
30
+ - close
31
+ X-Frame-Options:
32
+ - SAMEORIGIN
33
+ X-Xss-Protection:
34
+ - 1; mode=block
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ Content-Type:
38
+ - application/json; charset=utf-8
39
+ Content-Length:
40
+ - '232'
41
+ Etag:
42
+ - W/"81b442e407e9c8bbac8308519c37a4e6"
43
+ Cache-Control:
44
+ - max-age=0, private, must-revalidate
45
+ X-Request-Id:
46
+ - 8a424d7e-5a82-4d0e-8b8c-8b5d1b0697ef
47
+ X-Runtime:
48
+ - '0.401147'
49
+ body:
50
+ encoding: UTF-8
51
+ string: '{"contacts":["neue","intercom","intercom-io"],"mentions":[],"emails":["max.williams@pusher-4.mail.intercom.io"],"names":["Neue","Intercom","Intercom.io"],"contact_types":["organization","organization","organization"],"version":"v2"}'
52
+ http_version:
53
+ recorded_at: Fri, 15 May 2015 12:51:41 GMT
54
+ - request:
55
+ method: post
56
+ uri: http://public.xenapto.com/api/v2/text/search.json?input_format=html
57
+ body:
58
+ encoding: US-ASCII
59
+ string: text=%20%20%20%20%20%20%3Cspan%20style%3D%22font-family%3A%20-webkit-system-font%2C%20Helvetica%20Neue%2C%20Helvetica%2C%20sans-serif%3B%20color%3Argba(0%2C%200%2C%200%2C%201.0)%3B%22%0A%20%20%20%20%20%20class%3D%22%22%3E%3Cb%20class%3D%22%22%3EFrom%3A%20%3C%2Fb%3E%3C%2Fspan%3E%0A%20%20%20%20%20%20%3Cspan%20style%3D%22font-family%3A%20-webkit-system-font%2C%20Helvetica%20Neue%2C%20Helvetica%2C%20sans-serif%3B%22%0A%20%20%20%20%20%20class%3D%22%22%3EMax%20Williams%3Ca%20href%3D%22mailto%3Amax.williams%40pusher-4.mail.intercom.io%22%0A%20%20%20%20%20%20class%3D%22%22%3Emax.williams%40pusher-4.mail.intercom.io%3C%2Fa%3E%26gt%3B%3Cbr%20class%3D%22%22%3E%3C%2Fspan%3E%0A
60
+ headers:
61
+ Accept:
62
+ - "*/*; q=0.5, application/xml"
63
+ Accept-Encoding:
64
+ - gzip, deflate
65
+ Content-Length:
66
+ - '673'
67
+ Content-Type:
68
+ - application/x-www-form-urlencoded
69
+ User-Agent:
70
+ - Ruby
71
+ response:
72
+ status:
73
+ code: 200
74
+ message: OK
75
+ headers:
76
+ Date:
77
+ - Fri, 15 May 2015 12:52:12 GMT
78
+ Status:
79
+ - 200 OK
80
+ Connection:
81
+ - close
82
+ X-Frame-Options:
83
+ - SAMEORIGIN
84
+ X-Xss-Protection:
85
+ - 1; mode=block
86
+ X-Content-Type-Options:
87
+ - nosniff
88
+ Content-Type:
89
+ - application/json; charset=utf-8
90
+ Content-Length:
91
+ - '242'
92
+ Etag:
93
+ - W/"bc904362c962aaeea2357476a1c2fbff"
94
+ Cache-Control:
95
+ - max-age=0, private, must-revalidate
96
+ X-Request-Id:
97
+ - d703a761-c166-4bab-be73-9eab49cc131a
98
+ X-Runtime:
99
+ - '0.118948'
100
+ body:
101
+ encoding: UTF-8
102
+ string: '{"contacts":["max-williams","intercom","intercom-io"],"mentions":[],"emails":["max.williams@pusher-4.mail.intercom.io"],"names":["Max
103
+ Williams","Intercom","Intercom.io"],"contact_types":["person","organization","organization"],"version":"v2"}'
104
+ http_version:
105
+ recorded_at: Fri, 15 May 2015 12:52:12 GMT
106
+ recorded_with: VCR 2.9.3
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contact-data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xenapto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2015-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '3'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.31'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.31'
167
181
  description: A Ruby gem to retrieve data about people and organizations from http://public.xenapto.com
168
182
  email:
169
183
  - developers@xenapto.com
@@ -188,10 +202,15 @@ files:
188
202
  - lib/contact-data/exception.rb
189
203
  - lib/contact-data/fetcher.rb
190
204
  - lib/contact-data/link.rb
205
+ - lib/contact-data/options.rb
206
+ - lib/contact-data/text.rb
191
207
  - lib/contact-data/version.rb
208
+ - lib/hash.rb
209
+ - lib/string.rb
192
210
  - spec/contact-data_contact_spec.rb
193
211
  - spec/contact-data_deprecated_spec.rb
194
212
  - spec/contact-data_link_spec.rb
213
+ - spec/contact-data_text_spec.rb
195
214
  - spec/fetcher_spec.rb
196
215
  - spec/spec_helper.rb
197
216
  - spec/support/cassettes/deprecated_contact_name_search.yml
@@ -201,6 +220,7 @@ files:
201
220
  - spec/support/cassettes/links_latest.yml
202
221
  - spec/support/cassettes/name_search.yml
203
222
  - spec/support/cassettes/source_slug.yml
223
+ - spec/support/cassettes/text_search.yml
204
224
  - spec/support/vcr_setup.rb
205
225
  homepage: https://github.com/Xenapto/contact-data
206
226
  licenses:
@@ -222,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
242
  version: '0'
223
243
  requirements: []
224
244
  rubyforge_project:
225
- rubygems_version: 2.4.4
245
+ rubygems_version: 2.4.6
226
246
  signing_key:
227
247
  specification_version: 4
228
248
  summary: 'Example: ContactData.search(''John Smith III'')'
@@ -230,6 +250,7 @@ test_files:
230
250
  - spec/contact-data_contact_spec.rb
231
251
  - spec/contact-data_deprecated_spec.rb
232
252
  - spec/contact-data_link_spec.rb
253
+ - spec/contact-data_text_spec.rb
233
254
  - spec/fetcher_spec.rb
234
255
  - spec/spec_helper.rb
235
256
  - spec/support/cassettes/deprecated_contact_name_search.yml
@@ -239,4 +260,5 @@ test_files:
239
260
  - spec/support/cassettes/links_latest.yml
240
261
  - spec/support/cassettes/name_search.yml
241
262
  - spec/support/cassettes/source_slug.yml
263
+ - spec/support/cassettes/text_search.yml
242
264
  - spec/support/vcr_setup.rb