phonenumber_jp 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97164fbe29ca374429029d19b550d2742a6e52c8013a1979ba07d537e7b9e47c
4
- data.tar.gz: 2d7fdc5291da54c228e93363caf376bbb487ac1ea42334713d72ce1d63bc8db5
3
+ metadata.gz: a4ccec0967152f3ee0a741feeedcd85130a177c1906239d1938a53f1d045911e
4
+ data.tar.gz: ff57e1b129331c30199915963fae35b0336e28692092c6f93bed2375647fab00
5
5
  SHA512:
6
- metadata.gz: daad0407ade0e69a924629f0ba02ba1379c2e8dc81c32db3e51f778a98a11744b59b4f05d171d412804d61df6759deacc0cc9a807ce58a9dfdf8b216cecde835
7
- data.tar.gz: 0b8d8f20e060adc0c32793eee2b6457362d2270f1e8ef6601082c4343a2352c04ae3ef0197db198c1f9d6ea5cb8119932a90a543220fb1eca4c93814b9fbc259
6
+ metadata.gz: 41f0aa077d9acc3ae52de9eaae18395c0c926aa607397b0a585af160c6b63c535143adb06f2b692df7bc4a68cc98ebbc8af6de34a527003509a01e4363c5b30e
7
+ data.tar.gz: b89e2c87c0fe170567026ae45b79b843360dc2902668dd8065ccaa3fafffa227ee5a597a539a81012407d759743a9b946ff5a4f56a842e70a1156c57a3b194d8
data/.rubocop.yml CHANGED
@@ -2,6 +2,7 @@ AllCops:
2
2
  Exclude:
3
3
  - bin/*
4
4
  - node_modules/**/*
5
+ NewCops: enable
5
6
 
6
7
  Layout/CaseIndentation:
7
8
  EnforcedStyle: end
@@ -12,6 +13,9 @@ Layout/EndAlignment:
12
13
  Layout/EmptyLinesAroundAccessModifier:
13
14
  EnforcedStyle: only_before
14
15
 
16
+ Layout/LineLength:
17
+ Enabled: false
18
+
15
19
  Layout/SpaceInLambdaLiteral:
16
20
  EnforcedStyle: require_space
17
21
 
@@ -33,9 +37,6 @@ Metrics/ClassLength:
33
37
  Metrics/CyclomaticComplexity:
34
38
  Enabled: false
35
39
 
36
- Metrics/LineLength:
37
- Enabled: false
38
-
39
40
  Metrics/MethodLength:
40
41
  Enabled: false
41
42
 
@@ -51,7 +52,7 @@ Naming/HeredocDelimiterNaming:
51
52
  Naming/PredicateName:
52
53
  Enabled: false
53
54
 
54
- Naming/UncommunicativeMethodParamName:
55
+ Naming/MethodParameterName:
55
56
  Enabled: false
56
57
 
57
58
  Style/Alias:
@@ -104,6 +105,9 @@ Style/PercentLiteralDelimiters:
104
105
  Style/SpecialGlobalVars:
105
106
  Enabled: false
106
107
 
108
+ Style/StringConcatenation:
109
+ Enabled: false
110
+
107
111
  Style/StringLiterals:
108
112
  EnforcedStyle: double_quotes
109
113
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v0.1.3 (2021-10-29)
2
+
3
+ * update special number formats (e.g. 14 digits data transfer number).
4
+
1
5
  # v0.1.2 (2015-07-24)
2
6
 
3
7
  * copy entire codes from [labocho/phonenumber](https://github.com/labocho/phonenumber).
data/Gemfile CHANGED
@@ -4,3 +4,11 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in phonenumber.gemspec
6
6
  gemspec
7
+
8
+ group :development do
9
+ gem "bundler", ">= 1.16"
10
+ gem "rake", ">= 10.0"
11
+ gem "rspec", ">= 3.7"
12
+ gem "rubocop", ">= 0.76"
13
+ gem "steep", ">= 0.41.0"
14
+ end
data/Gemfile.lock CHANGED
@@ -1,41 +1,79 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- phonenumber_jp (0.1.2)
4
+ phonenumber_jp (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.0)
10
- diff-lcs (1.3)
11
- jaro_winkler (1.5.4)
12
- parallel (1.19.0)
13
- parser (2.6.5.0)
14
- ast (~> 2.4.0)
9
+ activesupport (6.1.4.1)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ i18n (>= 1.6, < 2)
12
+ minitest (>= 5.1)
13
+ tzinfo (~> 2.0)
14
+ zeitwerk (~> 2.3)
15
+ ast (2.4.2)
16
+ concurrent-ruby (1.1.9)
17
+ diff-lcs (1.4.4)
18
+ ffi (1.15.4)
19
+ i18n (1.8.10)
20
+ concurrent-ruby (~> 1.0)
21
+ language_server-protocol (3.16.0.3)
22
+ listen (3.7.0)
23
+ rb-fsevent (~> 0.10, >= 0.10.3)
24
+ rb-inotify (~> 0.9, >= 0.9.10)
25
+ minitest (5.14.4)
26
+ parallel (1.21.0)
27
+ parser (3.0.2.0)
28
+ ast (~> 2.4.1)
15
29
  rainbow (3.0.0)
16
- rake (13.0.1)
17
- rspec (3.9.0)
18
- rspec-core (~> 3.9.0)
19
- rspec-expectations (~> 3.9.0)
20
- rspec-mocks (~> 3.9.0)
21
- rspec-core (3.9.0)
22
- rspec-support (~> 3.9.0)
23
- rspec-expectations (3.9.0)
30
+ rake (13.0.6)
31
+ rb-fsevent (0.11.0)
32
+ rb-inotify (0.10.1)
33
+ ffi (~> 1.0)
34
+ rbs (1.6.2)
35
+ regexp_parser (2.1.1)
36
+ rexml (3.2.5)
37
+ rspec (3.10.0)
38
+ rspec-core (~> 3.10.0)
39
+ rspec-expectations (~> 3.10.0)
40
+ rspec-mocks (~> 3.10.0)
41
+ rspec-core (3.10.1)
42
+ rspec-support (~> 3.10.0)
43
+ rspec-expectations (3.10.1)
24
44
  diff-lcs (>= 1.2.0, < 2.0)
25
- rspec-support (~> 3.9.0)
26
- rspec-mocks (3.9.0)
45
+ rspec-support (~> 3.10.0)
46
+ rspec-mocks (3.10.2)
27
47
  diff-lcs (>= 1.2.0, < 2.0)
28
- rspec-support (~> 3.9.0)
29
- rspec-support (3.9.0)
30
- rubocop (0.76.0)
31
- jaro_winkler (~> 1.5.1)
48
+ rspec-support (~> 3.10.0)
49
+ rspec-support (3.10.2)
50
+ rubocop (1.22.3)
32
51
  parallel (~> 1.10)
33
- parser (>= 2.6)
52
+ parser (>= 3.0.0.0)
34
53
  rainbow (>= 2.2.2, < 4.0)
54
+ regexp_parser (>= 1.8, < 3.0)
55
+ rexml
56
+ rubocop-ast (>= 1.12.0, < 2.0)
35
57
  ruby-progressbar (~> 1.7)
36
- unicode-display_width (>= 1.4.0, < 1.7)
37
- ruby-progressbar (1.10.1)
38
- unicode-display_width (1.6.0)
58
+ unicode-display_width (>= 1.4.0, < 3.0)
59
+ rubocop-ast (1.12.0)
60
+ parser (>= 3.0.1.1)
61
+ ruby-progressbar (1.11.0)
62
+ steep (0.46.0)
63
+ activesupport (>= 5.1)
64
+ language_server-protocol (>= 3.15, < 4.0)
65
+ listen (~> 3.0)
66
+ parallel (>= 1.0.0)
67
+ parser (>= 3.0)
68
+ rainbow (>= 2.2.2, < 4.0)
69
+ rbs (>= 1.2.0)
70
+ terminal-table (>= 2, < 4)
71
+ terminal-table (3.0.2)
72
+ unicode-display_width (>= 1.1.1, < 3)
73
+ tzinfo (2.0.4)
74
+ concurrent-ruby (~> 1.0)
75
+ unicode-display_width (2.1.0)
76
+ zeitwerk (2.5.1)
39
77
 
40
78
  PLATFORMS
41
79
  ruby
@@ -46,6 +84,7 @@ DEPENDENCIES
46
84
  rake (>= 10.0)
47
85
  rspec (>= 3.7)
48
86
  rubocop (>= 0.76)
87
+ steep (>= 0.41.0)
49
88
 
50
89
  BUNDLED WITH
51
- 2.0.2
90
+ 2.2.3
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ file "tmp/xls2csv.jar" do
10
10
  warn "Download xls2csv.jar"
11
11
  File.write(
12
12
  "tmp/xls2csv.jar",
13
- open("https://github.com/labocho/xls2csv/releases/download/v0.1.1/xls2csv.jar", &:read),
13
+ URI.open("https://github.com/labocho/xls2csv/releases/download/v0.1.1/xls2csv.jar", &:read),
14
14
  )
15
15
  end
16
16
 
@@ -35,3 +35,9 @@ namespace "area_codes" do
35
35
  ruby "scripts/update_area_codes_list.rb"
36
36
  end
37
37
  end
38
+
39
+ namespace "steep" do
40
+ task "check" do
41
+ sh "steep check"
42
+ end
43
+ end
data/Steepfile ADDED
@@ -0,0 +1,25 @@
1
+ target :lib do
2
+ signature "sig"
3
+ check "lib"
4
+ end
5
+
6
+ # target :lib do
7
+ # signature "sig"
8
+ #
9
+ # check "lib" # Directory name
10
+ # check "Gemfile" # File name
11
+ # check "app/models/**/*.rb" # Glob
12
+ # # ignore "lib/templates/*.rb"
13
+ #
14
+ # # library "pathname", "set" # Standard libraries
15
+ # # library "strong_json" # Gems
16
+ # end
17
+
18
+ # target :spec do
19
+ # signature "sig", "sig-private"
20
+ #
21
+ # check "spec"
22
+ #
23
+ # # library "pathname", "set" # Standard libraries
24
+ # # library "rspec"
25
+ # end
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "phonenumber"
4
+ require "phonenumber_jp"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -1,3 +1,3 @@
1
1
  module PhonenumberJp
2
- VERSION = "0.1.2".freeze
2
+ VERSION = "0.1.3".freeze
3
3
  end
@@ -25,23 +25,25 @@ module PhonenumberJp
25
25
  def split(phonenumber)
26
26
  return [] if phonenumber.nil?
27
27
 
28
- phonenumber = phonenumber.gsub(/[^0-9\+]/, "")
28
+ phonenumber = phonenumber.gsub(/[^0-9+]/, "")
29
29
  return [] if phonenumber.length == 0
30
30
 
31
31
  case phonenumber
32
32
  when /^\+81/
33
- local = split("0" + phonenumber[3..-1])
33
+ local = split("0" + phonenumber[3..-1].to_s) # steep does not know that `phonenumber[3..-1]` will be return String always. Call `to_s` to tell it is String.
34
34
  return [phonenumber] if local.length < 2
35
35
 
36
- local[0] = local[0][1..-1]
36
+ local[0] = local[0][1..-1].to_s # steep does not know that `local[0][1..-1]` will be return String always. Call `to_s` to tell it is String.
37
37
  ["+81"] + local
38
- when /^(050)(\d\d\d\d)(\d\d\d\d)$/, # IP 電話
39
- /^(0800)(\d\d\d)(\d\d\d\d)$/, # フリーダイヤル
40
- /^(0[789]0)(\d\d\d\d)(\d\d\d\d)$/, # 携帯電話・PHS
41
- /^(020)(\d\d\d\d)(\d\d\d\d)$/, # ポケベル
42
- /^(0120)(\d\d\d)(\d\d\d)$/, # フリーダイヤル
38
+ when /^(0120)(\d\d\d)(\d\d\d)$/, # 着信課金機能 (フリーダイヤル)
39
+ /^(0800)(\d\d\d)(\d\d\d\d)$/, # 着信課金機能(フリーダイヤル)
40
+ /^(0180)(\d\d\d)(\d\d\d)$/, # 大量呼受付機能
43
41
  /^(0570)(\d\d\d)(\d\d\d)$/, # ナビダイヤル
44
- /^(0990)(\d\d\d)(\d\d\d)$/ # ダイヤル Q2
42
+ /^(0990)(\d\d\d)(\d\d\d)$/, # ダイヤル Q2
43
+ /^(020)(\d\d\d)(\d\d\d\d\d)$/, # データ伝送携帯電話番号, 無線呼出番号
44
+ /^(0200)(\d\d\d\d\d)(\d\d\d\d\d)$/, # データ伝送携帯電話番号
45
+ /^(0[789]0)(\d\d\d\d)(\d\d\d\d)$/, # 携帯電話・PHS
46
+ /^(050)(\d\d\d\d)(\d\d\d\d)$/ # IP 電話
45
47
  $~.captures
46
48
  when /^0(\d{9})$/ # 固定電話
47
49
  return [phonenumber] unless (area_code = find_area_code(phonenumber))
@@ -13,24 +13,19 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://github.com/labocho/phonenumber_jp"
14
14
  spec.license = "MIT"
15
15
 
16
- if spec.respond_to?(:metadata)
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = spec.homepage
19
- spec.metadata["changelog_uri"] = "https://github.com/labocho/phonenumber_jp/blob/master/CHANGELOG.md"
20
- else
21
- raise "RubyGems 2.0 or newer is required to protect against " \
22
- "public gem pushes."
23
- end
16
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes." unless spec.respond_to?(:metadata)
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = spec.homepage
20
+ spec.metadata["changelog_uri"] = "https://github.com/labocho/phonenumber_jp/blob/master/CHANGELOG.md"
24
21
 
25
22
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
23
  f.match(%r{^(test|spec|features)/})
27
24
  end
25
+
26
+ spec.required_ruby_version = ">= 2.5"
27
+
28
28
  spec.bindir = "exe"
29
29
  spec.executables = spec.files.grep(%r(^exe/)) {|f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
-
32
- spec.add_development_dependency "bundler", ">= 1.16"
33
- spec.add_development_dependency "rake", ">= 10.0"
34
- spec.add_development_dependency "rspec", ">= 3.7"
35
- spec.add_development_dependency "rubocop", ">= 0.76"
36
31
  end
@@ -3,9 +3,10 @@ require "open-uri"
3
3
  require "uri"
4
4
  require "nokogiri"
5
5
 
6
- URL = URI("http://www.soumu.go.jp/main_sosiki/joho_tsusin/top/tel_number/number_shitei.html")
6
+ URL = URI("https://www.soumu.go.jp/main_sosiki/joho_tsusin/top/tel_number/number_shitei.html")
7
+
8
+ html = URI.open(URL.to_s, &:read).force_encoding("cp932")
7
9
 
8
- html = open(URL.to_s, &:read)
9
10
  doc = Nokogiri.parse(html)
10
11
  xls_urls = []
11
12
 
@@ -19,6 +20,6 @@ xls_urls.each do |url|
19
20
  basename = url.gsub(%r(.*/), "")
20
21
  dest = "#{__dir__}/../tmp/xls/#{basename}"
21
22
  warn "Download #{url} to #{dest}"
22
- File.write(dest, open(url, &:read))
23
+ File.write(dest, URI.open(url, &:read))
23
24
  end
24
25
  # rubocop: enable Security/Open
@@ -0,0 +1,11 @@
1
+ module PhonenumberJp
2
+ AREA_CODES: Array[String]
3
+ VERSION: String
4
+
5
+ def self.hyphenate: (String | nil) -> (String | nil)
6
+ def self.valid?: (String | nil) -> bool
7
+
8
+ private
9
+ def self.split: (String | nil) -> Array[String]
10
+ def self.find_area_code: (String) -> (String | nil)
11
+ end
metadata CHANGED
@@ -1,71 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phonenumber_jp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - labocho
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-14 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '1.16'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '1.16'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '3.7'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '3.7'
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0.76'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0.76'
11
+ date: 2021-10-29 00:00:00.000000000 Z
12
+ dependencies: []
69
13
  description: Hyphenate Japanese phone number
70
14
  email:
71
15
  - labocho@penguinlab.jp
@@ -82,6 +26,7 @@ files:
82
26
  - LICENSE.txt
83
27
  - README.md
84
28
  - Rakefile
29
+ - Steepfile
85
30
  - bin/bundle
86
31
  - bin/console
87
32
  - bin/rake
@@ -95,6 +40,7 @@ files:
95
40
  - scripts/convert_xls_to_csv.rb
96
41
  - scripts/update_area_codes_list.rb
97
42
  - scripts/xls_downloader.rb
43
+ - sig/phonenumber_jp.rbs
98
44
  homepage: https://github.com/labocho/phonenumber_jp
99
45
  licenses:
100
46
  - MIT
@@ -102,7 +48,7 @@ metadata:
102
48
  homepage_uri: https://github.com/labocho/phonenumber_jp
103
49
  source_code_uri: https://github.com/labocho/phonenumber_jp
104
50
  changelog_uri: https://github.com/labocho/phonenumber_jp/blob/master/CHANGELOG.md
105
- post_install_message:
51
+ post_install_message:
106
52
  rdoc_options: []
107
53
  require_paths:
108
54
  - lib
@@ -110,15 +56,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
56
  requirements:
111
57
  - - ">="
112
58
  - !ruby/object:Gem::Version
113
- version: '0'
59
+ version: '2.5'
114
60
  required_rubygems_version: !ruby/object:Gem::Requirement
115
61
  requirements:
116
62
  - - ">="
117
63
  - !ruby/object:Gem::Version
118
64
  version: '0'
119
65
  requirements: []
120
- rubygems_version: 3.0.3
121
- signing_key:
66
+ rubygems_version: 3.1.2
67
+ signing_key:
122
68
  specification_version: 4
123
69
  summary: Hyphenate Japanese phone number
124
70
  test_files: []