hithorizons 0.4 → 0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab6f7786aec6d14befefb0c7e4a7086b6eb0ce248c085cac2b7aebc915058cb6
4
- data.tar.gz: 47c0fefec0cf906d4bad345e2befeb6060278c15e7c5bd132220f8004b43401c
3
+ metadata.gz: 0b2a3fdd9358b75537051add7674e7ed684ecaac7c450609c40a02d1cb6b1f96
4
+ data.tar.gz: 200ba0a9e296e71db76386bdcd3743ea31705efb5157d1eccb026b474246e50b
5
5
  SHA512:
6
- metadata.gz: b86030d927a6f4733e1548655cdf066c550b56c820691785db60eed26b7ca9e7fc8900ab45a2a66ce90ebaa530759016bddc97fd0c9480289271c244a56311f8
7
- data.tar.gz: dc2473e954c543b6f13b1bff27e7323d6ae7ececee12b6c1db116b14fe945e2c6f698ba4ca00ce63071e19eadc2f06468554381ace90f8af3763424a5fcf025d
6
+ metadata.gz: d5d94eaec4dcc218bed43470719ed78d0cb669756b2c6074a108d70b780797917204629901d68d2caa4eea80158bc891c82b214f50df66b3b122a29184bcaf0d
7
+ data.tar.gz: e5ec04de3143846cb682b55098124ca4013902b15b601605e6d2aa5a3a3105830cca01cf897e3f9105b70c8270e24b28b9dfd90bc6415a13af3218ea0dbb7b44
@@ -8,6 +8,7 @@ AllCops:
8
8
  Exclude:
9
9
  - 'bin/*'
10
10
  - 'tmp/**/*'
11
+ - 'spec/**/*'
11
12
 
12
13
  Layout/LineLength:
13
14
  Max: 150
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hithorizons (0.4)
4
+ hithorizons (0.5)
5
5
  faraday (~> 1)
6
6
  faraday_middleware (~> 1)
7
7
 
@@ -60,8 +60,9 @@ GEM
60
60
  unicode-display_width (>= 1.4.0, < 2.0)
61
61
  rubocop-ast (1.4.0)
62
62
  parser (>= 2.7.1.5)
63
- rubocop-rspec (1.42.0)
64
- rubocop (>= 0.87.0)
63
+ rubocop-rspec (2.1.0)
64
+ rubocop (~> 1.0)
65
+ rubocop-ast (>= 1.1.0)
65
66
  ruby-progressbar (1.11.0)
66
67
  ruby2_keywords (0.0.2)
67
68
  simplecov (0.21.1)
@@ -85,7 +86,7 @@ DEPENDENCIES
85
86
  rake (~> 13.0)
86
87
  rspec (~> 3.6)
87
88
  rubocop (~> 1.7)
88
- rubocop-rspec (~> 1.42)
89
+ rubocop-rspec (~> 2)
89
90
  simplecov (~> 0.21)
90
91
  webmock (~> 3.11.0)
91
92
 
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'hithorizons'
@@ -14,3 +14,6 @@ Response object fix
14
14
 
15
15
  ## 0.4
16
16
  Helpers, readme
17
+
18
+ ## 0.5
19
+ Better countries API
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency 'rake', '~> 13.0'
35
35
  spec.add_development_dependency 'rspec', '~> 3.6'
36
36
  spec.add_development_dependency 'rubocop', '~> 1.7'
37
- spec.add_development_dependency 'rubocop-rspec', '~> 1.42'
37
+ spec.add_development_dependency 'rubocop-rspec', '~> 2'
38
38
  spec.add_development_dependency 'simplecov', '~> 0.21'
39
39
  spec.add_development_dependency 'webmock', '~> 3.11.0'
40
40
  end
@@ -6,6 +6,7 @@ require 'faraday_middleware'
6
6
  require 'hithorizons/version'
7
7
  require 'hithorizons/configuration'
8
8
  require 'hithorizons/company'
9
+ require 'hithorizons/country'
9
10
  require 'hithorizons/countries'
10
11
  require 'hithorizons/company_types'
11
12
  require 'hithorizons/industry_types'
