egov_utils 1.5.0.alpha16 → 1.5.0.alpha17

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: 42577786177c1af8817f136fe3f860c925d2cd91540f49e17dc11b2fe3635397
4
- data.tar.gz: fbb299d6905f40c3102c22cb28403ff3c5c0ffd032fb1de7934d30de40c3bf92
3
+ metadata.gz: f2d9c2f0865a844342b3e80729356354092681e4f680bb90de22e68259258ed2
4
+ data.tar.gz: 6c47f3787cee7fb3415422500b5591a9fead43ac07b43b3f4a6fa57dde705a5a
5
5
  SHA512:
6
- metadata.gz: 966c54f84cf6b291350dc61a80369541fef8dc322346d2c4fffef384a07cfd37ae74a30165ab626e8d538168927f50ec79cbfb29656c7f964dd7f21c575f037a
7
- data.tar.gz: d315fe2d9a406873884bf5a3d88970b843653bf9fa5ce6254851f79fe83947e2b73b95a3bb76700d928d95606079823b92242d26ae7faea646294128e8ccd892
6
+ metadata.gz: a006382752a2064a135b8c66df67c022600b67d57b5ea51c29395b65efe0ba86f7ed5afb4682ac7e1f48915df25c426d1726bfde77d5fe8b4920e50993bffb1d
7
+ data.tar.gz: 4357089c5a0e4bab18a7e3d8481c96c54db580a5742d69ea4b9a59f8b2cb22ca3a361cdfca9fe0f0e1bbffcdf3045e374744580d8ad65902a948579806841513
@@ -3,17 +3,21 @@ module EgovUtils
3
3
 
4
4
  # before_safe :identify_address , if: :changed?
5
5
 
6
- validates :street, :city, length: 2..255
7
- validates :postcode, numericality: { only_integer: true }
8
- with_options if: :in_czech_republic? do
9
- validates :district, inclusion: { in: :district_names }
10
- validates :region, inclusion: { in: :region_names }
11
- end
12
- with_options unless: :in_czech_republic? do
13
- validates :district, inclusion: { in: :district_names }, allow_nil: true
14
- validates :region, inclusion: { in: :region_names }, allow_nil: true
6
+ with_options unless: :text_address? do
7
+ validates :street, :city, length: 2..255
8
+ validates :postcode, numericality: { only_integer: true }
9
+ with_options if: :in_czech_republic? do
10
+ validates :district, inclusion: { in: :district_names }
11
+ validates :region, inclusion: { in: :region_names }
12
+ end
13
+ with_options if: -> { !in_czech_republic? } do
14
+ validates :district, inclusion: { in: :district_names }, allow_nil: true
15
+ validates :region, inclusion: { in: :region_names }, allow_nil: true
16
+ end
17
+ validates :country, inclusion: { in: :country_ids }, allow_nil: true
15
18
  end
16
- validates :country, inclusion: { in: :country_ids }, allow_nil: true
19
+
20
+ before_validation -> { self.country = CZ_ISO_CODE if text_address? }
17
21
 
18
22
  District = Struct.new(:id, :name, :region_id)
19
23
  Region = Struct.new(:id, :name)
@@ -22,6 +26,10 @@ module EgovUtils
22
26
 
23
27
  CZ_ISO_CODE = '203'
24
28
 
29
+ def text_address?
30
+ text_address.present?
31
+ end
32
+
25
33
  def self.countries
26
34
  return @countries if @countries
27
35
  require 'csv'
@@ -99,7 +107,7 @@ module EgovUtils
99
107
  end
100
108
 
101
109
  def to_s
102
- "#{street} #{number}, #{postcode} #{city}"
110
+ text_address.presence || "#{street} #{number}, #{postcode} #{city}"
103
111
  end
104
112
 
105
113
  def prepare_egon_message(message)
@@ -8,18 +8,28 @@ module EgovUtils
8
8
  private
9
9
 
10
10
  def handle_response!
