kontact 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 432af4fb43c107b6560bc233a2fb2348a69f216a91c1a78383d462db542e02b0
4
+ data.tar.gz: b220a08ca112f24510ac239590c34074f7160c8e1f59ab2bedb55573712a76c8
5
+ SHA512:
6
+ metadata.gz: 02361f67fe767a32f1607e7f87c71a560aeae40b52814801f24521e0db6c0829c82cce0993c1a2ff368906a3ee821a3a986993ad239bf9c99438ff5e0dec49b6
7
+ data.tar.gz: 9d410f83156e1292489ca19fb975af004073bd102a643050b26a781467b61c43ca0ceb6d3b511d45cfd8986fe44525c10f0dd7c601436e14614e36249c1f2e98
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.1
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
data/CHANGELOG.md ADDED
File without changes
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Kontact
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/kontact`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ ```bash
14
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
+ ```
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ ```bash
20
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/kontact.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
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
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,33 @@
1
+ module Kontact
2
+ module Brazil
3
+ DDDs = %w[
4
+ 11 12 13 14 15 16 17 18 19
5
+ 21 22 24
6
+ 27 28
7
+ 31 32 33 34 35 37 38
8
+ 41 42 43 44 45 46
9
+ 47 48 49
10
+ 51 53 54 55
11
+ 61 62 63 64
12
+ 65 66 67
13
+ 68 69
14
+ 71 73 74 75 77
15
+ 79
16
+ 81 82 83 84 85 86 87 88 89
17
+ 91 92 93 94 95 96 97 98 99
18
+ ]
19
+
20
+ def self.generate(type = :mobile)
21
+ ddd = DDDs.sample
22
+ number = case type
23
+ when :mobile
24
+ "9#{rand(1000..9999)}-#{rand(1000..9999)}"
25
+ when :landline
26
+ "#{rand(2000..5999)}-#{rand(1000..9999)}"
27
+ else
28
+ raise ArgumentError, "Invalid type: #{type}"
29
+ end
30
+ "+55 #{ddd} #{number}"
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,63 @@
1
+ module Kontact
2
+ module USA
3
+ AREAS = %w[
4
+ 201 202 203 204 205 206 207 208 209
5
+ 210 212 213 214 215 216 217 218 219
6
+ 224 225 226 228 229 231 234 236 239
7
+ 240 248 250 251 252 253 254 256 260
8
+ 262 267 269 270 272 274 276 278 281
9
+ 283 289 301 302 303 304 305 306 307
10
+ 308 309 310 312 313 314 315 316 317
11
+ 318 319 320 321 323 325 326 330 331
12
+ 332 334 336 337 339 340 343 345 346
13
+ 347 351 352 360 361 364 365 367 380
14
+ 385 386 401 402 403 404 405 406 407
15
+ 408 409 410 412 413 414 415 416 417
16
+ 418 419 423 424 425 430 431 432 434
17
+ 435 437 438 440 441 442 443 450 458
18
+ 464 469 470 473 475 478 479 480 484
19
+ 501 502 503 504 505 506 507 508 509
20
+ 510 512 513 514 515 516 517 518 519
21
+ 520 530 531 534 539 540 541 551 557
22
+ 559 561 562 563 564 567 570 571 573
23
+ 574 575 579 580 581 582 585 586 601
24
+ 602 603 604 605 606 607 608 609 610
25
+ 612 613 614 615 616 617 618 619 620
26
+ 623 626 628 629 630 631 636 639 640
27
+ 641 646 647 649 650 651 657 658 659
28
+ 660 661 662 667 669 670 671 672 678
29
+ 680 681 682 683 684 689 701 702 703
30
+ 704 705 706 707 708 709 710 712 713
31
+ 714 715 716 717 718 719 720 721 724
32
+ 725 726 727 731 732 734 737 740 743
33
+ 747 754 757 758 760 762 763 764 765
34
+ 767 769 770 771 772 773 774 775 778
35
+ 779 780 781 782 784 785 786 787 801
36
+ 802 803 804 805 806 807 808 809 810
37
+ 812 813 814 815 816 817 818 819 820
38
+ 825 828 829 830 831 832 835 843 845
39
+ 847 848 849 850 854 856 857 858 859
40
+ 860 862 863 864 865 867 868 869 870
41
+ 872 873 874 876 878 901 902 903 904
42
+ 905 906 907 908 909 910 912 913 914
43
+ 915 916 917 918 919 920 925 927 928
44
+ 929 930 931 935 936 937 938 939 940
45
+ 941 947 948 949 951 952 954 956 957
46
+ 959 970 971 972 973 975 976 978 979
47
+ 980 984 985 986 989
48
+ ]
49
+
50
+ def self.generate(_type = :mobile)
51
+ area = AREAS.sample
52
+ line_number = rand(1000..9999)
53
+ "+1 #{area} #{valid_prefix}-#{line_number}"
54
+ end
55
+
56
+ def self.valid_prefix
57
+ loop do
58
+ prefix = rand(200..999)
59
+ return prefix unless [911, 411, 555].include?(prefix)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kontact
4
+ VERSION = "0.1.0"
5
+ end
data/lib/kontact.rb ADDED
@@ -0,0 +1,16 @@
1
+ require_relative "kontact/version"
2
+ require_relative "kontact/brazil"
3
+ require_relative "kontact/usa"
4
+
5
+ module Kontact
6
+ def self.generate(country, type = :mobile)
7
+ case country.to_sym
8
+ when :brazil
9
+ Brazil.generate(type)
10
+ when :usa
11
+ USA.generate(type)
12
+ else
13
+ raise ArgumentError, "Unsupported country: #{country}"
14
+ end
15
+ end
16
+ end
data/sig/kontact.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Kontact
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kontact
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Thiago Chirana
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rspec
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :development
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ description: Generate and Valid any phone number in one each country
27
+ email:
28
+ - engsw.thiago@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - ".rspec"
34
+ - ".rubocop.yml"
35
+ - CHANGELOG.md
36
+ - README.md
37
+ - Rakefile
38
+ - lib/kontact.rb
39
+ - lib/kontact/brazil.rb
40
+ - lib/kontact/usa.rb
41
+ - lib/kontact/version.rb
42
+ - sig/kontact.rbs
43
+ homepage: https://github.com/thiagochirana/kontact
44
+ licenses: []
45
+ metadata:
46
+ homepage_uri: https://github.com/thiagochirana/kontact
47
+ source_code_uri: https://github.com/thiagochirana/kontact
48
+ changelog_uri: https://github.com/thiagochirana/kontact/blob/main/CHANGELOG.md
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 3.4.3
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubygems_version: 3.6.7
64
+ specification_version: 4
65
+ summary: Generate and Valid any phone number
66
+ test_files: []