st_tools 0.3.13 → 0.3.14

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
  SHA1:
3
- metadata.gz: 83397a6c2d69184286fbc9f97a11039115380d2c
4
- data.tar.gz: dc4150faa007de0563d7d499d247e3466c4298e9
3
+ metadata.gz: f2159ed0b18531c0644af292aee0525c26cc9b92
4
+ data.tar.gz: 035ff3d07ef85f83b603ecdaad6948196376d93c
5
5
  SHA512:
6
- metadata.gz: e2ef6827fcdf47f95eac4ad0b05e545cc35480511fe79497214d9aba0915d48cb96ecd69da9b78ecedc9531667ff2916eda92bd41d4ec7c5e1cc072762a55b22
7
- data.tar.gz: 2e2253e11334b98793a8fc7a29393155e334c753a01353490202d36aaad4a009f0d1687a3e6b9960d2f5d9e87d6b64c877f19de06e5bf21e72ec4e2a4b8d827f
6
+ metadata.gz: 761181420dcff4c027c34966ccd23ebb99e821ba8652e2fe5caec0bcafcb9bfa8294cae76146efff0af9b82d5343d486093444bf9d1e1e1932c8a15e942e2ad2
7
+ data.tar.gz: 5bfa84ebe8896af349ebb0abf8482e0c7c9dec294282201b579d8550a8e015db12ac4dc541eba505fc06a76b167ad425dd24985e30c0f9f9cb979e44ad1d3776
@@ -0,0 +1,60 @@
1
+ module StTools
2
+ class Countries
3
+ AOGUIDS = {
4
+ zz: '',
5
+ ru: 'ea70abb2-ccc2-46c8-9b15-d42cac1ecd7f',
6
+ ua: 'e6a4a903-01e6-43f0-9bad-e57c2eb4a9c7',
7
+ kz: 'e501ac67-d26a-40c9-ad43-f1628807fdc0',
8
+ by: 'ff26f2dc-759e-4196-9e28-4d6338c8e863'
9
+ }
10
+
11
+ COUNTRIES = {
12
+ zz: {code: '', shortname: '', fullname: ''},
13
+ ru: {code: 'ru', shortname: 'Россия', fullname: 'Российская Федерация'},
14
+ ua: {code: 'ua', shortname: 'Украина', fullname: 'Украина'},
15
+ kz: {code: 'kz', shortname: 'Казахстан', fullname: 'Республика Казахстан'},
16
+ by: {code: 'by', shortname: 'Беларусь', fullname: 'Республика Беларусь'}
17
+ }
18
+
19
+ GEO = {
20
+ zz: {location: [0.0, 0.0], upper: [0.0, 0.0], lower: [0.0, 0.0]},
21
+ ru: {location: [99.505405, 61.698653], upper: [191.128003, 81.886117], lower: [19.484764, 41.18599]},
22
+ ua: {location: [0.0, 0.0], upper: [0.0, 0.0], lower: [0.0, 0.0]},
23
+ kz: {location: [0.0, 0.0], upper: [0.0, 0.0], lower: [0.0, 0.0]},
24
+ by: {location: [0.0, 0.0], upper: [0.0, 0.0], lower: [0.0, 0.0]},
25
+ }
26
+
27
+ # Метод проверяет, яаляется ли UUID страной
28
+ #
29
+ # @param [String] uuid идентификатор страны
30
+ # @return [Boolean] true, если идентификатор является идентификатором страны
31
+ # @example Примеры использования
32
+ # StTools::Countries.country?('e6a4a903-01e6-43f0-9bad-e57c2eb4a9c7') #=> true
33
+ # StTools::Countries.country?('f5eea12d-e601-f043-9bad-e5789eefa9aa') #=> false
34
+ # StTools::Countries.country?('Hello') #=> false
35
+ def self.country?(uuid)
36
+ ::StTools::Countries::AOGUIDS.values.include?(uuid)
37
+ end
38
+
39
+ # Метод возвращает информацию о стране по ее идентификатору
40
+ #
41
+ # @param [String] id идентификатор страны (в виде aoguid, :ru, 'ru')
42
+ # @return [Hash] hash описание страны
43
+ # @example Примеры использования
44
+ # StTools::Countries.country('e6a4a903-01e6-43f0-9bad-e57c2eb4a9c7') #=> Hash
45
+ # StTools::Countries.country(:ru) #=> Hash
46
+ # StTools::Countries.country('ru') #=> Hash
47
+ # StTools::Countries.country('??') #=> Empty Hash
48
+ def self.country(id)
49
+ if ::StTools::Fias.uuid?(id)
50
+ code = ::StTools::Countries::AOGUIDS.invert[id] || :zz
51
+ else
52
+ code = ::StTools::Countries::AOGUIDS.keys.include?(id.to_sym) ? id.to_sym : :zz
53
+ end
54
+
55
+ ::StTools::Countries::COUNTRIES[code].merge(::StTools::Countries::GEO[code])
56
+ end
57
+
58
+
59
+ end
60
+ end
data/lib/st_tools/fias.rb CHANGED
@@ -154,6 +154,7 @@ module StTools
154
154
  end