11
- EgovUtils::Address.new(
12
- street:
13
- response_body.xpath('//UliceNazev').text.presence || response_body.xpath('//CastObceNazev').text,
14
- house_number: response_body.xpath('//CisloDomovni').text,
15
- orientation_number: response_body.xpath('//CisloOrientacni').text,
16
- city: response_body.xpath('//ObecNazev').text,
17
- postcode: response_body.xpath('//PostaKod').text,
18
- egov_identifier: response_body.xpath('//AdresniMistoKod').text,
19
- country: 203,
20
- district: district.name,
21
- region: region.name
22
- )
11
+ if text_address?
12
+ EgovUtils::Address.new(
13
+ text_address: response_body.xpath('//AdresaTextem').text
14
+ )
15
+ else
16
+ EgovUtils::Address.new(
17
+ street:
18
+ response_body.xpath('//UliceNazev').text.presence || response_body.xpath('//CastObceNazev').text,
19
+ house_number: response_body.xpath('//CisloDomovni').text,
20
+ orientation_number: response_body.xpath('//CisloOrientacni').text,
21
+ city: response_body.xpath('//ObecNazev').text,
22
+ postcode: response_body.xpath('//PostaKod').text,
23
+ egov_identifier: response_body.xpath('//AdresniMistoKod').text,
24
+ country: 203,
25
+ district: district.name,
26
+ region: region.name,
27
+ )
28
+ end
29
+ end
30
+
31
+ def text_address?
32
+ response_body.xpath('//AdresaTextem').text.present?
23
33
  end
24
34
 
25
35
  def district
@@ -6,18 +6,28 @@ module EgovUtils
6
6
  private
7
7
 
8
8
  def handle_response!
9
- EgovUtils::Address.new(
10
- street:
11
- response_body.xpath('//UliceNazev').text.presence || response_body.xpath('//CastObceNazev').text,
12
- house_number: response_body.xpath('//CisloDomovni').text,
13
- orientation_number: response_body.xpath('//CisloOrientacni').text,
14
- city: response_body.xpath('//ObecNazev').text,
15
- postcode: response_body.xpath('//PostaKod').text,
16
- egov_identifier: response_body.xpath('//AdresniMistoKod').text,
17
- country: 203,
18
- district: district.name,
19
- region: region.name
20
- )
9
+ if text_address?
10
+ EgovUtils::Address.new(
11
+ text_address: response_body.xpath('//AdresaTextem').text
12
+ )
13
+ else
14
+ EgovUtils::Address.new(
15
+ street:
16
+ response_body.xpath('//UliceNazev').text.presence || response_body.xpath('//CastObceNazev').text,
17
+ house_number: response_body.xpath('//CisloDomovni').text,
18
+ orientation_number: response_body.xpath('//CisloOrientacni').text,
19
+ city: response_body.xpath('//ObecNazev').text,
20
+ postcode: response_body.xpath('//PostaKod').text,
21
+ egov_identifier: response_body.xpath('//AdresniMistoKod').text,
22
+ country: 203,
23
+ district: district.name,
24
+ region: region.name,
25
+ )
26
+ end
27
+ end
28
+
29
+ def text_address?
30
+ response_body.xpath('//AdresaTextem').text.present?
21
31
  end
22
32
 
23
33
  def district
@@ -0,0 +1,5 @@
1
+ class AddTextAddressToAddresses < ActiveRecord::Migration[7.1]
2
+ def change
3
+ add_column :egov_utils_addresses, :text_address, :string
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module EgovUtils
2
- VERSION = '1.5.0.alpha16'
2
+ VERSION = '1.5.0.alpha17'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: egov_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0.alpha16
4
+ version: 1.5.0.alpha17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondřej Ezr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-05 00:00:00.000000000 Z
11
+ date: 2025-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -779,6 +779,7 @@ files:
779
779
  - db/migrate/20230427091407_add_fields_to_registration_requests.rb
780
780
  - db/migrate/20231006131159_add_supervisor_assignment_to_registration_requests.rb
781
781
  - db/migrate/20240711130901_add_remote_id_to_people.rb
782
+ - db/migrate/20250413085634_add_text_address_to_addresses.rb
782
783
  - lib/azahara_schema_currency.rb
783
784
  - lib/azahara_schema_currency/aggregation_attribute_patch.rb
784
785
  - lib/azahara_schema_currency/association_attribute_patch.rb