portal_scraper 1.6.0 → 1.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a542aac9f217de2e57612d41dcea49244113a8bd5df4b4a75f68f3bbee929f3
4
- data.tar.gz: 0a81730c139e278ec244b146262c4f20a0ab2541dbc560e6f9113641dcefafc4
3
+ metadata.gz: 720b81f1806f9e135f471667556e9cbe322bbd6cd7d3a0e52c13a4f998c0626d
4
+ data.tar.gz: e891188589e402071e65fa9dc53309ca653267167a9e5bc789426b1f8bdf430e
5
5
  SHA512:
6
- metadata.gz: f5878b31e717280e896190b54ec68992729123466c163f6829e9553b8cab5db31a4f73d6cff3b047377cb8c8321fcfa9614cad5a85d7a6f25b894f7001b22f44
7
- data.tar.gz: 7e55493099947d44c3a7a0d73f2cd3713c228f8cdecbffd92e5495261d752554e759649c9865c0b397ad114bea5a461b21f3c985605a31bc1e91771ef1eb734d
6
+ metadata.gz: a486c14f993b7daef03e648df44b7f306efcf9efa0c63d39e79c43821823bf4205ee1e84a122a178c5957016c0941acb307ec07829380f00b56edf6cd9634bdf
7
+ data.tar.gz: 608fd996c6bed19039ce3bcc1d1da3d29d2bb77135063b17fd814f69bad5185e0e815d6f2d4a779edeaa983efff6781aa9be1ff607e664fe1692c6a0c9260506
@@ -48,8 +48,9 @@ module PortalScraper
48
48
  form['commune'] = user[:codeInsee]
49
49
  form['libCommune'] = user[:ville]
50
50
  else
51
- fill_commune(app, form, user[:codePostal], format_city_name(user[:ville]))
51
+ fill_commune(app, form, user[:codePostal], format_city_name(user[:ville]), user[:pays] || user[:libNation])
52
52
  end
53
+ fill_address(form, user[:numeroVoie])
53
54
  fill_birth_place(form, user[:paysNaissance])
54
55
  form['modeContact'] = ''
55
56
  form['creerTiers'] = 'Créer'
@@ -127,13 +128,22 @@ module PortalScraper
127
128
  end
128
129
  end
129
130
 
130
- def fill_commune(app, form, postal_code, city)
131
+ def fill_commune(app, form, postal_code, city, country_code)
131
132
  app.post(url_for('/tiersCommunes.do'), { codPos: postal_code }).tap do |mappings|
132
133
  cities = mappings.search('td.t').map { |c| { code: c.parent.search('a.PL_LST').text.strip, name: c.text.strip } }
133
134
  matched_city = cities.find(-> { cities.first }) { |c| c[:name].include?(city) }
134
135
  form['commune'] = matched_city[:code]
135
136
  form['libCommune'] = matched_city[:name]
136
137
  end
138
+ form['territoireRes'] = CODE_TO_COUNTRY_MAPPING.dig(country_code, 'category')
139
+ end
140
+
141
+ def fill_address(form, address)
142
+ address, additional_information = address.split("\n")
143
+ form['numeroVoie'] = address
144
+ if additional_information
145
+ form['lieudit'] = additional_information
146
+ end
137
147
  end
138
148
 
139
149
  def fill_birth_place(form, country_code)
@@ -1,7 +1,7 @@
1
1
  module PortalScraper
2
2
  class Version
3
3
  MAJOR = 1
4
- MINOR = 6
4
+ MINOR = 7
5
5
  PATCH = 0
6
6
 
7
7
  def self.to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: portal_scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Armand Mégrot
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-09-18 00:00:00.000000000 Z
12
+ date: 2019-11-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mechanize