@@ -2,71 +2,71 @@
2
2
 
3
3
  module Hithorizons
4
4
  class Countries
5
- MAPPING = {
6
- ALB: 'ALBANIA',
7
- AND: 'ANDORRA',
8
- ARM: 'ARMENIA',
9
- AUS: 'AUSTRIA',
10
- AZE: 'AZERBAIJAN',
11
- BLR: 'BELARUS',
12
- BEL: 'BELGIUM',
13
- BIH: 'BOSNIA AND HERZEGOVINA',
14
- BGR: 'BULGARIA',
15
- HRV: 'CROATIA',
16
- CYP: 'CYPRUS',
17
- CZE: 'CZECH REPUBLIC',
18
- DNK: 'DENMARK',
19
- GBR: 'ENGLAND',
20
- EST: 'ESTONIA',
21
- FRO: 'FAROE ISLANDS',
22
- FIN: 'FINLAND',
23
- FRA: 'FRANCE',
24
- GEO: 'GEORGIA',
25
- DEU: 'GERMANY',
26
- GIB: 'GIBRALTAR',
27
- GRC: 'GREECE',
28
- GRL: 'GREENLAND',
29
- HUN: 'HUNGARY',
30
- ISL: 'ICELAND',
31
- ITA: 'ITALY',
32
- KAZ: 'KAZAKHSTAN',
33
- XKX: 'KOSOVO',
34
- KGZ: 'KYRGYZSTAN',
35
- LVA: 'LATVIA',
36
- LIE: 'LIECHTENSTEIN',
37
- LTU: 'LITHUANIA',
38
- LUX: 'LUXEMBOURG',
39
- MKD: 'MACEDONIA',
40
- MLT: 'MALTA',
41
- MDA: 'MOLDOVA',
42
- MCO: 'MONACO',
43
- MNE: 'MONTENEGRO',
44
- NLD: 'NETHERLANDS',
45
- NOR: 'NORWAY',
46
- POL: 'POLAND',
47
- PRT: 'PORTUGAL',
48
- ROU: 'ROMANIA',
49
- RUS: 'RUSSIAN FEDERATION',
50
- SMR: 'SAN MARINO',
51
- SRB: 'SERBIA',
52
- SVK: 'SLOVAKIA',
53
- SVN: 'SLOVENIA',
54
- ESP: 'SPAIN',
55
- SWE: 'SWEDEN',
56
- CHE: 'SWITZERLAND',
57
- TJK: 'TAJIKISTAN',
58
- TUR: 'TURKEY',
59
- TKM: 'TURKMENISTAN',
60
- UKR: 'UKRAINE',
61
- UZB: 'UZBEKISTAN',
62
- }.freeze
5
+ LIST = [
6
+ ['ALB', 'ALBANIA', true],
7
+ ['AND', 'ANDORRA', true],
8
+ ['ARM', 'ARMENIA', true],
9
+ ['AUS', 'AUSTRIA', false],
10
+ ['AZE', 'AZERBAIJAN', true],
11
+ ['BLR', 'BELARUS', true],
12
+ ['BEL', 'BELGIUM', true],
13
+ ['BIH', 'BOSNIA AND HERZEGOVINA', true],
14
+ ['BGR', 'BULGARIA', true],
15
+ ['HRV', 'CROATIA', true],
16
+ ['CYP', 'CYPRUS', false],
17
+ ['CZE', 'CZECH REPUBLIC', true],
18
+ ['DNK', 'DENMARK', true],
19
+ ['GBR', 'ENGLAND', false],
20
+ ['EST', 'ESTONIA', false],
21
+ ['FRO', 'FAROE ISLANDS', true],
22
+ ['FIN', 'FINLAND', true],
23
+ ['FRA', 'FRANCE', false],
24
+ ['GEO', 'GEORGIA', true],
25
+ ['DEU', 'GERMANY', false],
26
+ ['GIB', 'GIBRALTAR', true],
27
+ ['GRC', 'GREECE', true],
28
+ ['GRL', 'GREENLAND', true],
29
+ ['HUN', 'HUNGARY', false],
30
+ ['ISL', 'ICELAND', true],
31
+ ['ITA', 'ITALY', true],
32
+ ['KAZ', 'KAZAKHSTAN', true],
33
+ ['XKX', 'KOSOVO', true],
34
+ ['KGZ', 'KYRGYZSTAN', true],
35
+ ['LVA', 'LATVIA', false],
36
+ ['LIE', 'LIECHTENSTEIN', false],
37
+ ['LTU', 'LITHUANIA', true],
38
+ ['LUX', 'LUXEMBOURG', false],
39
+ ['MKD', 'MACEDONIA', true],
40
+ ['MLT', 'MALTA', false],
41
+ ['MDA', 'MOLDOVA', true],
42
+ ['MCO', 'MONACO', true],
43
+ ['MNE', 'MONTENEGRO', true],
44
+ ['NLD', 'NETHERLANDS', false],
45
+ ['NOR', 'NORWAY', true],
46
+ ['POL', 'POLAND', true],
47
+ ['PRT', 'PORTUGAL', true],
48
+ ['ROU', 'ROMANIA', false],
49
+ ['RUS', 'RUSSIAN FEDERATION', true],
50
+ ['SMR', 'SAN MARINO', true],
51
+ ['SRB', 'SERBIA', true],
52
+ ['SVK', 'SLOVAKIA', true],
53
+ ['SVN', 'SLOVENIA', false],
54
+ ['ESP', 'SPAIN', true],
55
+ ['SWE', 'SWEDEN', false],
56
+ ['CHE', 'SWITZERLAND', true],
57
+ ['TJK', 'TAJIKISTAN', true],
58
+ ['TUR', 'TURKEY', true],
59
+ ['TKM', 'TURKMENISTAN', true],
60
+ ['UKR', 'UKRAINE', true],
61
+ ['UZB', 'UZBEKISTAN', true],
62
+ ].map { |country| Country.new(*country) }
63
63
 
