piplapis-ruby 4.0.0
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/LICENSE +11 -0
- data/README.md +38 -0
- data/lib/pipl.rb +35 -0
- data/lib/pipl/client.rb +165 -0
- data/lib/pipl/configurable.rb +55 -0
- data/lib/pipl/consts.rb +74 -0
- data/lib/pipl/containers.rb +289 -0
- data/lib/pipl/default.rb +55 -0
- data/lib/pipl/errors.rb +33 -0
- data/lib/pipl/fields.rb +714 -0
- data/lib/pipl/response.rb +126 -0
- data/lib/pipl/utils.rb +51 -0
- data/lib/pipl/version.rb +3 -0
- data/pipl.gemspec +19 -0
- metadata +77 -0
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
require_relative 'containers'
|
4
|
+
|
5
|
+
module Pipl
|
6
|
+
|
7
|
+
class Client
|
8
|
+
|
9
|
+
class SearchResponse
|
10
|
+
|
11
|
+
attr_reader :query, :person, :sources, :possible_persons, :warnings, :visible_sources, :available_sources
|
12
|
+
attr_reader :search_id, :http_status_code
|
13
|
+
|
14
|
+
def initialize(params={})
|
15
|
+
@query = params[:query]
|
16
|
+
@person = params[:person]
|
17
|
+
@sources = params[:sources]
|
18
|
+
@possible_persons = params[:possible_persons]
|
19
|
+
@warnings = params[:warnings]
|
20
|
+
@visible_sources = params[:visible_sources]
|
21
|
+
@available_sources = params[:available_sources]
|
22
|
+
@search_id = params[:search_id]
|
23
|
+
@http_status_code = params[:http_status_code]
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.from_json(json_str)
|
27
|
+
h = JSON.parse(json_str, symbolize_names: true)
|
28
|
+
|
29
|
+
params = {}
|
30
|
+
params[:query] = Pipl::Person.from_hash(h[:query]) if h.key? :query
|
31
|
+
params[:person] = Pipl::Person.from_hash(h[:person]) if h.key? :person
|
32
|
+
params[:sources] = h[:sources].map { |s| Pipl::Source.from_hash(s) } if h.key? :sources
|
33
|
+
params[:possible_persons] = h[:possible_persons].map { |p| Pipl::Person.from_hash(p) } if h.key? :possible_persons
|
34
|
+
params[:warnings] = h[:warnings]
|
35
|
+
params[:visible_sources] = h[:@visible_sources]
|
36
|
+
params[:available_sources] = h[:@available_sources]
|
37
|
+
params[:search_id] = h[:@search_id]
|
38
|
+
params[:http_status_code] = h[:@http_status_code]
|
39
|
+
|
40
|
+
self.new(params)
|
41
|
+
end
|
42
|
+
|
43
|
+
def matching_sources
|
44
|
+
@sources.select { |s| s.match == 1.0 } if @sources
|
45
|
+
end
|
46
|
+
|
47
|
+
def group_sources_by_domain
|
48
|
+
@sources.group_by { |s| s.domain } if @sources
|
49
|
+
end
|
50
|
+
|
51
|
+
def group_sources_by_category
|
52
|
+
@sources.group_by { |s| s.category } if @sources
|
53
|
+
end
|
54
|
+
|
55
|
+
def group_sources_by_match
|
56
|
+
@sources.group_by { |s| s.match } if @sources
|
57
|
+
end
|
58
|
+
|
59
|
+
def gender
|
60
|
+
@person.gender if @person
|
61
|
+
end
|
62
|
+
|
63
|
+
def age
|
64
|
+
@person.age if @person
|
65
|
+
end
|
66
|
+
|
67
|
+
def job
|
68
|
+
@person.job if @person
|
69
|
+
end
|
70
|
+
|
71
|
+
def address
|
72
|
+
@person.address if @person
|
73
|
+
end
|
74
|
+
|
75
|
+
def education
|
76
|
+
@person.education if @person
|
77
|
+
end
|
78
|
+
|
79
|
+
def language
|
80
|
+
@person.language if @person
|
81
|
+
end
|
82
|
+
|
83
|
+
def ethnicity
|
84
|
+
@person.ethnicity if @person
|
85
|
+
end
|
86
|
+
|
87
|
+
def origin_country
|
88
|
+
@person.origin_country if @person
|
89
|
+
end
|
90
|
+
|
91
|
+
def phone
|
92
|
+
@person.phone if @person
|
93
|
+
end
|
94
|
+
|
95
|
+
def email
|
96
|
+
@person.email if @person
|
97
|
+
end
|
98
|
+
|
99
|
+
def name
|
100
|
+
@person.name if @person
|
101
|
+
end
|
102
|
+
|
103
|
+
def image
|
104
|
+
@person.image if @person
|
105
|
+
end
|
106
|
+
|
107
|
+
def url
|
108
|
+
@person.url if @person
|
109
|
+
end
|
110
|
+
|
111
|
+
def username
|
112
|
+
@person.username if @person
|
113
|
+
end
|
114
|
+
|
115
|
+
def user_id
|
116
|
+
@person.user_id if @person
|
117
|
+
end
|
118
|
+
|
119
|
+
def relationship
|
120
|
+
@person.relationship if @person
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
data/lib/pipl/utils.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module Pipl
|
5
|
+
|
6
|
+
module Utils
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
def str_to_date(s)
|
11
|
+
Date.strptime(s, DATE_FORMAT)
|
12
|
+
end
|
13
|
+
|
14
|
+
def date_to_str(d)
|
15
|
+
d.strftime(DATE_FORMAT)
|
16
|
+
end
|
17
|
+
|
18
|
+
def is_valid_url?(url)
|
19
|
+
not ((url =~ URI::ABS_URI).nil?)
|
20
|
+
end
|
21
|
+
|
22
|
+
def alpha_chars(s)
|
23
|
+
s.gsub(/^[\p{Alpha}]/, '')
|
24
|
+
end
|
25
|
+
|
26
|
+
def alnum_chars(s)
|
27
|
+
s.gsub(/^[\p{Alnum}]/, '')
|
28
|
+
end
|
29
|
+
|
30
|
+
def titleize(s)
|
31
|
+
s.gsub(/\w+/) { |x| x.capitalize }
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_utf8(obj)
|
35
|
+
if obj.respond_to?(:encode)
|
36
|
+
begin
|
37
|
+
obj.encode('UTF-8')
|
38
|
+
rescue Exception
|
39
|
+
puts "Could not convert #{obj} to UTF-8"
|
40
|
+
raise
|
41
|
+
end
|
42
|
+
else
|
43
|
+
obj
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/lib/pipl/version.rb
ADDED
data/pipl.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'pipl/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'piplapis-ruby'
|
7
|
+
spec.summary = 'Ruby bindings for the Pipl API'
|
8
|
+
spec.description = 'Pipl is the most comprehensive people search on the web. See https://pipl.com for details.'
|
9
|
+
spec.homepage = 'https://github.com/piplcom/piplapis-ruby'
|
10
|
+
spec.authors = ['Edo Shor']
|
11
|
+
spec.email = ['edo.shor@pipl.com']
|
12
|
+
spec.license = 'Apache 2.0'
|
13
|
+
spec.version = Pipl::VERSION.dup
|
14
|
+
spec.files = %w(LICENSE README.md pipl.gemspec)
|
15
|
+
spec.files += Dir.glob('lib/**/*.rb')
|
16
|
+
spec.require_paths = ['lib']
|
17
|
+
|
18
|
+
spec.add_development_dependency('bundler', '~> 1.6')
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: piplapis-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 4.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Edo Shor
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-03-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.6'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.6'
|
30
|
+
description: Pipl is the most comprehensive people search on the web. See https://pipl.com
|
31
|
+
for details.
|
32
|
+
email:
|
33
|
+
- edo.shor@pipl.com
|
34
|
+
executables: []
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- LICENSE
|
39
|
+
- README.md
|
40
|
+
- pipl.gemspec
|
41
|
+
- lib/pipl/response.rb
|
42
|
+
- lib/pipl/consts.rb
|
43
|
+
- lib/pipl/version.rb
|
44
|
+
- lib/pipl/fields.rb
|
45
|
+
- lib/pipl/utils.rb
|
46
|
+
- lib/pipl/configurable.rb
|
47
|
+
- lib/pipl/client.rb
|
48
|
+
- lib/pipl/default.rb
|
49
|
+
- lib/pipl/errors.rb
|
50
|
+
- lib/pipl/containers.rb
|
51
|
+
- lib/pipl.rb
|
52
|
+
homepage: https://github.com/piplcom/piplapis-ruby
|
53
|
+
licenses:
|
54
|
+
- Apache 2.0
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.8.23.2
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: Ruby bindings for the Pipl API
|
77
|
+
test_files: []
|