german_phone_number_classifier 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7037e6228f339903baadc28547edf3772bda25028a1983ad6b44b06a10492e5d
4
+ data.tar.gz: 941894cc3a2ffeee49625cff3661e0d6f85d5e9ecd21ab52cc96b13bafaf2c96
5
+ SHA512:
6
+ metadata.gz: ccd52c370e5051b5de558bb6d35665d018ce2f0610723c19b6087bed83812ea1f2ae3ea0c06d5fad6e7711babb822fd43343267370ab9116fd7d1686e9c79772
7
+ data.tar.gz: df9214f2c4dfe738708e957a8e0578da9cfca22bc70273ee32ea5b1d20d78fe93bfc33653d13ecf823a34a3070988212e47f1f676f83f934be05be6d46155a18
@@ -0,0 +1,61 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Rspec & Coverage
9
+
10
+ on:
11
+ push:
12
+ branches: [ main ]
13
+ pull_request:
14
+ branches: [ main ]
15
+
16
+ jobs:
17
+ rubocop:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['2.7.2']
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
+ # uses: ruby/setup-ruby@v1
30
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
31
+ with:
32
+ ruby-version: ${{ matrix.ruby-version }}
33
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
+ - name: Run rubocop
35
+ run: bundle exec rubocop
36
+
37
+ test:
38
+
39
+ runs-on: ubuntu-latest
40
+ strategy:
41
+ matrix:
42
+ ruby-version: ['2.7.2','3.0.0']
43
+
44
+ steps:
45
+ - uses: actions/checkout@v2
46
+ - name: Set up Ruby
47
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
48
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
49
+ # uses: ruby/setup-ruby@v1
50
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
51
+ with:
52
+ ruby-version: ${{ matrix.ruby-version }}
53
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
54
+ - name: Run tests
55
+ run: bundle exec rspec
56
+ - name: Upload coverage results
57
+ uses: actions/upload-artifact@master
58
+ if: ${{ matrix.ruby-version }} == '2.7.2' # we only need one report from the build matrix
59
+ with:
60
+ name: coverage-report
61
+ path: coverage
data/.gitignore ADDED
@@ -0,0 +1,57 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ # Gemfile.lock
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
57
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ AllCops:
2
+ SuggestExtensions: false
3
+ NewCops: enable
4
+ Metrics/BlockLength:
5
+ IgnoredMethods: ['describe', 'context']
6
+ Metrics/ModuleLength:
7
+ Exclude:
8
+ - 'lib/german_phone_number_classifier/german_landline_prefixes.rb'
9
+ Metrics/MethodLength:
10
+ Exclude:
11
+ - 'lib/german_phone_number_classifier.rb'
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.4
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.4.5
7
+ before_install: gem install bundler -v 2.0.2
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in german_phone_number_classifier.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,79 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ german_phone_number_classifier (1.0.0.pre)
5
+ phony (~> 2.19.9)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ansi (1.5.0)
11
+ ast (2.4.2)
12
+ byebug (11.1.3)
13
+ diff-lcs (1.5.0)
14
+ docile (1.4.0)
15
+ parallel (1.22.1)
16
+ parser (3.1.2.0)
17
+ ast (~> 2.4.1)
18
+ phony (2.19.11)
19
+ rainbow (3.1.1)
20
+ rake (10.5.0)
21
+ regexp_parser (2.3.1)
22
+ rexml (3.2.5)
23
+ rspec (3.11.0)
24
+ rspec-core (~> 3.11.0)
25
+ rspec-expectations (~> 3.11.0)
26
+ rspec-mocks (~> 3.11.0)
27
+ rspec-core (3.11.0)
28
+ rspec-support (~> 3.11.0)
29
+ rspec-expectations (3.11.0)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.11.0)
32
+ rspec-mocks (3.11.1)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.11.0)
35
+ rspec-support (3.11.0)
36
+ rubocop (1.28.2)
37
+ parallel (~> 1.10)
38
+ parser (>= 3.1.0.0)
39
+ rainbow (>= 2.2.2, < 4.0)
40
+ regexp_parser (>= 1.8, < 3.0)
41
+ rexml
42
+ rubocop-ast (>= 1.17.0, < 2.0)
43
+ ruby-progressbar (~> 1.7)
44
+ unicode-display_width (>= 1.4.0, < 3.0)
45
+ rubocop-ast (1.17.0)
46
+ parser (>= 3.1.1.0)
47
+ rubocop-rspec (2.10.0)
48
+ rubocop (~> 1.19)
49
+ ruby-progressbar (1.11.0)
50
+ simplecov (0.21.2)
51
+ docile (~> 1.1)
52
+ simplecov-html (~> 0.11)
53
+ simplecov_json_formatter (~> 0.1)
54
+ simplecov-console (0.9.1)
55
+ ansi
56
+ simplecov
57
+ terminal-table
58
+ simplecov-html (0.12.3)
59
+ simplecov_json_formatter (0.1.4)
60
+ terminal-table (3.0.2)
61
+ unicode-display_width (>= 1.1.1, < 3)
62
+ unicode-display_width (2.1.0)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ bundler (~> 2.3)
69
+ byebug (~> 11.1.3)
70
+ german_phone_number_classifier!
71
+ rake (~> 10.0)
72
+ rspec (~> 3.4)
73
+ rubocop (~> 1.25)
74
+ rubocop-rspec (~> 2.10)
75
+ simplecov (~> 0.21.2)
76
+ simplecov-console (~> 0.9)
77
+
78
+ BUNDLED WITH
79
+ 2.3.5
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Carsten Wirth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Carsten Wirth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,89 @@
1
+ [![Rspec & Coverage](https://github.com/jethroo/german_phone_number_classifier/actions/workflows/ruby.yml/badge.svg)](https://github.com/jethroo/german_phone_number_classifier/actions/workflows/ruby.yml)
2
+
3
+ # German Phone Number Classifier
4
+
5
+ Library for checking in which category a german phone number falls in regards to [Bundesnetzagentur classes](https://www.bundesnetzagentur.de/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Nummerierung/start.html).
6
+
7
+ ## Ruby Version
8
+
9
+ This gem is developed for ruby versions `'>= 2.7.0'`.
10
+
11
+ ## Usage
12
+
13
+ Add the gem to your Gemfile:
14
+
15
+ ```ruby
16
+ gem 'german_phone_number_classifier', '1.0.0.pre'
17
+ ```
18
+
19
+ and run `bundle install`.
20
+
21
+ The module comes with 2 class methods as public interface.
22
+
23
+ ### .classify
24
+
25
+ This method is for identifying the a telephone number as part of the german phone number system and will put it in a category identified as symbol:
26
+
27
+ ```ruby
28
+ irb(main):001:0> GermanPhoneNumberClassifier.classify('+4930120849110')
29
+ => :landline
30
+ irb(main):002:0> GermanPhoneNumberClassifier.classify('+4830120849110')
31
+ => :non_german_phone_number
32
+ irb(main):003:0> GermanPhoneNumberClassifier.classify('+4915012345678')
33
+ => :mobile
34
+ ```
35
+
36
+ Following categories are defined:
37
+
38
+ * `:no_phone_number`
39
+ * `:non_german_phone_number`
40
+ * `:authoritative` see [here](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/Notruf/Notruf_node.html), [here](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/115/115_node.html), [here](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/116xyz/116xyz_node.html) and [here](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/118xy/118_node.html)
41
+ * [`:provider_selection`](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/010/010xy_node.html)
42
+ * [`:high_connection`](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/0137/start.html)
43
+ * [`:service_hotline`](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/0180/start.html)
44
+ * `:vpn` see [here](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/018/018_Node.html) and [here] (https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/0181/181_node.html)
45
+ * `:online_and_traffic` see [here](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/019xyz/019xyz_node.html) and [here] (https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/Verkehrslenkungsnummern/VerkehrslenkungsNrn_node.html)
46
+ * [`:personal_number`](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/0700/0700_node.html)
47
+ * [`:free_service_hotline`](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/0180/start.html)
48
+ * [`:dialer`](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/09009/9009_node.html)
49
+ * [`:mobile`](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/MobileDienste/mobiledienste_node.html)
50
+ * [`:premium_service_hotline`](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/0900/0900_node.html)
51
+ * [`:test_provider`](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/031/031_node.html)
52
+ * [`:landline`](https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/ONRufnr/ortsnetze_node.html)
53
+ * `:unknown_class`
54
+
55
+ ### .landline_location
56
+
57
+ Furthermore the gem offers a utility function to get the location from prefix mappings for german phone numbers which are `:landline`. All others numbers will get `nil` returned.
58
+
59
+ ```ruby
60
+ irb(main):002:0> GermanPhoneNumberClassifier.landline_location('+4930120849110')
61
+ => "Berlin"
62
+ ```
63
+
64
+ ## Development
65
+
66
+ Test can be run with rspec: `bundle exec rspec` and rubocop: `bundle exec rubocop`
67
+
68
+
69
+ ## Contributing
70
+
71
+ 1. Fork it (https://github.com/jethroo/german_phone_number_classifier/fork)
72
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
73
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
74
+ 4. Push to the branch (`git push origin my-new-feature`)
75
+ 5. Create a new Pull Request
76
+
77
+ Notes:
78
+
79
+ - Contributions without tests won't be accepted.
80
+ - Please don't update the gem version.
81
+
82
+ ## License
83
+
84
+ see [here](LICENSE)
85
+
86
+ ## Authors/Contributors
87
+
88
+ - [Homeday](https://github.com/homeday-de)
89
+ - [Carsten Wirth](http://github.com/jethroo)
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'byebug'
6
+ require 'german_phone_number_classifier'
7
+
8
+ # You can add fixtures and/or initialization code here to make experimenting
9
+ # with your gem easier. You can also use a different console, if you like.
10
+
11
+ # (If you use this, don't forget to add pry to your Gemfile!)
12
+ # require "pry"
13
+ # Pry.start
14
+
15
+ require 'irb'
16
+ IRB.start(__FILE__)
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'csv'
5
+ require 'json'
6
+
7
+ # Download landline number prefixes to tmp
8
+ # https://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Nummerierung/Rufnummern/ONRufnr/Vorwahlverzeichnis_ONB.zip.zip?__blob=publicationFile&v=286
9
+
10
+ csv_file = File.open('./tmp/NVONB.INTERNET.20220323.ONB.csv')
11
+ data = {}
12
+
13
+ CSV.foreach(csv_file, headers: false, col_sep: ';') do |row|
14
+ data[row[0]] = row[1]
15
+ end
16
+
17
+ formated_hash = JSON.pretty_generate(data).gsub(/(?:"|')(?<key>[^"]*)(?:"|')(?=:)(?::)/) do |_|
18
+ "#{Regexp.last_match(:key)}:"
19
+ end
20
+
21
+ formated_hash.gsub!(':', '=>')
22
+
23
+ File.write('./tmp/parsed_onb', formated_hash)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'german_phone_number_classifier/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'german_phone_number_classifier'
9
+ spec.version = GermanPhoneNumberClassifier::VERSION
10
+ spec.authors = ['Carsten Wirth']
11
+ spec.email = ['carsten.wirth@homeday.de']
12
+
13
+ spec.required_ruby_version = '>= 2.7.0'
14
+
15
+ spec.summary = 'Classifying german phone numbers'
16
+ spec.description = 'Library for checking in which category a german phone' \
17
+ ' number falls in regards to Bundesnetzagentur classes.'
18
+ spec.homepage = 'https://github.com/jethroo/german_phone_number_classifier'
19
+ spec.license = 'MIT'
20
+
21
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
22
+
23
+ spec.metadata['homepage_uri'] = spec.homepage
24
+ spec.metadata['source_code_uri'] = 'https://github.com/jethroo/german_phone_number_classifier'
25
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
26
+
27
+ # Specify which files should be added to the gem when it is released.
28
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
30
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
31
+ end
32
+ spec.bindir = 'exe'
33
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ['lib']
35
+
36
+ spec.add_dependency 'phony', '~> 2.19.9'
37
+
38
+ spec.add_development_dependency 'bundler', '~> 2.3'
39
+ spec.add_development_dependency 'byebug', '~> 11.1.3'
40
+ spec.add_development_dependency 'rake', '~> 10.0'
41
+ spec.add_development_dependency 'rspec', '~> 3.4'
42
+ spec.add_development_dependency 'rubocop', '~> 1.25'
43
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.10'
44
+ spec.add_development_dependency 'simplecov', '~> 0.21.2'
45
+ spec.add_development_dependency 'simplecov-console', '~> 0.9'
46
+
47
+ spec.metadata['rubygems_mfa_required'] = 'true'
48
+ end