orgnummer 0.0.1 → 0.1.0
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.
- checksums.yaml +4 -4
- data/README.md +16 -1
- data/lib/orgnummer.rb +29 -0
- data/orgnummer.gemspec +1 -1
- data/spec/lib/orgnummer_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8df60f0387f4b8eddc8b1ac31c373d8ba6169c38
|
4
|
+
data.tar.gz: b56cd3117a802d90620e4ef9febe5f472934639c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92a44d30b9cf9bfbaaf5917dcbceb748202eecab7742ec988017c4d5df7f4d75794b61e7a9ab63e6b8cf7c45867cb0adb3551a617fa10672a5507e600c566067
|
7
|
+
data.tar.gz: ad3026e329ab54e01b70996875f55d23fa96989b453c5777e8d248c1471ae41752dcc7ca17a41bf5c84aa1d9ac1bc89493ec1e1a10d3f9fbd141a03a10b289b4
|
data/README.md
CHANGED
@@ -16,9 +16,24 @@ Or install it yourself as:
|
|
16
16
|
|
17
17
|
$ gem install orgnummer
|
18
18
|
|
19
|
+
## Changelog
|
20
|
+
0.1.0. Added support for resolving swedish organization types
|
21
|
+
|
22
|
+
0.0.1. Initial version
|
23
|
+
|
24
|
+
|
25
|
+
|
19
26
|
## Usage
|
20
27
|
|
21
|
-
|
28
|
+
```ruby
|
29
|
+
bolag = Orgnummer.new(5568610827)
|
30
|
+
|
31
|
+
if bolag.valid?
|
32
|
+
#do something
|
33
|
+
|
34
|
+
if bolag.type_of_organization eq :aktiebolag
|
35
|
+
#do something
|
36
|
+
```
|
22
37
|
|
23
38
|
## Contributing
|
24
39
|
|
data/lib/orgnummer.rb
CHANGED
@@ -38,4 +38,33 @@ class Orgnummer
|
|
38
38
|
self.valid? ? @number[0..5] + '-' + @number[6..10] : "Not a valid number: #{@number}"
|
39
39
|
end
|
40
40
|
|
41
|
+
def type_of_organization
|
42
|
+
valid? ? get_type_from_first_char : :odefinierat
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def get_type_from_first_char
|
48
|
+
case @number[0, 1]
|
49
|
+
when '1'
|
50
|
+
:dodsbo
|
51
|
+
when '2'
|
52
|
+
:stat_landsting_kommun_forsamling
|
53
|
+
when '3'
|
54
|
+
:utlandskt_foretag
|
55
|
+
when '5'
|
56
|
+
:aktiebolag
|
57
|
+
when '6'
|
58
|
+
:enkelt_bolag
|
59
|
+
when '7'
|
60
|
+
:ekonomisk_forening
|
61
|
+
when '8'
|
62
|
+
:ideell_forening_stiftelse
|
63
|
+
when '9'
|
64
|
+
:handels_kommanditbolag
|
65
|
+
else
|
66
|
+
:odefinierat
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
41
70
|
end
|
data/orgnummer.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'orgnummer'
|
7
|
-
spec.version = '0.0
|
7
|
+
spec.version = '0.1.0'
|
8
8
|
spec.authors = ['Jonas']
|
9
9
|
spec.email = ['jonas.lundstrom@mirendo.se']
|
10
10
|
spec.description = %q{Create and validate format of the swedish organisationsnummer}
|
data/spec/lib/orgnummer_spec.rb
CHANGED
@@ -49,5 +49,19 @@ describe Orgnummer do
|
|
49
49
|
expect(short.to_s).to eq 'Not a valid number: 12'
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
describe 'type of organization' do
|
54
|
+
it 'resolves type of organization based on number' do
|
55
|
+
expect(ab.type_of_organization).to eq :aktiebolag
|
56
|
+
expect(bad_end.type_of_organization).to eq :odefinierat
|
57
|
+
expect(Orgnummer.new(1568610826).type_of_organization).to eq :dodsbo
|
58
|
+
expect(Orgnummer.new(2568610824).type_of_organization).to eq :stat_landsting_kommun_forsamling
|
59
|
+
expect(Orgnummer.new(3568610822).type_of_organization).to eq :utlandskt_foretag
|
60
|
+
expect(Orgnummer.new(6568610825).type_of_organization).to eq :enkelt_bolag
|
61
|
+
expect(Orgnummer.new(7568610823).type_of_organization).to eq :ekonomisk_forening
|
62
|
+
expect(Orgnummer.new(8568610821).type_of_organization).to eq :ideell_forening_stiftelse
|
63
|
+
expect(Orgnummer.new(9568610829).type_of_organization).to eq :handels_kommanditbolag
|
64
|
+
end
|
65
|
+
end
|
52
66
|
end
|
53
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orgnummer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|