swiss-village-directory 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,9 +6,27 @@ module SwissVillageDirectory
6
6
  attr_reader :villages
7
7
 
8
8
  def initialize
9
- raw_data = CSV.read(File.dirname(__FILE__) + '/../../data/PLZO_CSV_WGS84.csv', col_sep: ';')
10
- @villages = raw_data[1..-1].map do |row|
11
- Village.new(row[0], row[1], row[2], row[3], row[4], row[5], row[6])
9
+ filename = File.dirname(__FILE__) + '/../../data/PLZO_CSV_WGS84.csv'
10
+ options = { col_sep: ';', encoding: 'ISO-8859-1:UTF-8', headers: :first_row }
11
+
12
+ source_key_mapping = {
13
+ 'Ortschaftsname' => :name,
14
+ 'PLZ' => :zip_code,
15
+ 'Zusatzziffer' => :one_digit_spare,
16
+ 'Gemeindename' => :commune,
17
+ 'BFS-Nr' => :bfs_number,
18
+ 'Kantonskürzel' => :canton,
19
+ 'E' => :longitude,
20
+ 'N' => :latitude,
21
+ 'Sprache' => :language
22
+ }
23
+
24
+ villages_hashes = CSV.open(filename, options).map do |row|
25
+ row.to_h.transform_keys { |k| source_key_mapping[k] }
26
+ end
27
+
28
+ @villages = villages_hashes.map do |h|
29
+ Village.new(h[:name], h[:zip_code], h[:one_digit_spare], h[:commune], h[:canton], h[:longitude], h[:latitude])
12
30
  end
13
31
  end
14
32
 
@@ -1,3 +1,3 @@
1
1
  module SwissVillageDirectory
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
@@ -1,5 +1,4 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'swiss_village_directory/version'
5
4
 
@@ -18,9 +17,12 @@ Gem::Specification.new do |spec|
18
17
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
18
  spec.require_paths = ['lib']
20
19
 
21
- spec.add_development_dependency 'bundler', '~> 1.12'
22
- spec.add_development_dependency 'rake', '~> 10.0'
23
- spec.add_development_dependency 'rspec', '~> 3.0'
24
- spec.add_development_dependency 'rubocop', '~> 0'
25
- spec.add_development_dependency 'simplecov', '~> 0'
20
+ spec.required_ruby_version = '>= 2.5.0'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.17'
23
+ spec.add_development_dependency 'pry', '~> 0.12'
24
+ spec.add_development_dependency 'rake', '~> 12.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.8'
26
+ spec.add_development_dependency 'rubocop', '~> 0.74'
27
+ spec.add_development_dependency 'simplecov', '~> 0.17'
26
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swiss-village-directory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josua Schmid
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-07-20 00:00:00.000000000 Z
12
+ date: 2019-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -17,70 +17,84 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.12'
20
+ version: '1.17'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.12'
27
+ version: '1.17'
28
+ - !ruby/object:Gem::Dependency
29
+ name: pry
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0.12'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.12'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: rake
30
44
  requirement: !ruby/object:Gem::Requirement
31
45
  requirements:
32
46
  - - "~>"
33
47
  - !ruby/object:Gem::Version
34
- version: '10.0'
48
+ version: '12.0'
35
49
  type: :development
36
50
  prerelease: false
37
51
  version_requirements: !ruby/object:Gem::Requirement
38
52
  requirements:
39
53
  - - "~>"
40
54
  - !ruby/object:Gem::Version
41
- version: '10.0'
55
+ version: '12.0'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: rspec
44
58
  requirement: !ruby/object:Gem::Requirement
45
59
  requirements:
46
60
  - - "~>"
47
61
  - !ruby/object:Gem::Version
48
- version: '3.0'
62
+ version: '3.8'
49
63
  type: :development
50
64
  prerelease: false
51
65
  version_requirements: !ruby/object:Gem::Requirement
52
66
  requirements:
53
67
  - - "~>"
54
68
  - !ruby/object:Gem::Version
55
- version: '3.0'
69
+ version: '3.8'
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: rubocop
58
72
  requirement: !ruby/object:Gem::Requirement
59
73
  requirements:
60
74
  - - "~>"
61
75
  - !ruby/object:Gem::Version
62
- version: '0'
76
+ version: '0.74'
63
77
  type: :development
64
78
  prerelease: false
65
79
  version_requirements: !ruby/object:Gem::Requirement
66
80
  requirements:
67
81
  - - "~>"
68
82
  - !ruby/object:Gem::Version
69
- version: '0'
83
+ version: '0.74'
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: simplecov
72
86
  requirement: !ruby/object:Gem::Requirement
73
87
  requirements:
74
88
  - - "~>"
75
89
  - !ruby/object:Gem::Version
76
- version: '0'
90
+ version: '0.17'
77
91
  type: :development
78
92
  prerelease: false
79
93
  version_requirements: !ruby/object:Gem::Requirement
80
94
  requirements:
81
95
  - - "~>"
82
96
  - !ruby/object:Gem::Version
83
- version: '0'
97
+ version: '0.17'
84
98
  description:
85
99
  email:
86
100
  - josua.schmid@renuo.ch
@@ -92,6 +106,8 @@ files:
92
106
  - ".gitignore"
93
107
  - ".rspec"
94
108
  - ".rubocop.yml"
109
+ - ".rubocop_todo.yml"
110
+ - ".ruby-version"
95
111
  - ".travis.yml"
96
112
  - CODE_OF_CONDUCT.md
97
113
  - CONTRIBUTING.md
@@ -99,6 +115,7 @@ files:
99
115
  - LICENCE
100
116
  - README.md
101
117
  - Rakefile
118
+ - bin/check
102
119
  - bin/console
103
120
  - bin/setup
104
121
  - data/PLZO_CSV_WGS84.csv
@@ -119,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
136
  requirements:
120
137
  - - ">="
121
138
  - !ruby/object:Gem::Version
122
- version: '0'
139
+ version: 2.5.0
123
140
  required_rubygems_version: !ruby/object:Gem::Requirement
124
141
  requirements:
125
142
  - - ">="
@@ -127,10 +144,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
144
  version: '0'
128
145
  requirements: []
129
146
  rubyforge_project:
130
- rubygems_version: 2.4.5.1
147
+ rubygems_version: 2.7.6
131
148
  signing_key:
132
149
  specification_version: 4
133
150
  summary: This gem provides a data set of all swiss villages taken out of the "Ortschaftenverzeichnis"
134
151
  (https://data.geo.admin.ch/ch.swisstopo-vd.ortschaftenverzeichnis_plz/readme.txt)
135
152
  test_files: []
136
- has_rdoc: