egov_utils 0.1.4 → 0.1.5

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: 0f63fa0be85c1b24f142e25d3ba88b06aa28746c
4
- data.tar.gz: f591df909e11cc230e68a12c51a2a8324db9dd9d
3
+ metadata.gz: 2b4f8d1e7b832f1e39353978e0227fe9fe46c337
4
+ data.tar.gz: f196d70f9d135cd16c39dbc26d95348f35892868
5
5
  SHA512:
6
- metadata.gz: 54147634748dbca9e1c632fb0a7be76663a5b7295e14180d26d9eaa99926a4f953ee063132ad29da18b1e64c4c1edae46e25df6e193f181b728c571edbc05581
7
- data.tar.gz: 36ef6a4509dd5173c9027c4585341a33701992bf1ba7df49fd4371de8baf8d6a401d0557e648bafc926d1e13de344bb45002dae4a3ad5d7c30c30f67efcf9ed1
6
+ metadata.gz: d49271e7e63b551bc7ea734aca1051f53dd4927b9924bd02714a01b9b3f5b4cbab5b97b15bde02db068c544ccc6c17a13577f8d681057a3ec02533728dcfeab1
7
+ data.tar.gz: dba5631a2185d2a7b26f9acbec86a57a1ecc74ba55a88ce734ecc71d1e91d83db1471d69f78957406d03782e6edb35e3913b2067cd898a9443b3a259c870dc41
@@ -5,6 +5,8 @@ module EgovUtils
5
5
 
6
6
  validates :street, :city, length: 3..255
7
7
  validates :postcode, numericality: { only_integer: true }
8
+ validates :district, inclusion: { in: :district_names }
9
+ validates :region, inclusion: { in: :region_names }
8
10
 
9
11
  District = Struct.new(:id, :name, :region_id)
10
12
  Region = Struct.new(:id, :name)
@@ -34,8 +36,16 @@ module EgovUtils
34
36
  regions.detect{|r| r[:id] == district[:region_id] } if district
35
37
  end
36
38
 
39
+ def district_names
40
+ self.class.districts.collect{|r| r[:name]}
41
+ end
42
+ def region_names
43
+ self.class.regions.collect{|r| r[:name]}
44
+ end
45
+
46
+
37
47
  def district=(value)
38
- self.region = self.class.region_for_district(value)[:name]
48
+ self.region = self.class.region_for_district(value).try(:[], :name)
39
49
  super
40
50
  end
41
51
 
@@ -9,7 +9,7 @@
9
9
  .col-12
10
10
  = form.text_field :city
11
11
  = form.text_field :postcode
12
- = form.text_field :district
12
+ = form.select :district, EgovUtils::Address.districts.collect{|r| [r[:name],r[:name]]}
13
13
  = form.select :region, EgovUtils::Address.regions.collect{|r| [r[:name],r[:name]]}
14
14
  -# form.text_field :country
15
15
  %div.validation-button
@@ -1,3 +1,3 @@
1
1
  module EgovUtils
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
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: 0.1.4
4
+ version: 0.1.5
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: 2017-09-15 00:00:00.000000000 Z
11
+ date: 2017-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -329,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
329
329
  version: '0'
330
330
  requirements: []
331
331
  rubyforge_project:
332
- rubygems_version: 2.5.2
332
+ rubygems_version: 2.6.13
333
333
  signing_key:
334
334
  specification_version: 4
335
335
  summary: The eGoverment utilities is set of functionalities to support basic eGoverment