64
64
  def self.find_by_iso3(iso3)
65
- MAPPING[iso3.upcase.to_sym] if iso3
65
+ LIST.find { |country| country.iso3 == iso3 }
66
66
  end
67
67
 
68
- def self.iso3_by_country(country)
69
- MAPPING.invert[country]
68
+ def self.find_by_name(country_name)
69
+ LIST.find { |country| country.name == country_name }
70
70
  end
71
71
  end
72
72
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hithorizons
4
+ class Country
5
+ attr_reader :iso3, :name
6
+
7
+ def initialize(iso3, name, registration_number)
8
+ @iso3 = iso3
9
+ @name = name
10
+ @registration_number = registration_number
11
+ end
12
+
13
+ def vat_id?
14
+ !@registration_number
15
+ end
16
+
17
+ def registration_number?
18
+ @registration_number
19
+ end
20
+
21
+ def vat_id(company)
22
+ return unless vat_id?
23
+
24
+ case iso3
25
+ when 'HUN'
26
+ "HU#{company['NationalId'][0...-3]}"
27
+ when 'ROU'
28
+ "RO#{company['NationalId']}"
29
+ else
30
+ company['NationalId']
31
+ end
32
+ end
33
+
34
+ def tax_id(company)
35
+ case iso3
36
+ when 'HUN', 'ROU'
37
+ company['NationalId']
38
+ end
39
+ end
40
+
41
+ def registration_number(company)
42
+ @registration_number ? company['NationalId'] : nil
43
+ end
44
+ end
45
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hithorizons
4
- VERSION = '0.4'
4
+ VERSION = '0.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hithorizons
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '0.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lubomir Vnenk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-06 00:00:00.000000000 Z
11
+ date: 2021-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.42'
103
+ version: '2'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.42'
110
+ version: '2'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -166,6 +166,7 @@ files:
166
166
  - lib/hithorizons/company_types.rb
167
167
  - lib/hithorizons/configuration.rb
168
168
  - lib/hithorizons/countries.rb
169
+ - lib/hithorizons/country.rb
169
170
  - lib/hithorizons/industry_types.rb
170
171
  - lib/hithorizons/version.rb
171
172
  homepage: https://github.com/lubosch/hithorizons