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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de5e451ca4c630460be33cc18f72638a608c932c797017afa25a405a328dfcdd
4
- data.tar.gz: b7641f275b6dcb1e0f4edc1fa9a476c2f243a6802a2d95c2abf5339d644da276
3
+ metadata.gz: e80aa4d3820c18bf3e31c146edb01329bbf8b22b0a52bae193d46407ffc9eb3d
4
+ data.tar.gz: 94a67f5502208bc8748b3e1142142c7342c0834d4a308c400e0dd7d54247b7cf
5
5
  SHA512:
6
- metadata.gz: 5b1455abd7797ae7221dd47f8c3cc99cfedd1bf8739c67ed5ad440108b3b8c109bcae0171234e6c5c5fe02c23066986382da402a73db0728a43b59f253362465
7
- data.tar.gz: 07b818140be988bcf18227a1b21903077a0d6b772748e6a5c3072d4fe209e030a66ffebcf537fa4d78c87be06aee7344ee375d3d7cdac1009f0c950ee9f61e9c
6
+ metadata.gz: c2c8b4e0417c1feccd2ebcc777ea16170ccdb6ed3d5eb306b46b1e1468b7197db380a9fac2e0fb10cd646d36a523996290c6550c77a05bf9f6e7dadd7c791885
7
+ data.tar.gz: 75b46928d1dd33ccd394e9b5a550ddd336755ec1d3ce4a3c9bd6a802ea0cd130f8e28fbf8046f0587fe3c91581c2680feb061faf272097d3f1f241f8ef4bbd2b
@@ -2,6 +2,9 @@
2
2
 
3
3
  - Add your change HERE
4
4
 
5
+ ## 2.14.0
6
+ - Add `Code.npi` [@alibby]
7
+
5
8
  ## 2.13.0
6
9
  - Add `Bank.card_number`, `.card_expiry_date` and `.card_type` [@AlexWayfer]
7
10
  - Add `Bank.iban` [@Volosh1n]
@@ -913,6 +913,7 @@
913
913
  | Method | Example |
914
914
  | ------ | ------- |
915
915
  | `ean` | 3898841772821, 4659685709508, 6077985245362 |
916
+ | `npi` | 3657840229, 4282614922, 6249306468 |
916
917
 
917
918
  ## FFaker::Color
918
919
 
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`
@@ -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.13.0'
10
- s.date = '2019-10-04'
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', '~> 10.1.1'
45
+ s.add_development_dependency 'rake', '~> 13.0'
47
46
  s.add_development_dependency 'test-unit'
48
47
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FFaker
4
- VERSION = '2.13.0'
4
+ VERSION = '2.14.0'
5
5
 
6
6
  require 'ffaker/utils/array_utils'
7
7
  require 'ffaker/utils/module_utils'
@@ -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
 
@@ -1,22 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rubygems'
4
3
  require 'benchmark'
5
4
 
6
- N = 10_000
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 #{N} names (#{name} #{FFaker::VERSION})") do
12
- N.times do
13
- FFaker::Name.name
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
- fork { run('faker') }; Process.wait
22
- fork { run('ffaker') }; Process.wait
16
+ ['faker', 'ffaker'].each do |gem_name|
17
+ require gem_name
18
+ fork { run(gem_name) }; Process.wait
19
+ end
@@ -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.13.0
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: 2019-10-04 00:00:00.000000000 Z
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: 10.1.1
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: 10.1.1
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
- rubyforge_project: ffaker
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/test_job_fr.rb
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/test_name_kr.rb
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/test_job_vn.rb
786
- - test/test_gender_kr.rb
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/test_name_ru.rb
789
- - test/test_identification_pl.rb
790
- - test/test_phone_number_au.rb
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/test_food.rb
793
- - test/test_color.rb
794
- - test/test_name_mx.rb
795
- - test/test_gender_ja.rb
796
- - test/test_phone_number_sg.rb
797
- - test/test_address_au.rb
798
- - test/helper.rb
799
- - test/test_sport_pl.rb
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/test_company_cn.rb
804
- - test/test_venue.rb
805
- - test/test_name_ja.rb
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/test_gender.rb
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/test_address_pl.rb
813
- - test/test_lorem_fr.rb
814
- - test/test_name_id.rb
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/test_address_kr.rb
817
- - test/test_identification_es_mx.rb
818
- - test/test_book.rb
819
- - test/test_skill.rb
820
- - test/test_filesystem.rb
821
- - test/test_healthcare_ru.rb
822
- - test/test_phone_number.rb
823
- - test/test_units_metric.rb
824
- - test/test_gender_id.rb
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/test_sport_us.rb
864
+ - test/test_gender_kr.rb
865
+ - test/test_address_id.rb
836
866
  - test/test_internet.rb
837
- - test/test_job_ja.rb
838
- - test/test_image.rb
839
- - test/test_name_nb.rb
840
- - test/test_module_utils.rb
841
- - test/test_color_ua.rb
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/test_address_gr.rb
844
- - test/test_phone_number_se.rb
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/test_hipster_ipsum.rb
848
- - test/test_healthcare_ipsum.rb
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/test_address_uk.rb
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/test_code.rb
878
- - test/test_internet_se.rb
879
- - test/test_address.rb
880
- - test/test_identification_br.rb
881
- - test/test_name_tw.rb
882
- - test/test_products.rb
883
- - test/test_address_ch_de.rb
884
- - test/test_time.rb
885
- - test/test_lorem_ie.rb
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/test_address_ca.rb
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/test_name_fr.rb
902
- - test/test_music.rb
903
- - test/test_job.rb
904
- - test/test_youtube.rb
905
- - test/test_name_br.rb
906
- - test/test_identification_co.rb
907
- - test/test_company.rb
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/test_phone_number_nl.rb
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