piplrequest 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/piplrequest.rb +23 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3355fcb1df7915583889c5182e17b74cd459783c
4
- data.tar.gz: 40ff32cd854b51760fc0ce61729f33f725b45724
3
+ metadata.gz: 8fd3a935d8bb901be18fb00f750b4800e663eeb1
4
+ data.tar.gz: ffcdb99750ae841d6814ec7c2c0eb32a51170da7
5
5
  SHA512:
6
- metadata.gz: a3ab914a76485d308cc02a73daf3785ef64d1789fbe0a6a7b802ee2d750067c22ede8abe087d4beb5c09a27691b4c6a933b2203f75a295d92dafbcc33e14d671
7
- data.tar.gz: 6733732e558efd9965c28ea3ac5f8d037d4b4da0ddae51385c51ee2db422a990314762d8bb0c361d4db7c4a6d30cbd754a29164991611ae3cc7a60d83a8bc6c1
6
+ metadata.gz: fbf0aaf7b4692535ab1d39d260e3da51de6933a9289e59017a7f21ad90e367a76fb54c4f68dd0372f0321f902f7aa40db425fca1f5f1a6d30745a81d5c912e1f
7
+ data.tar.gz: 897f0af70c2031e7d48fb7067c7761f91c130b735754856cd787fc245be99230904a17e96f74b51cae6a5314f9c86167d48b8ce199c619b444fd22baa215b1c4
data/lib/piplrequest.rb CHANGED
@@ -87,14 +87,30 @@ class PiplRequest
87
87
  def gen_name(data_item)
88
88
  return Pipl::Name.new(first: get_clean_name_content(data_item, :first),
89
89
  last: get_clean_name_content(data_item, :last),
90
+ middle: get_clean_name_content(data_item, :middle),
90
91
  raw: get_clean_name_content(data_item, :raw)
91
92
  )
92
93
  end
93
94
 
95
+ # Get the location
96
+ def gen_location(data_item)
97
+ city = get_field_content(data_item, :address, :city)
98
+ state = get_field_content(data_item, :address, :state)
99
+ country = get_field_content(data_item, :address, :country)
100
+
101
+ # Gen string for location
102
+ location_string = ""
103
+ location_string += city + ", "if city
104
+ location_string += state + ", " if state
105
+ location_string += country if country
106
+
107
+ location = geocode(location_string)
108
+ end
109
+
94
110
  # Generate the URL
95
111
  def gen_url(data_item)
96
- Pipl::Url.new(url: get_field_content(data_item, :url, :url),
97
- domain: @fields_to_use[:url][:domain])
112
+ url = get_field_content(data_item, :url, :url)
113
+ Pipl::Url.new(url: url, domain: @fields_to_use[:url][:domain]) if url
98
114
  end
99
115
 
100
116
  # Builds person model
@@ -102,20 +118,20 @@ class PiplRequest
102
118
  # Initial gen and required fields
103
119
  person = Pipl::Person.new
104
120
  person.add_field(gen_name(data_item))
105
-
121
+
106
122
  # Optional fields- only run if there
107
- location = geocode(get_field_content(data_item, :address, :city))
123
+ location = gen_location(data_item)
108
124
  person.add_field(location) if location
109
-
125
+
110
126
  url = gen_url(data_item)
111
127
  person.add_field(url) if url
112
-
128
+
113
129
  return person
114
130
  end
115
131
 
116
132
  # Get content that should be put in field based on fields_to_use mapping
117
133
  def get_field_content(data_item, field_category, field_name)
118
- data_field = @fields_to_use[field_category][field_name]
134
+ data_field = @fields_to_use[field_category][field_name] if @fields_to_use[field_category]
119
135
 
120
136
  # Merge multiple fields if provided
121
137
  if data_field.is_a?(Array)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piplrequest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - M. C. McGrath
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-25 00:00:00.000000000 Z
11
+ date: 2016-03-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Gets data from Pipl
14
14
  email: shidash@shidash.com