snils 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/README.ru.md +6 -1
- data/lib/snils.rb +5 -2
- data/lib/snils/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2d5331ca5ae9415ba0dbe3bacf90d481b956438
|
4
|
+
data.tar.gz: 16ac1c6f7e865be1eab804d7fb65657133160efa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eef745d47ad882618c713da274eac1d0e3c6f52085596afb64e2352fcc22194f59146c536edb026281d333003914999863bec42fe552d923b0cade4c0579f8eb
|
7
|
+
data.tar.gz: c912b72514aa9c218478d50886f5c899f1df601d9c0b6af437e173db68740bab18a3d18de72cf7b0ed796f49d98f9d02a6b080337fc6bd4441bd294989a1f744
|
data/README.md
CHANGED
@@ -67,8 +67,13 @@ Generating SNILSes in factories for tests:
|
|
67
67
|
|
68
68
|
```ruby
|
69
69
|
FactoryGirl.define do
|
70
|
+
# You can generate random valid SNILSes
|
70
71
|
sequence :snils do |_|
|
71
|
-
Snils.
|
72
|
+
Snils.generate
|
73
|
+
end
|
74
|
+
# Or sequenced ones
|
75
|
+
sequence :snils do |counter|
|
76
|
+
Snils.generate(counter)
|
72
77
|
end
|
73
78
|
|
74
79
|
factory :user do
|
data/README.ru.md
CHANGED
@@ -62,8 +62,13 @@ Snils.new("216471647").errors
|
|
62
62
|
|
63
63
|
```ruby
|
64
64
|
FactoryGirl.define do
|
65
|
+
# Вы можете генерировать случайные корректные СНИЛСы
|
65
66
|
sequence :snils do |_|
|
66
|
-
Snils.
|
67
|
+
Snils.generate
|
68
|
+
end
|
69
|
+
# Или последовательные
|
70
|
+
sequence :snils do |counter|
|
71
|
+
Snils.generate(counter)
|
67
72
|
end
|
68
73
|
|
69
74
|
factory :user do
|
data/lib/snils.rb
CHANGED
@@ -58,8 +58,11 @@ class Snils
|
|
58
58
|
end
|
59
59
|
|
60
60
|
# Generates new random valid SNILS
|
61
|
-
|
62
|
-
|
61
|
+
#
|
62
|
+
# if you'll provide +num+, it will be used as a base for new SNILS,
|
63
|
+
# checksum will be calculated automatically.
|
64
|
+
def self.generate(num = nil)
|
65
|
+
digits = num.nil? ? Array.new(9).map { rand(10) }.join : ('%09d' % num)
|
63
66
|
sum = self.new(digits).checksum
|
64
67
|
"#{digits}#{sum}"
|
65
68
|
end
|
data/lib/snils/version.rb
CHANGED