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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99c4655619df5fecbcaaa1dac708f9fbb38405f2
4
- data.tar.gz: 207dc1ae3644b46612577782e8abe73170ce12d4
3
+ metadata.gz: e2d5331ca5ae9415ba0dbe3bacf90d481b956438
4
+ data.tar.gz: 16ac1c6f7e865be1eab804d7fb65657133160efa
5
5
  SHA512:
6
- metadata.gz: 4f84bff954d0023d02045428eef5f3982afece00c5a1b7fa5964e580c07cf27abc0d2e3d9a0cbd2962e40c5ba5f9912e6168eb3a7b5516aa895c177043e3c7e5
7
- data.tar.gz: c154aff4dec2ae7e159272c7a733a48f6b02a16ced43e24e540c6f3a63847f57d4df4a19f5db0c73349fc9009e7805762682b4c7273225095f9792e8244485d8
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.new.to_s
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
@@ -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.new.to_s
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
@@ -58,8 +58,11 @@ class Snils
58
58
  end
59
59
 
60
60
  # Generates new random valid SNILS
61
- def self.generate
62
- digits = Array.new(9).map { rand(10) }.join
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
@@ -1,3 +1,3 @@
1
1
  class Snils
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Novikov