155
155
 
156
156
 
157
+
157
158
  private
158
159
 
159
160
  # noinspection RubyClassVariableUsageInspection
@@ -168,5 +169,6 @@ module StTools
168
169
  return self_federal_cities
169
170
  end
170
171
 
172
+
171
173
  end
172
174
  end
@@ -39,6 +39,7 @@ module StTools
39
39
  # @return [Object] нет
40
40
  def progress=(val)
41
41
  return if val > @max
42
+ return if val == @max
42
43
  return if val == @value
43
44
  return if val % @step != 0 && (@max - val) >= @step
44
45
 
@@ -46,7 +47,7 @@ module StTools
46
47
  @pbar.progress = val
47
48
  @usage += 1
48
49
 
49
- if val > @max - 1
50
+ if val >= @max
50
51
  puts_footer
51
52
  end
52
53
  end
@@ -38,5 +38,8 @@ module StTools
38
38
  res.split(' ').first
39
39
  end
40
40
 
41
+ # todo: расчет размера папки
42
+ # todo: свободное место
43
+
41
44
  end
42
45
  end
@@ -1,3 +1,3 @@
1
1
  module StTools
2
- VERSION = '0.3.13'
2
+ VERSION = '0.3.14'
3
3
  end
data/lib/st_tools.rb CHANGED
@@ -10,6 +10,7 @@ module StTools
10
10
  require 'st_tools/system'
11
11
  require 'st_tools/human'
12
12
  require 'st_tools/fias'
13
+ require 'st_tools/countries'
13
14
  require 'st_tools/string'
14
15
  require 'st_tools/progress_bar'
15
16
 
@@ -0,0 +1,48 @@
1
+ require 'rspec'
2
+ require 'st_tools'
3
+
4
+
5
+ describe 'Проверка методов StTool::Countries.*' do
6
+
7
+ #-----------------------------------------------------
8
+ #
9
+ # Тесты проверки страны
10
+ #
11
+ #-----------------------------------------------------
12
+ it '.country? success' do
13
+ test = ::StTools::Countries.country?('e6a4a903-01e6-43f0-9bad-e57c2eb4a9c7')
14
+ expect(test).to eq true
15
+ end
16
+
17
+ it '.country? fail' do
18
+ test = ::StTools::Countries.country?('0c5b2444-70a0-4932-980c-b4dc0d3f02b5')
19
+ expect(test).to eq false
20
+ end
21
+
22
+ #-----------------------------------------------------
23
+ #
24
+ # Тесты получения информации о стране
25
+ #
26
+ #-----------------------------------------------------
27
+ it 'country success by aoguid' do
28
+ test = ::StTools::Countries.country('e6a4a903-01e6-43f0-9bad-e57c2eb4a9c7')
29
+ expect(test[:code]).to eq 'ua'
30
+ end
31
+
32
+ it 'country success by code :ru' do
33
+ test = ::StTools::Countries.country(:ru)
34
+ expect(test[:code]).to eq 'ru'
35
+ end
36
+
37
+ it 'country success by code ru' do
38
+ test = ::StTools::Countries.country('kz')
39
+ expect(test[:code]).to eq 'kz'
40
+ end
41
+
42
+ it 'country success by code ru' do
43
+ test = ::StTools::Countries.country('us')
44
+ expect(test[:code]).to eq ''
45
+ end
46
+
47
+
48
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: st_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.13
4
+ version: 0.3.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stan Zhuravlev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-14 00:00:00.000000000 Z
11
+ date: 2015-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -90,6 +90,7 @@ files:
90
90
  - lib/socr/geo.yml
91
91
  - lib/st_tools.rb
92
92
  - lib/st_tools/common.rb
93
+ - lib/st_tools/countries.rb
93
94
  - lib/st_tools/fias.rb
94
95
  - lib/st_tools/human.rb
95
96
  - lib/st_tools/progress_bar.rb
@@ -97,6 +98,7 @@ files:
97
98
  - lib/st_tools/system.rb
98
99
  - lib/st_tools/tokenizer.rb
99
100
  - lib/st_tools/version.rb
101
+ - test/countries_lib_spec.rb
100
102
  - test/fias_lib_spec.rb
101
103
  - test/human_lib_spec.rb
102
104
  - test/progress_bar_lib_spec.rb