postnummer_norge 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/build.yml +37 -0
- data/.gitignore +1 -1
- data/.rubocop.yml +21 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +81 -0
- data/README.md +17 -0
- data/Rakefile +13 -0
- data/lib/postnummer_norge/postal_code.rb +10 -10
- data/lib/postnummer_norge/postal_codes.tab +3990 -3430
- data/lib/postnummer_norge/version.rb +3 -1
- data/lib/postnummer_norge.rb +2 -2
- data/postnummer_norge.gemspec +8 -10
- data/spec/postnummer_norge/postal_code_spec.rb +62 -0
- data/spec/spec_helper.rb +8 -2
- metadata +36 -88
- data/README.rdoc +0 -11
- data/spec/lib/postal_code_spec.rb +0 -30
data/lib/postnummer_norge.rb
CHANGED
data/postnummer_norge.gemspec
CHANGED
@@ -1,25 +1,23 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
3
4
|
require "postnummer_norge/version"
|
4
5
|
|
5
6
|
Gem::Specification.new do |s|
|
6
7
|
s.name = "postnummer_norge"
|
7
8
|
s.version = PostnummerNorge::VERSION
|
8
9
|
s.authors = ["Inge Jørgensen"]
|
9
|
-
s.email = ["inge@
|
10
|
+
s.email = ["inge@anyone.no"]
|
10
11
|
s.homepage = ""
|
11
|
-
s.summary =
|
12
|
-
s.summary = %q{Ruby gem for looking up and verifying Norwegian postal codes}
|
12
|
+
s.summary = "Norwegian postal codes"
|
13
13
|
|
14
|
-
|
14
|
+
s.required_ruby_version = ">= 3.0.0"
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
|
-
s.
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
19
18
|
s.require_paths = ["lib"]
|
20
19
|
|
21
20
|
# specify any dependencies here; for example:
|
22
|
-
s.add_development_dependency "rspec", ">= 2.10.0"
|
23
|
-
s.add_development_dependency "rake", "0.9.2.2"
|
24
21
|
# s.add_runtime_dependency "rest-client"
|
22
|
+
s.metadata["rubygems_mfa_required"] = "true"
|
25
23
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
require "postnummer_norge"
|
5
|
+
|
6
|
+
describe PostnummerNorge::PostalCode do
|
7
|
+
describe "#exists?" do
|
8
|
+
subject { described_class.exists?(code) }
|
9
|
+
|
10
|
+
context "when code exists" do
|
11
|
+
let(:code) { "0662" }
|
12
|
+
|
13
|
+
it { is_expected.to be(true) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "when code does not exist" do
|
17
|
+
let(:code) { "0002" }
|
18
|
+
|
19
|
+
it { is_expected.to be(false) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#find" do
|
24
|
+
subject(:postal_code) { described_class.find(code) }
|
25
|
+
|
26
|
+
context "when code exists" do
|
27
|
+
let(:code) { "4085" }
|
28
|
+
|
29
|
+
it { is_expected.to be_a(described_class) }
|
30
|
+
specify { expect(postal_code.name).to eq("HUNDVÅG") }
|
31
|
+
specify { expect(postal_code.municipality).to eq("STAVANGER") }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when code does not exist" do
|
35
|
+
let(:code) { "0002" }
|
36
|
+
|
37
|
+
it { is_expected.to be_nil }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#find_by_name" do
|
42
|
+
subject(:results) { described_class.find_by_name(name) }
|
43
|
+
|
44
|
+
let(:postal_code) { results.first }
|
45
|
+
|
46
|
+
context "when name exists" do
|
47
|
+
let(:name) { "HUNDVÅG" }
|
48
|
+
|
49
|
+
it { is_expected.to be_an(Array) }
|
50
|
+
specify { expect(postal_code).to be_a(described_class) }
|
51
|
+
specify { expect(postal_code.code).to eq("4077") }
|
52
|
+
specify { expect(postal_code.name).to eq("HUNDVÅG") }
|
53
|
+
specify { expect(postal_code.municipality).to eq("STAVANGER") }
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when name does not exist" do
|
57
|
+
let(:name) { "XYZZYX" }
|
58
|
+
|
59
|
+
it { is_expected.to be_nil }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,109 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: postnummer_norge
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 0.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
14
|
-
autorequire:
|
6
|
+
authors:
|
7
|
+
- Inge Jørgensen
|
8
|
+
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
none: false
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
hash: 39
|
27
|
-
segments:
|
28
|
-
- 2
|
29
|
-
- 10
|
30
|
-
- 0
|
31
|
-
version: 2.10.0
|
32
|
-
name: rspec
|
33
|
-
type: :development
|
34
|
-
prerelease: false
|
35
|
-
requirement: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
|
-
none: false
|
39
|
-
requirements:
|
40
|
-
- - "="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
hash: 11
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
- 9
|
46
|
-
- 2
|
47
|
-
- 2
|
48
|
-
version: 0.9.2.2
|
49
|
-
name: rake
|
50
|
-
type: :development
|
51
|
-
prerelease: false
|
52
|
-
requirement: *id002
|
53
|
-
description:
|
54
|
-
email:
|
55
|
-
- inge@manualdesign.no
|
11
|
+
date: 2023-11-13 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- inge@anyone.no
|
56
16
|
executables: []
|
57
|
-
|
58
17
|
extensions: []
|
59
|
-
|
60
18
|
extra_rdoc_files: []
|
61
|
-
|
62
|
-
|
63
|
-
- .gitignore
|
19
|
+
files:
|
20
|
+
- ".github/workflows/build.yml"
|
21
|
+
- ".gitignore"
|
22
|
+
- ".rubocop.yml"
|
64
23
|
- Gemfile
|
65
|
-
-
|
24
|
+
- Gemfile.lock
|
25
|
+
- README.md
|
66
26
|
- Rakefile
|
67
27
|
- lib/postnummer_norge.rb
|
68
28
|
- lib/postnummer_norge/postal_code.rb
|
69
29
|
- lib/postnummer_norge/postal_codes.tab
|
70
30
|
- lib/postnummer_norge/version.rb
|
71
31
|
- postnummer_norge.gemspec
|
72
|
-
- spec/
|
32
|
+
- spec/postnummer_norge/postal_code_spec.rb
|
73
33
|
- spec/spec_helper.rb
|
74
|
-
homepage:
|
34
|
+
homepage: ''
|
75
35
|
licenses: []
|
76
|
-
|
77
|
-
|
36
|
+
metadata:
|
37
|
+
rubygems_mfa_required: 'true'
|
38
|
+
post_install_message:
|
78
39
|
rdoc_options: []
|
79
|
-
|
80
|
-
require_paths:
|
40
|
+
require_paths:
|
81
41
|
- lib
|
82
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
-
|
84
|
-
requirements:
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
85
44
|
- - ">="
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
version: "0"
|
91
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
-
none: false
|
93
|
-
requirements:
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.0.0
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
94
49
|
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
|
97
|
-
segments:
|
98
|
-
- 0
|
99
|
-
version: "0"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
100
52
|
requirements: []
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
summary: Ruby gem for looking up and verifying Norwegian postal codes
|
107
|
-
test_files:
|
108
|
-
- spec/lib/postal_code_spec.rb
|
109
|
-
- spec/spec_helper.rb
|
53
|
+
rubygems_version: 3.4.10
|
54
|
+
signing_key:
|
55
|
+
specification_version: 4
|
56
|
+
summary: Norwegian postal codes
|
57
|
+
test_files: []
|
data/README.rdoc
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
include PostnummerNorge
|
5
|
-
|
6
|
-
describe PostnummerNorge::PostalCode do
|
7
|
-
|
8
|
-
it 'checks for existence' do
|
9
|
-
PostalCode.exists?('0662').should be_true
|
10
|
-
PostalCode.exists?('0002').should be_false
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'finds postal code by number' do
|
14
|
-
postal_code = PostalCode.find('4085')
|
15
|
-
postal_code.should be_kind_of(PostalCode)
|
16
|
-
postal_code.name.should == 'HUNDVÅG'
|
17
|
-
postal_code.municipality.should == 'STAVANGER'
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'returns nil for invalid postal codes' do
|
21
|
-
PostalCode.find('0002').should be_nil
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'finds postal code by name' do
|
25
|
-
postal_code = PostalCode.find_by_name('HUNDVÅG').first
|
26
|
-
postal_code.should be_kind_of(PostalCode)
|
27
|
-
postal_code.code.should == '4085'
|
28
|
-
postal_code.name.should == 'HUNDVÅG'
|
29
|
-
end
|
30
|
-
end
|