swiss-village-directory 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,13 @@
1
+ require 'swiss_village_directory/repository'
2
+ require 'swiss_village_directory/version'
3
+ require 'swiss_village_directory/village'
4
+
5
+ module SwissVillageDirectory
6
+ def self.repository
7
+ @repository ||= Repository.new
8
+ end
9
+
10
+ def self.villages
11
+ repository.villages
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ require 'swiss_village_directory/village'
2
+ require 'csv'
3
+
4
+ module SwissVillageDirectory
5
+ class Repository
6
+ attr_reader :villages
7
+
8
+ def initialize
9
+ raw_data = CSV.read('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])
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module SwissVillageDirectory
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,15 @@
1
+ module SwissVillageDirectory
2
+ class Village
3
+ attr_reader :name, :zip_code, :one_digit_spare, :commune, :canton, :longitude, :latitude
4
+
5
+ def initialize(name, zip_code, one_digit_spare, commune, canton, longitude, latitude)
6
+ @name = name
7
+ @zip_code = zip_code.to_i
8
+ @one_digit_spare = one_digit_spare.to_i
9
+ @commune = commune
10
+ @canton = canton
11
+ @longitude = longitude.to_f
12
+ @latitude = latitude.to_f
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'swiss_village_directory/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'swiss-village-directory'
8
+ spec.version = SwissVillageDirectory::VERSION
9
+ spec.authors = ['Josua Schmid']
10
+ spec.email = ['josua.schmid@renuo.ch']
11
+
12
+ spec.summary = 'This gem provides a data set of all swiss villages taken out of the "Ortschaftenverzeichnis" (https://data.geo.admin.ch/ch.swisstopo-vd.ortschaftenverzeichnis_plz/readme.txt)'
13
+ spec.homepage = 'https://github.com/renuo/swiss-village-directory'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
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'
26
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: swiss-village-directory
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Josua Schmid
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - josua.schmid@renuo.ch
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".rubocop.yml"
93
+ - ".travis.yml"
94
+ - CODE_OF_CONDUCT.md
95
+ - CONTRIBUTING.md
96
+ - Gemfile
97
+ - LICENCE
98
+ - README.md
99
+ - Rakefile
100
+ - bin/console
101
+ - bin/setup
102
+ - data/PLZO_CSV_WGS84.csv
103
+ - lib/swiss_village_directory.rb
104
+ - lib/swiss_village_directory/repository.rb
105
+ - lib/swiss_village_directory/version.rb
106
+ - lib/swiss_village_directory/village.rb
107
+ - swiss-village-directory.gemspec
108
+ homepage: https://github.com/renuo/swiss-village-directory
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.5.1
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: This gem provides a data set of all swiss villages taken out of the "Ortschaftenverzeichnis"
132
+ (https://data.geo.admin.ch/ch.swisstopo-vd.ortschaftenverzeichnis_plz/readme.txt)
133
+ test_files: []
134
+ has_rdoc: