ptc 0.1.0 → 0.1.1
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/.gitignore +10 -0
- data/.rspec +2 -1
- data/.rubocop.yml +50 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +82 -0
- data/Guardfile +15 -0
- data/README.md +1 -0
- data/RELEASING.txt +3 -2
- data/lib/ptc.rb +15 -0
- data/lib/ptc/dicts/countries_priorities.yml +19 -0
- data/lib/ptc/get_country_by_phone.rb +35 -0
- data/lib/ptc/utils/countries_priorities.rb +13 -0
- data/lib/ptc/utils/numer.rb +6 -0
- data/lib/ptc/version.rb +3 -0
- data/ptc.gemspec +28 -0
- metadata +48 -9
- data/bin/release +0 -1
- data/bin/tag +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f3cfad480259d997a156029f7ec8a69e0e0a5ba5ffed319b88b39070435af7d
|
4
|
+
data.tar.gz: 4106345af88254378a9f9fca698f6c45f494098584a4af7f72b784071862f260
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6e47e519fd41f604c18658b245d86955e783d248e29664afb6efb10afcb25671f11f2872386a6b611eb7a7b99afd3ef11b597a911b7cfcc39d88ca20a12a84c
|
7
|
+
data.tar.gz: 1da9097ee6f91bfbf4aee1c772480ee3d3071372e3f23d429ea5e54e481ec646daeca18af1215c4fb1a0c9f983fc4c05931bfab64e3943b772f8e25d1ace0b31
|
data/.gitignore
ADDED
data/.rspec
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
Style/AsciiComments:
|
2
|
+
Description: 'Use only ascii symbols in comments.'
|
3
|
+
StyleGuide: '#english-comments'
|
4
|
+
Enabled: false
|
5
|
+
Style/FrozenStringLiteralComment:
|
6
|
+
Enabled: false
|
7
|
+
Style/CommentedKeyword:
|
8
|
+
Enabled: false
|
9
|
+
Style/SymbolArray:
|
10
|
+
Enabled: false
|
11
|
+
Metrics/LineLength:
|
12
|
+
Max: 120
|
13
|
+
Enabled: false
|
14
|
+
Metrics/MethodLength:
|
15
|
+
Enabled: false
|
16
|
+
Metrics/ModuleLength:
|
17
|
+
Enabled: false
|
18
|
+
Metrics/ParameterLists:
|
19
|
+
Max: 3
|
20
|
+
CountKeywordArgs: true
|
21
|
+
Layout/LeadingCommentSpace:
|
22
|
+
Enabled: false
|
23
|
+
Layout/SpaceBeforeComment:
|
24
|
+
Enabled: false
|
25
|
+
Layout/ExtraSpacing:
|
26
|
+
Enabled: false
|
27
|
+
Layout/CaseIndentation:
|
28
|
+
Enabled: false
|
29
|
+
Layout/SpaceAroundOperators:
|
30
|
+
Enabled: false
|
31
|
+
Style/FormatString:
|
32
|
+
Enabled: false
|
33
|
+
Style/FormatStringToken:
|
34
|
+
Enabled: false
|
35
|
+
Layout/AlignParameters:
|
36
|
+
Enabled: false
|
37
|
+
Metrics/BlockNesting:
|
38
|
+
Enabled: false
|
39
|
+
Layout/TrailingWhitespace:
|
40
|
+
Enabled: false
|
41
|
+
Metrics/AbcSize:
|
42
|
+
Enabled: false
|
43
|
+
Style/Documentation:
|
44
|
+
Enabled: false
|
45
|
+
Layout/AlignHash:
|
46
|
+
Enabled: false
|
47
|
+
Metrics/ClassLength:
|
48
|
+
Enabled: false
|
49
|
+
Lint/Syntax:
|
50
|
+
Enabled: false
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ptc (0.1.0)
|
5
|
+
countries (~> 1.2.0)
|
6
|
+
phony (> 2.15)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
byebug (11.1.3)
|
12
|
+
coderay (1.1.2)
|
13
|
+
countries (1.2.5)
|
14
|
+
currencies (~> 0.4.2)
|
15
|
+
i18n_data (~> 0.7.0)
|
16
|
+
currencies (0.4.2)
|
17
|
+
diff-lcs (1.3)
|
18
|
+
ffi (1.11.1)
|
19
|
+
formatador (0.2.5)
|
20
|
+
guard (2.16.2)
|
21
|
+
formatador (>= 0.2.4)
|
22
|
+
listen (>= 2.7, < 4.0)
|
23
|
+
lumberjack (>= 1.0.12, < 2.0)
|
24
|
+
nenv (~> 0.1)
|
25
|
+
notiffany (~> 0.0)
|
26
|
+
pry (>= 0.9.12)
|
27
|
+
shellany (~> 0.0)
|
28
|
+
thor (>= 0.18.1)
|
29
|
+
guard-compat (1.2.1)
|
30
|
+
guard-rspec (4.7.3)
|
31
|
+
guard (~> 2.1)
|
32
|
+
guard-compat (~> 1.1)
|
33
|
+
rspec (>= 2.99.0, < 4.0)
|
34
|
+
i18n_data (0.7.0)
|
35
|
+
listen (3.1.5)
|
36
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
37
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
38
|
+
ruby_dep (~> 1.2)
|
39
|
+
lumberjack (1.2.5)
|
40
|
+
method_source (0.9.2)
|
41
|
+
nenv (0.3.0)
|
42
|
+
notiffany (0.1.3)
|
43
|
+
nenv (~> 0.1)
|
44
|
+
shellany (~> 0.0)
|
45
|
+
phony (2.18.15)
|
46
|
+
pry (0.12.2)
|
47
|
+
coderay (~> 1.1.0)
|
48
|
+
method_source (~> 0.9.0)
|
49
|
+
rake (13.0.1)
|
50
|
+
rb-fsevent (0.10.3)
|
51
|
+
rb-inotify (0.10.0)
|
52
|
+
ffi (~> 1.0)
|
53
|
+
rspec (3.8.0)
|
54
|
+
rspec-core (~> 3.8.0)
|
55
|
+
rspec-expectations (~> 3.8.0)
|
56
|
+
rspec-mocks (~> 3.8.0)
|
57
|
+
rspec-core (3.8.2)
|
58
|
+
rspec-support (~> 3.8.0)
|
59
|
+
rspec-expectations (3.8.4)
|
60
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
61
|
+
rspec-support (~> 3.8.0)
|
62
|
+
rspec-mocks (3.8.1)
|
63
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
64
|
+
rspec-support (~> 3.8.0)
|
65
|
+
rspec-support (3.8.2)
|
66
|
+
ruby_dep (1.5.0)
|
67
|
+
shellany (0.0.1)
|
68
|
+
thor (0.20.3)
|
69
|
+
|
70
|
+
PLATFORMS
|
71
|
+
ruby
|
72
|
+
|
73
|
+
DEPENDENCIES
|
74
|
+
bundler
|
75
|
+
byebug
|
76
|
+
guard-rspec
|
77
|
+
ptc!
|
78
|
+
rake
|
79
|
+
rspec
|
80
|
+
|
81
|
+
BUNDLED WITH
|
82
|
+
2.1.4
|
data/Guardfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
guard :rspec, cmd: "rspec" do
|
2
|
+
require "guard/rspec/dsl"
|
3
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
4
|
+
|
5
|
+
# RSpec files
|
6
|
+
rspec = dsl.rspec
|
7
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
8
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
9
|
+
watch(rspec.spec_files)
|
10
|
+
|
11
|
+
# Ruby files
|
12
|
+
ruby = dsl.ruby
|
13
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
14
|
+
|
15
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
`get_country_geo_by_phone(phone_number)` -- Получить геометрический (географический) центр страны по номеру телефона
|
data/RELEASING.txt
CHANGED
@@ -5,8 +5,9 @@ Needed:
|
|
5
5
|
$ gem install gem-release
|
6
6
|
|
7
7
|
Steps:
|
8
|
+
0. bundle config local.ptc /home/<user>/git/my/ruby/ptc/
|
8
9
|
1. bundle exec rspec
|
9
10
|
2. ptc/version.rb - increase version
|
10
11
|
3. history.textile - add a new entry on top with the version. Describe and give thanks!
|
11
|
-
4. build
|
12
|
-
5. push
|
12
|
+
4. build (RubyMine: <alt>+<t>, <alt>+<g>, <alt>+<b>)
|
13
|
+
5. push (RubyMine: <alt>+<t>, <alt>+<g>, <alt>+<p>)
|
data/lib/ptc.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require 'phony'
|
3
|
+
require 'countries'
|
4
|
+
|
5
|
+
# загружаем библиотечные классы
|
6
|
+
lambda do
|
7
|
+
%w[../ptc/utils ../ptc].each do |path|
|
8
|
+
lib_path = '%s/**/*.rb' % File.expand_path(path, __FILE__)
|
9
|
+
# noinspection RubyResolve
|
10
|
+
Dir[lib_path].each { |f| require_relative f }
|
11
|
+
end
|
12
|
+
end.call
|
13
|
+
|
14
|
+
module Ptc
|
15
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module GetCountryByPhone
|
2
|
+
include Numer
|
3
|
+
include CountriesPriorities
|
4
|
+
|
5
|
+
# Получить геометрический (географический) центр страны по номеру телефона
|
6
|
+
# Если коду страны из номера телефона соответствуют более 1 страны (например, +7 для RU и KZ),
|
7
|
+
# то взята будет одна первая страна из списка согласно приоритету +countries_priorities.yml+
|
8
|
+
def get_country_geo_by_phone(phone_number)
|
9
|
+
return nil if phone_number.nil?
|
10
|
+
|
11
|
+
phone_number = Phony.split(_numeric phone_number)
|
12
|
+
return nil unless phone_number.all?
|
13
|
+
|
14
|
+
country_code = phone_number[0]
|
15
|
+
countries = ISO3166::Country.find_all_by(:country_code, country_code)
|
16
|
+
top_country = top_priority_country_by_country_code country_code
|
17
|
+
country = top_country.nil? ? countries.values.first : countries[top_country]
|
18
|
+
|
19
|
+
#gem "countries", '3.0.1'
|
20
|
+
#country_geo = country.values.first['geo']
|
21
|
+
# OpenStruct.new(
|
22
|
+
# latitude: country_geo['latitude'],
|
23
|
+
# longitude: country_geo['longitude']
|
24
|
+
# )
|
25
|
+
|
26
|
+
#puts [country['latitude_dec'], country['longitude_dec']].join ','
|
27
|
+
OpenStruct.new(
|
28
|
+
latitude: country['latitude_dec'],
|
29
|
+
longitude: country['longitude_dec']
|
30
|
+
)
|
31
|
+
rescue ::Phony::SplittingError
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module CountriesPriorities
|
2
|
+
def top_priority_country_by_country_code(country_code)
|
3
|
+
cp = cps[country_code.to_i]
|
4
|
+
cp&.first
|
5
|
+
end
|
6
|
+
|
7
|
+
def cps
|
8
|
+
@_dict ||= begin
|
9
|
+
ppp = File.expand_path '../dicts/countries_priorities.yml', File.dirname(__FILE__)
|
10
|
+
YAML.load_file(ppp)['countries_priorities']
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/ptc/version.rb
ADDED
data/ptc.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "ptc/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "ptc"
|
7
|
+
spec.version = Ptc::VERSION
|
8
|
+
spec.authors = ["TZ"]
|
9
|
+
spec.email = ["t.zozulya@key-g.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{GEO+PHONES}
|
12
|
+
spec.homepage = "http://getboat.com"
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
# Specify which files should be added to the gem when it is released.
|
16
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_dependency 'phony', '> 2.15'
|
27
|
+
spec.add_dependency 'countries', '~> 1.2.0'
|
28
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ptc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- TZ
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,20 +38,59 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: phony
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.15'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.15'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: countries
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.2.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.2.0
|
69
|
+
description:
|
42
70
|
email:
|
43
|
-
-
|
71
|
+
- t.zozulya@key-g.com
|
44
72
|
executables: []
|
45
73
|
extensions: []
|
46
74
|
extra_rdoc_files: []
|
47
75
|
files:
|
76
|
+
- ".gitignore"
|
48
77
|
- ".rspec"
|
78
|
+
- ".rubocop.yml"
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- Guardfile
|
82
|
+
- README.md
|
49
83
|
- RELEASING.txt
|
50
84
|
- Rakefile
|
51
|
-
- bin/release
|
52
|
-
- bin/tag
|
53
85
|
- history.textile
|
54
|
-
|
86
|
+
- lib/ptc.rb
|
87
|
+
- lib/ptc/dicts/countries_priorities.yml
|
88
|
+
- lib/ptc/get_country_by_phone.rb
|
89
|
+
- lib/ptc/utils/countries_priorities.rb
|
90
|
+
- lib/ptc/utils/numer.rb
|
91
|
+
- lib/ptc/version.rb
|
92
|
+
- ptc.gemspec
|
93
|
+
homepage: http://getboat.com
|
55
94
|
licenses:
|
56
95
|
- MIT
|
57
96
|
metadata: {}
|
@@ -73,5 +112,5 @@ requirements: []
|
|
73
112
|
rubygems_version: 3.0.8
|
74
113
|
signing_key:
|
75
114
|
specification_version: 4
|
76
|
-
summary:
|
115
|
+
summary: GEO+PHONES
|
77
116
|
test_files: []
|
data/bin/release
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
gem release
|
data/bin/tag
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
gem tag -p
|