swissmatch-location 0.0.1

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.
@@ -0,0 +1,38 @@
1
+ TEST_DATA_DIR = File.expand_path('../../data', __FILE__)
2
+
3
+ require 'stringio'
4
+ require 'test/swissmatch_location_fixtures'
5
+
6
+ module TestSuite
7
+ attr_accessor :name
8
+ end
9
+
10
+ module Kernel
11
+ def suite(name, &block)
12
+ klass = Class.new(Test::Unit::TestCase, &block)
13
+ klass.extend TestSuite
14
+ klass.name = "Suite #{name}"
15
+
16
+ klass
17
+ end
18
+ module_function :suite
19
+ end
20
+
21
+ class Test::Unit::TestCase
22
+ def self.test(desc, &impl)
23
+ define_method("test #{desc}", &impl)
24
+ end
25
+
26
+ def read_data(path, *options)
27
+ File.read(File.expand_path(path, TEST_DATA_DIR), *options)
28
+ end
29
+
30
+ def capture_stdout
31
+ captured = StringIO.new
32
+ $stdout = captured
33
+ yield
34
+ captured.string
35
+ ensure
36
+ $stdout = STDOUT
37
+ end
38
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+
3
+ require 'swissmatch/location'
4
+ require 'swissmatch/datafiles'
5
+
6
+ SwissMatch.load(SwissMatch::DataFiles.new(TEST_DATA_DIR))
data/test/runner.rb ADDED
@@ -0,0 +1,20 @@
1
+ # run with `ruby test/runner.rb`
2
+ # if you only want to run a single test-file: `ruby test/runner.rb testfile.rb`
3
+
4
+ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
5
+ $LOAD_PATH << File.expand_path('../../test/lib', __FILE__)
6
+ TEST_DIR = File.expand_path('../../test', __FILE__)
7
+
8
+ require 'test/unit'
9
+ require 'helper'
10
+
11
+ if ENV['COVERAGE']
12
+ require 'simplecov'
13
+ SimpleCov.start
14
+ end
15
+
16
+ units = ARGV.empty? ? Dir["#{TEST_DIR}/unit/**/*.rb"] : ARGV
17
+
18
+ units.each do |unit|
19
+ load unit
20
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ require 'swissmatch/location'
4
+
5
+ suite "SwissMatch::Location" do
6
+
7
+ test "SwissMatch::canton" do
8
+ assert_kind_of SwissMatch::Canton, SwissMatch.canton('ZH')
9
+ end
10
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ require 'swissmatch/location'
4
+
5
+ suite "SwissMatch::ZipCodes" do
6
+
7
+ test "SwissMatch::ZipCodes\#[]" do
8
+ zip_codes = SwissMatch.zip_codes
9
+ assert_kind_of SwissMatch::ZipCode, zip_codes[805200]
10
+ assert_kind_of SwissMatch::ZipCode, zip_codes["805200"]
11
+ assert_kind_of SwissMatch::ZipCode, zip_codes[8052, 0]
12
+ assert_kind_of SwissMatch::ZipCode, zip_codes["8052", 0]
13
+ assert_kind_of SwissMatch::ZipCode, zip_codes[8052, "0"]
14
+ assert_kind_of SwissMatch::ZipCode, zip_codes["8052", 0]
15
+ assert_kind_of SwissMatch::ZipCode, zip_codes[8052, "Zürich"]
16
+ assert_kind_of SwissMatch::ZipCode, zip_codes["8052", "Zürich"]
17
+ assert_kind_of SwissMatch::ZipCodes, zip_codes[8052]
18
+ assert_kind_of SwissMatch::ZipCodes, zip_codes["8052"]
19
+ assert_kind_of SwissMatch::ZipCodes, zip_codes["Zürich"]
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: swissmatch-location
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Stefan Rusterholz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rubyzip
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: autocompletion
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.0.2
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.0.2
46
+ description: ! 'Deal with swiss cantons, communities and zip codes, as provided by
47
+ the swiss postal
48
+
49
+ service.
50
+
51
+ Additionally handle data updates provided by the swiss postal service.'
52
+ email: stefan.rusterholz@gmail.com
53
+ executables: []
54
+ extensions: []
55
+ extra_rdoc_files: []
56
+ files:
57
+ - data/swissmatch/plz_c_20120723.txt
58
+ - data/swissmatch/plz_p1_20120723.txt
59
+ - data/swissmatch/plz_p2_20120723.txt
60
+ - lib/swissmatch/canton.rb
61
+ - lib/swissmatch/cantons.rb
62
+ - lib/swissmatch/communities.rb
63
+ - lib/swissmatch/community.rb
64
+ - lib/swissmatch/datafiles.rb
65
+ - lib/swissmatch/loaderror.rb
66
+ - lib/swissmatch/location/autoload.rb
67
+ - lib/swissmatch/location/ruby.rb
68
+ - lib/swissmatch/location/version.rb
69
+ - lib/swissmatch/location.rb
70
+ - lib/swissmatch/name.rb
71
+ - lib/swissmatch/zip.rb
72
+ - lib/swissmatch/zipcode.rb
73
+ - lib/swissmatch/zipcodes.rb
74
+ - test/data/plz_c_20120000.txt
75
+ - test/data/plz_p1_20120000.txt
76
+ - test/data/plz_p1up_20120000.txt
77
+ - test/data/plz_p2_20120000.txt
78
+ - test/lib/helper.rb
79
+ - test/lib/test/swissmatch_location_fixtures.rb
80
+ - test/runner.rb
81
+ - test/unit/lib/swissmatch/location.rb
82
+ - test/unit/lib/swissmatch/zip_codes.rb
83
+ - swissmatch-location.gemspec
84
+ - LICENSE.txt
85
+ - Rakefile
86
+ - README.markdown
87
+ homepage: http://github.com/apeiros/swissmatch-location
88
+ licenses: []
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>'
103
+ - !ruby/object:Gem::Version
104
+ version: 1.3.1
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 1.8.24
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: Deal with swiss zip codes, cantons and communities.
111
+ test_files: []
112
+ has_rdoc: