ffaker 2.13.0 → 2.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +3 -0
- data/REFERENCE.md +1 -0
- data/Rakefile +0 -6
- data/ffaker.gemspec +3 -4
- data/lib/ffaker.rb +1 -1
- data/lib/ffaker/code.rb +17 -0
- data/scripts/benchmark.rb +8 -11
- data/test/test_code.rb +22 -1
- metadata +150 -151
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e80aa4d3820c18bf3e31c146edb01329bbf8b22b0a52bae193d46407ffc9eb3d
|
4
|
+
data.tar.gz: 94a67f5502208bc8748b3e1142142c7342c0834d4a308c400e0dd7d54247b7cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2c8b4e0417c1feccd2ebcc777ea16170ccdb6ed3d5eb306b46b1e1468b7197db380a9fac2e0fb10cd646d36a523996290c6550c77a05bf9f6e7dadd7c791885
|
7
|
+
data.tar.gz: 75b46928d1dd33ccd394e9b5a550ddd336755ec1d3ce4a3c9bd6a802ea0cd130f8e28fbf8046f0587fe3c91581c2680feb061faf272097d3f1f241f8ef4bbd2b
|
data/Changelog.md
CHANGED
data/REFERENCE.md
CHANGED
data/Rakefile
CHANGED
@@ -42,10 +42,6 @@ def date
|
|
42
42
|
Date.today.to_s
|
43
43
|
end
|
44
44
|
|
45
|
-
def rubyforge_project
|
46
|
-
name
|
47
|
-
end
|
48
|
-
|
49
45
|
def gemspec_file
|
50
46
|
"#{name}.gemspec"
|
51
47
|
end
|
@@ -121,8 +117,6 @@ task gemspec: :validate do
|
|
121
117
|
replace_header(head, :name)
|
122
118
|
replace_header(head, :version)
|
123
119
|
replace_header(head, :date)
|
124
|
-
# comment this out if your rubyforge_project has a different name
|
125
|
-
replace_header(head, :rubyforge_project)
|
126
120
|
|
127
121
|
# determine file list from git ls-files
|
128
122
|
files = `git ls-files`
|
data/ffaker.gemspec
CHANGED
@@ -6,9 +6,8 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.rubygems_version = '1.3.5'
|
7
7
|
|
8
8
|
s.name = 'ffaker'
|
9
|
-
s.version = '2.
|
10
|
-
s.date = '
|
11
|
-
s.rubyforge_project = 'ffaker'
|
9
|
+
s.version = '2.14.0'
|
10
|
+
s.date = '2020-03-11'
|
12
11
|
s.required_ruby_version = '>= 2.4'
|
13
12
|
|
14
13
|
s.license = 'MIT'
|
@@ -43,6 +42,6 @@ Gem::Specification.new do |s|
|
|
43
42
|
|
44
43
|
s.test_files = Dir['test/**/*']
|
45
44
|
|
46
|
-
s.add_development_dependency 'rake', '~>
|
45
|
+
s.add_development_dependency 'rake', '~> 13.0'
|
47
46
|
s.add_development_dependency 'test-unit'
|
48
47
|
end
|
data/lib/ffaker.rb
CHANGED
data/lib/ffaker/code.rb
CHANGED
@@ -5,6 +5,23 @@ module FFaker
|
|
5
5
|
extend ModuleUtils
|
6
6
|
extend self
|
7
7
|
|
8
|
+
def npi(legacy: false)
|
9
|
+
max = legacy ? 299_999_999 : 999_999_999
|
10
|
+
base_npi = rand(100_000_000..max).to_s
|
11
|
+
|
12
|
+
summed_digits = base_npi
|
13
|
+
.chars
|
14
|
+
.each_with_index
|
15
|
+
.map { |n, i| (i.even? ? n.to_i * 2 : n).to_s }
|
16
|
+
.join
|
17
|
+
.chars
|
18
|
+
.inject(0) { |sum, digit| sum + digit.to_i }
|
19
|
+
|
20
|
+
npi_checksum = (10 - (24 + summed_digits) % 10).to_s.chars.last
|
21
|
+
|
22
|
+
base_npi + npi_checksum
|
23
|
+
end
|
24
|
+
|
8
25
|
def ean
|
9
26
|
ean = rand(100_000_000_000..999_999_999_999).to_s
|
10
27
|
|
data/scripts/benchmark.rb
CHANGED
@@ -1,22 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rubygems'
|
4
3
|
require 'benchmark'
|
5
4
|
|
6
|
-
|
5
|
+
NAMES_COUNT = 10_000
|
7
6
|
|
8
7
|
def run(name)
|
9
|
-
require name
|
10
8
|
Benchmark.bm do |rep|
|
11
|
-
rep.report("generating #{
|
12
|
-
|
13
|
-
|
14
|
-
end
|
9
|
+
rep.report("generating #{NAMES_COUNT} names (#{name})") do
|
10
|
+
mod == 'ffaker' ? FFaker : Faker
|
11
|
+
NAMES_COUNT.times { mod::Name.name }
|
15
12
|
end
|
16
13
|
end
|
17
|
-
$stdout.flush
|
18
|
-
exit(0)
|
19
14
|
end
|
20
15
|
|
21
|
-
|
22
|
-
|
16
|
+
['faker', 'ffaker'].each do |gem_name|
|
17
|
+
require gem_name
|
18
|
+
fork { run(gem_name) }; Process.wait
|
19
|
+
end
|
data/test/test_code.rb
CHANGED
@@ -5,7 +5,28 @@ require 'helper'
|
|
5
5
|
class TestCode < Test::Unit::TestCase
|
6
6
|
include DeterministicHelper
|
7
7
|
|
8
|
-
assert_methods_are_deterministic(FFaker::Code, :ean)
|
8
|
+
assert_methods_are_deterministic(FFaker::Code, :ean, :npi)
|
9
|
+
|
10
|
+
def test_npi_legacy_regexp
|
11
|
+
assert FFaker::Code.npi(legacy: true).match(/\A(1|2)[0-9]{9}\z/)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_npi
|
15
|
+
FFaker::Random.seed = 523_456_789
|
16
|
+
assert FFaker::Code.npi == '7411850515'
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_deterministic_npi
|
20
|
+
FFaker::Random.seed = 42
|
21
|
+
v = FFaker::Code.npi
|
22
|
+
FFaker::Random.reset!
|
23
|
+
assert v == FFaker::Code.npi
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_valid_npi
|
27
|
+
FFaker::Random.seed = 123_456_789
|
28
|
+
assert FFaker::Code.npi == '2410167607'
|
29
|
+
end
|
9
30
|
|
10
31
|
def test_ean
|
11
32
|
assert FFaker::Code.ean.match(/^\d{13}$/)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/ffaker/ffaker/graphs/contributors
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: '13.0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: '13.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: test-unit
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -751,180 +751,179 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
751
751
|
- !ruby/object:Gem::Version
|
752
752
|
version: '0'
|
753
753
|
requirements: []
|
754
|
-
|
755
|
-
rubygems_version: 2.7.6
|
754
|
+
rubygems_version: 3.0.3
|
756
755
|
signing_key:
|
757
756
|
specification_version: 2
|
758
757
|
summary: Ffaker generates dummy data.
|
759
758
|
test_files:
|
760
|
-
- test/
|
761
|
-
- test/test_ssn_se.rb
|
762
|
-
- test/test_phone_number_ru.rb
|
763
|
-
- test/test_identification_es_cl.rb
|
764
|
-
- test/test_identification_kr.rb
|
765
|
-
- test/test_address_mx.rb
|
766
|
-
- test/test_name_ph.rb
|
767
|
-
- test/test_name.rb
|
768
|
-
- test/test_company_se.rb
|
769
|
-
- test/test_gender_pl.rb
|
770
|
-
- test/test_tweet.rb
|
771
|
-
- test/test_animal.rb
|
772
|
-
- test/test_color_pl.rb
|
773
|
-
- test/test_address_ja.rb
|
774
|
-
- test/test_avatar.rb
|
759
|
+
- test/test_name_se.rb
|
775
760
|
- test/test_phone_number_kr.rb
|
776
761
|
- test/test_lorem_ua.rb
|
762
|
+
- test/test_animal_cn.rb
|
777
763
|
- test/test_name_pl.rb
|
778
|
-
- test/
|
779
|
-
- test/test_phone_number_cu.rb
|
780
|
-
- test/test_address_id.rb
|
781
|
-
- test/test_phone_number_pl.rb
|
782
|
-
- test/test_nato_alphabet.rb
|
783
|
-
- test/test_job_cn.rb
|
764
|
+
- test/test_ssn.rb
|
784
765
|
- test/test_education.rb
|
785
|
-
- test/
|
786
|
-
- test/
|
766
|
+
- test/test_name_ga.rb
|
767
|
+
- test/test_gender.rb
|
768
|
+
- test/test_name_br.rb
|
769
|
+
- test/test_address_fi.rb
|
787
770
|
- test/test_name_th.rb
|
788
|
-
- test/
|
789
|
-
- test/
|
790
|
-
- test/
|
771
|
+
- test/test_name_vn.rb
|
772
|
+
- test/test_music.rb
|
773
|
+
- test/test_lorem_ru.rb
|
774
|
+
- test/test_job.rb
|
775
|
+
- test/test_address_ch.rb
|
776
|
+
- test/test_address_br.rb
|
777
|
+
- test/test_venue.rb
|
778
|
+
- test/test_name_ph.rb
|
779
|
+
- test/test_address_nl.rb
|
791
780
|
- test/test_job_br.rb
|
792
|
-
- test/
|
793
|
-
- test/
|
794
|
-
- test/
|
795
|
-
- test/
|
796
|
-
- test/
|
797
|
-
- test/
|
798
|
-
- test/
|
799
|
-
- test/
|
781
|
+
- test/test_name_es.rb
|
782
|
+
- test/test_gender_id.rb
|
783
|
+
- test/test_name_ru.rb
|
784
|
+
- test/test_phone_number_se.rb
|
785
|
+
- test/test_identification_es.rb
|
786
|
+
- test/test_bank.rb
|
787
|
+
- test/test_phone_number_ua.rb
|
788
|
+
- test/test_cheesy_lingo.rb
|
789
|
+
- test/test_lorem_fr.rb
|
800
790
|
- test/test_units.rb
|
791
|
+
- test/test_array_utils.rb
|
792
|
+
- test/helper.rb
|
793
|
+
- test/test_name_nb.rb
|
794
|
+
- test/test_name_ua.rb
|
795
|
+
- test/test_faker.rb
|
796
|
+
- test/test_identification_es_cl.rb
|
797
|
+
- test/test_name_de.rb
|
801
798
|
- test/test_sports.rb
|
799
|
+
- test/test_address_ca.rb
|
800
|
+
- test/test_name_nl.rb
|
801
|
+
- test/test_nato_alphabet.rb
|
802
|
+
- test/test_job_vn.rb
|
803
|
+
- test/test_gender_br.rb
|
804
|
+
- test/test_book.rb
|
805
|
+
- test/test_guid.rb
|
806
|
+
- test/test_code.rb
|
807
|
+
- test/test_address_pl.rb
|
808
|
+
- test/test_avatar.rb
|
809
|
+
- test/test_name_sn.rb
|
810
|
+
- test/test_name_gr.rb
|
811
|
+
- test/test_address_kr.rb
|
812
|
+
- test/test_address_uk.rb
|
813
|
+
- test/test_movie.rb
|
814
|
+
- test/test_course_mathematiques.rb
|
815
|
+
- test/test_address_sn.rb
|
816
|
+
- test/test_name_tw.rb
|
817
|
+
- test/test_name_mx.rb
|
818
|
+
- test/test_phone_number_da.rb
|
819
|
+
- test/test_aws.rb
|
820
|
+
- test/test_html_ipsum.rb
|
821
|
+
- test/test_currency.rb
|
802
822
|
- test/test_education_cn.rb
|
803
|
-
- test/
|
804
|
-
- test/
|
805
|
-
- test/
|
806
|
-
- test/test_cheesy_lingo.rb
|
807
|
-
- test/test_animal_us.rb
|
823
|
+
- test/test_food.rb
|
824
|
+
- test/test_gender_jp.rb
|
825
|
+
- test/test_healthcare_ipsum.rb
|
808
826
|
- test/test_name_th_en.rb
|
809
|
-
- test/
|
827
|
+
- test/test_geolocation.rb
|
828
|
+
- test/test_job_fr.rb
|
829
|
+
- test/test_address_ch_fr.rb
|
810
830
|
- test/test_phone_number_id.rb
|
831
|
+
- test/test_phone_number.rb
|
832
|
+
- test/test_youtube.rb
|
833
|
+
- test/test_phone_number_nl.rb
|
834
|
+
- test/test_module_utils.rb
|
835
|
+
- test/test_vehicle.rb
|
836
|
+
- test/test_name_ar.rb
|
837
|
+
- test/test_boolean.rb
|
838
|
+
- test/test_job_kr.rb
|
839
|
+
- test/test_address_ua.rb
|
840
|
+
- test/test_lorem_kr.rb
|
811
841
|
- test/test_company_it.rb
|
812
|
-
- test/
|
813
|
-
- test/
|
814
|
-
- test/
|
842
|
+
- test/test_identification_co.rb
|
843
|
+
- test/test_animal.rb
|
844
|
+
- test/test_name_it.rb
|
845
|
+
- test/test_address_ja.rb
|
846
|
+
- test/test_phone_number_ru.rb
|
847
|
+
- test/test_address_se.rb
|
848
|
+
- test/test_airline.rb
|
849
|
+
- test/test_gender_ja.rb
|
850
|
+
- test/test_address_fr.rb
|
851
|
+
- test/test_lorem.rb
|
815
852
|
- test/test_address_in.rb
|
816
|
-
- test/
|
817
|
-
- test/
|
818
|
-
- test/
|
819
|
-
- test/
|
820
|
-
- test/
|
821
|
-
- test/
|
822
|
-
- test/
|
823
|
-
- test/
|
824
|
-
- test/
|
825
|
-
- test/test_lorem_ar.rb
|
853
|
+
- test/test_phone_number_pl.rb
|
854
|
+
- test/test_tweet.rb
|
855
|
+
- test/test_internet_se.rb
|
856
|
+
- test/test_identification_kr.rb
|
857
|
+
- test/test_ssn_mx.rb
|
858
|
+
- test/test_phone_number_au.rb
|
859
|
+
- test/test_image.rb
|
860
|
+
- test/test_unique_utils.rb
|
861
|
+
- test/test_address_au.rb
|
826
862
|
- test/test_lorem_cn.rb
|
827
|
-
- test/test_animal_cn.rb
|
828
|
-
- test/test_address_fi.rb
|
829
|
-
- test/test_currency.rb
|
830
|
-
- test/test_address_ch.rb
|
831
|
-
- test/test_address_ru.rb
|
832
|
-
- test/test_phone_number_mx.rb
|
833
|
-
- test/test_phone_number_da.rb
|
834
863
|
- test/test_address_ch_it.rb
|
835
|
-
- test/
|
864
|
+
- test/test_gender_kr.rb
|
865
|
+
- test/test_address_id.rb
|
836
866
|
- test/test_internet.rb
|
837
|
-
- test/
|
838
|
-
- test/
|
839
|
-
- test/
|
840
|
-
- test/
|
841
|
-
- test/
|
867
|
+
- test/test_phone_number_sg.rb
|
868
|
+
- test/test_filesystem.rb
|
869
|
+
- test/test_color.rb
|
870
|
+
- test/test_sport_us.rb
|
871
|
+
- test/test_name_ja.rb
|
872
|
+
- test/test_company.rb
|
873
|
+
- test/test_name_cs.rb
|
874
|
+
- test/test_course_philosophie.rb
|
875
|
+
- test/test_address_da.rb
|
876
|
+
- test/test_company_se.rb
|
877
|
+
- test/test_lorem_ie.rb
|
878
|
+
- test/test_products.rb
|
879
|
+
- test/test_sport_pl.rb
|
880
|
+
- test/test_company_cn.rb
|
842
881
|
- test/test_address_us.rb
|
843
|
-
- test/
|
844
|
-
- test/
|
882
|
+
- test/test_job_ja.rb
|
883
|
+
- test/test_address_ch_de.rb
|
884
|
+
- test/test_name_id.rb
|
885
|
+
- test/test_address_ru.rb
|
886
|
+
- test/test_color_pl.rb
|
887
|
+
- test/test_address_mx.rb
|
888
|
+
- test/test_name_kr.rb
|
889
|
+
- test/test_name_cn.rb
|
890
|
+
- test/test_healthcare_ru.rb
|
891
|
+
- test/test_conference.rb
|
892
|
+
- test/test_phone_number_br.rb
|
893
|
+
- test/test_gender_pl.rb
|
894
|
+
- test/test_name_kh.rb
|
895
|
+
- test/test_identification_es_mx.rb
|
845
896
|
- test/test_phone_number_de.rb
|
897
|
+
- test/test_name_fr.rb
|
898
|
+
- test/test_color_ua.rb
|
899
|
+
- test/test_lorem_ar.rb
|
900
|
+
- test/test_identification_pl.rb
|
846
901
|
- test/test_units_english.rb
|
847
|
-
- test/
|
848
|
-
- test/
|
849
|
-
- test/test_dizzle_ipsum.rb
|
850
|
-
- test/test_array_utils.rb
|
851
|
-
- test/test_sem_ver.rb
|
902
|
+
- test/test_identification_br.rb
|
903
|
+
- test/test_gender_cn.rb
|
852
904
|
- test/test_animal_pl.rb
|
853
|
-
- test/
|
854
|
-
- test/test_name_ua.rb
|
855
|
-
- test/test_address_nl.rb
|
856
|
-
- test/test_address_fr.rb
|
857
|
-
- test/test_address_sn.rb
|
905
|
+
- test/test_skill.rb
|
858
906
|
- test/test_lorem_pl.rb
|
859
|
-
- test/test_lorem_kr.rb
|
860
|
-
- test/test_phone_number_ua.rb
|
861
|
-
- test/test_address_br.rb
|
862
|
-
- test/test_string.rb
|
863
|
-
- test/test_guid.rb
|
864
|
-
- test/test_address_ch_fr.rb
|
865
|
-
- test/test_ssn.rb
|
866
|
-
- test/test_unique_utils.rb
|
867
|
-
- test/test_geolocation.rb
|
868
|
-
- test/test_name_ga.rb
|
869
|
-
- test/test_vehicle.rb
|
870
|
-
- test/test_name_se.rb
|
871
|
-
- test/test_name_de.rb
|
872
|
-
- test/test_bank.rb
|
873
|
-
- test/test_boolean.rb
|
874
|
-
- test/test_lorem.rb
|
875
|
-
- test/test_lorem_ru.rb
|
876
907
|
- test/test_name_da.rb
|
877
|
-
- test/
|
878
|
-
- test/
|
879
|
-
- test/
|
880
|
-
- test/
|
881
|
-
- test/
|
882
|
-
- test/
|
883
|
-
- test/
|
884
|
-
- test/
|
885
|
-
- test/
|
886
|
-
- test/test_name_gr.rb
|
887
|
-
- test/test_airline.rb
|
888
|
-
- test/test_aws.rb
|
889
|
-
- test/test_conference.rb
|
908
|
+
- test/test_ssn_se.rb
|
909
|
+
- test/test_bacon_ipsum.rb
|
910
|
+
- test/test_phone_number_tw.rb
|
911
|
+
- test/test_string.rb
|
912
|
+
- test/test_address_de.rb
|
913
|
+
- test/test_address_gr.rb
|
914
|
+
- test/test_phone_number_mx.rb
|
915
|
+
- test/test_hipster_ipsum.rb
|
916
|
+
- test/test_animal_us.rb
|
890
917
|
- test/test_lorem_ja.rb
|
891
|
-
- test/
|
892
|
-
- test/test_movie.rb
|
893
|
-
- test/test_address_ua.rb
|
894
|
-
- test/test_phone_number_br.rb
|
895
|
-
- test/test_name_sn.rb
|
896
|
-
- test/test_course_mathematiques.rb
|
897
|
-
- test/test_name_cs.rb
|
898
|
-
- test/test_identification_es.rb
|
899
|
-
- test/test_name_nl.rb
|
918
|
+
- test/test_sem_ver.rb
|
900
919
|
- test/test_locale.rb
|
901
|
-
- test/
|
902
|
-
- test/
|
903
|
-
- test/
|
904
|
-
- test/
|
905
|
-
- test/
|
906
|
-
- test/
|
907
|
-
- test/
|
908
|
-
- test/test_gender_cn.rb
|
909
|
-
- test/test_phone_number_sn.rb
|
920
|
+
- test/test_dizzle_ipsum.rb
|
921
|
+
- test/test_phone_number_cu.rb
|
922
|
+
- test/test_address.rb
|
923
|
+
- test/test_name.rb
|
924
|
+
- test/test_job_cn.rb
|
925
|
+
- test/test_units_metric.rb
|
926
|
+
- test/test_time.rb
|
910
927
|
- test/test_phone_number_fr.rb
|
911
|
-
- test/
|
912
|
-
- test/test_faker.rb
|
913
|
-
- test/test_gender_jp.rb
|
914
|
-
- test/test_address_se.rb
|
915
|
-
- test/test_name_vn.rb
|
916
|
-
- test/test_address_de.rb
|
917
|
-
- test/test_ssn_mx.rb
|
928
|
+
- test/test_phone_number_sn.rb
|
918
929
|
- test/test_identification.rb
|
919
|
-
- test/test_bacon_ipsum.rb
|
920
|
-
- test/test_gender_br.rb
|
921
|
-
- test/test_name_ar.rb
|
922
|
-
- test/test_course_philosophie.rb
|
923
|
-
- test/test_phone_number_tw.rb
|
924
|
-
- test/test_name_cn.rb
|
925
|
-
- test/test_address_da.rb
|
926
|
-
- test/test_name_it.rb
|
927
|
-
- test/test_name_kh.rb
|
928
|
-
- test/test_name_es.rb
|
929
|
-
- test/test_job_kr.rb
|
930
|
-
- test/test_html_ipsum.rb
|