fake_faker 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.travis.yml +7 -0
  4. data/CHANGELOG.md +13 -0
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +30 -0
  7. data/README.md +35 -0
  8. data/Rakefile +10 -0
  9. data/bin/console +14 -0
  10. data/bin/generate_wrapper +218 -0
  11. data/bin/setup +8 -0
  12. data/fake_faker.gemspec +34 -0
  13. data/lib/fake_faker.rb +46 -0
  14. data/lib/fake_faker/address.rb +25 -0
  15. data/lib/fake_faker/alphanumeric.rb +13 -0
  16. data/lib/fake_faker/avatar.rb +9 -0
  17. data/lib/fake_faker/bank.rb +13 -0
  18. data/lib/fake_faker/books.rb +7 -0
  19. data/lib/fake_faker/books/dune.rb +15 -0
  20. data/lib/fake_faker/books/lovecraft.rb +35 -0
  21. data/lib/fake_faker/chilerut.rb +13 -0
  22. data/lib/fake_faker/code.rb +17 -0
  23. data/lib/fake_faker/commerce.rb +17 -0
  24. data/lib/fake_faker/company.rb +9 -0
  25. data/lib/fake_faker/cryptocoin.rb +17 -0
  26. data/lib/fake_faker/date.rb +25 -0
  27. data/lib/fake_faker/demographic.rb +9 -0
  28. data/lib/fake_faker/file.rb +13 -0
  29. data/lib/fake_faker/fillmurray.rb +9 -0
  30. data/lib/fake_faker/finance.rb +9 -0
  31. data/lib/fake_faker/hipster.rb +29 -0
  32. data/lib/fake_faker/internet.rb +53 -0
  33. data/lib/fake_faker/invoice.rb +17 -0
  34. data/lib/fake_faker/json.rb +13 -0
  35. data/lib/fake_faker/lorem.rb +41 -0
  36. data/lib/fake_faker/loremflickr.rb +21 -0
  37. data/lib/fake_faker/lorempixel.rb +9 -0
  38. data/lib/fake_faker/markdown.rb +9 -0
  39. data/lib/fake_faker/measurement.rb +37 -0
  40. data/lib/fake_faker/movies.rb +6 -0
  41. data/lib/fake_faker/movies/starwars.rb +11 -0
  42. data/lib/fake_faker/name.rb +9 -0
  43. data/lib/fake_faker/nationalhealthservice.rb +9 -0
  44. data/lib/fake_faker/number.rb +45 -0
  45. data/lib/fake_faker/phonenumber.rb +13 -0
  46. data/lib/fake_faker/placeholdit.rb +9 -0
  47. data/lib/fake_faker/relationship.rb +9 -0
  48. data/lib/fake_faker/source.rb +13 -0
  49. data/lib/fake_faker/string.rb +9 -0
  50. data/lib/fake_faker/stripe.rb +21 -0
  51. data/lib/fake_faker/time.rb +17 -0
  52. data/lib/fake_faker/types.rb +25 -0
  53. data/lib/fake_faker/vehicle.rb +21 -0
  54. data/lib/fake_faker/version.rb +3 -0
  55. data/lib/fake_faker/worldcup.rb +13 -0
  56. data/templates/klass.erb +22 -0
  57. metadata +170 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 44f4e2ec792d88a1ea28227f49316767daf0bf1f5a5047ee09819d03011093db
4
+ data.tar.gz: 9b455b990794d3dbdadf7a151e9016dcdb98331b7b1eb5063e6a3a742465abbe
5
+ SHA512:
6
+ metadata.gz: 0fd5cd60edab5e59d4adcf93b923331efcb51a8014bdfb38445f04fe3d466bc6f0ea2b908f2a1c6bcb07be373b9b2d5da3f11fca0d5f1e6976b1bb64df16bbec
7
+ data.tar.gz: 07e03d3f67c7736ce38c358035f212023aade31df7226e963388a5d6df8f24a0ea823d08de1d50400207130a9ed3e57052d7270f56c6986cb031132b342fabfe
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 2.0.2
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - 2019-08-21
10
+
11
+ ### Added
12
+
13
+ - Wrapper classes to provide Faker V1 API
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in fake_faker.gemspec
4
+ gemspec
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fake_faker (0.1.0)
5
+ faker (>= 2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ concurrent-ruby (1.1.5)
11
+ faker (2.1.2)
12
+ i18n (>= 0.8)
13
+ i18n (1.6.0)
14
+ concurrent-ruby (~> 1.0)
15
+ minitest (5.11.3)
16
+ rake (10.5.0)
17
+ rufo (0.7.0)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ bundler (~> 2.0)
24
+ fake_faker!
25
+ minitest (~> 5.0)
26
+ rake (~> 10.0)
27
+ rufo
28
+
29
+ BUNDLED WITH
30
+ 2.0.2
@@ -0,0 +1,35 @@
1
+ # FakeFaker
2
+
3
+ Faker V2.0 introduced a lot of breaking changes due to replacing positonal arguments to keyword arguments. This gem provides wrapper classes those affected by the changes.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'fake_faker', group: :test
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install fake_faker
20
+
21
+ ## Usage
22
+
23
+ Replace `Faker` to `FakeFaker` ***only*** where V2 API breaking changes caused errors.
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ Most of class files under `lib/fake_faker` are automatilcally generated by `bin/generate_wrapper`. Please see the file before startig development.
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/masa-iwasaki/fake_faker.
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fake_faker"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,218 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ md = <<MARKDOWN
4
+ - `Faker::Books::Dune.quote(character = nil)` becomes `Faker::Books::Dune.quote(character: nil)`
5
+ - `Faker::Books::Dune.saying(source = nil)` becomes `Faker::Books::Dune.saying(source: nil)`
6
+ - `Faker::Books::Lovecraft.fhtagn(number_of = nil)` becomes `Faker::Books::Lovecraft.fhtagn(number: nil)`
7
+ - `Faker::Books::Lovecraft.paragraph(sentence_count = nil, random_sentences_to_add = nil)` becomes `Faker::Books::Lovecraft.paragraph(sentence_count: nil, random_sentences_to_add: nil)`
8
+ - `Faker::Books::Lovecraft.paragraph_by_chars(chars = nil)` becomes `Faker::Books::Lovecraft.paragraph_by_chars(characters: nil)`
9
+ - `Faker::Books::Lovecraft.paragraphs(paragraph_count = nil)` becomes `Faker::Books::Lovecraft.paragraphs(number: nil)`
10
+ - `Faker::Books::Lovecraft.sentence(word_count = nil, random_words_to_add = nil)` becomes `Faker::Books::Lovecraft.sentence(word_count: nil, random_words_to_add: nil)`
11
+ - `Faker::Books::Lovecraft.sentences(sentence_count = nil)` becomes `Faker::Books::Lovecraft.sentences(number: nil)`
12
+ - `Faker::Books::Lovecraft.words(num = nil, spaces_allowed = nil)` becomes `Faker::Books::Lovecraft.words(number: nil, spaces_allowed: nil)`
13
+ - `Faker::Address.city(options = nil)` becomes `Faker::Address.city(options: nil)`
14
+ - `Faker::Address.postcode(state_abbreviation = nil)` becomes `Faker::Address.postcode(state_abbreviation: nil)`
15
+ - `Faker::Address.street_address(include_secondary = nil)` becomes `Faker::Address.street_address(include_secondary: nil)`
16
+ - `Faker::Address.zip(state_abbreviation = nil)` becomes `Faker::Address.zip(state_abbreviation: nil)`
17
+ - `Faker::Address.zip_code(state_abbreviation = nil)` becomes `Faker::Address.zip_code(state_abbreviation: nil)`
18
+ - `Faker::Alphanumeric.alpha(char_count = nil)` becomes `Faker::Alphanumeric.alpha(number: nil)`
19
+ - `Faker::Alphanumeric.alphanumeric(char_count = nil)` becomes `Faker::Alphanumeric.alphanumeric(number: nil)`
20
+ - `Faker::Avatar.image(slug = nil, size = nil, format = nil, set = nil, bgset = nil)` becomes `Faker::Avatar.image(slug: nil, size: nil, format: nil, set: nil, bgset: nil)`
21
+ - `Faker::Bank.account_number(digits = nil)` becomes `Faker::Bank.account_number(digits: nil)`
22
+ - `Faker::Bank.iban(country_code = nil)` becomes `Faker::Bank.iban(country_code: nil)`
23
+ - `Faker::ChileRut.full_rut(min_rut = nil, fixed = nil)` becomes `Faker::ChileRut.full_rut(min_rut: nil, fixed: nil)`
24
+ - `Faker::ChileRut.rut(min_rut = nil, fixed = nil)` becomes `Faker::ChileRut.rut(min_rut: nil, fixed: nil)`
25
+ - `Faker::Code.ean(base = nil)` becomes `Faker::Code.ean(base: nil)`
26
+ - `Faker::Code.isbn(base = nil)` becomes `Faker::Code.isbn(base: nil)`
27
+ - `Faker::Code.nric(min_age = nil, max_age = nil)` becomes `Faker::Code.nric(min_age: nil, max_age: nil)`
28
+ - `Faker::Commerce.department(max = nil, fixed_amount = nil)` becomes `Faker::Commerce.department(max: nil, fixed_amount: nil)`
29
+ - `Faker::Commerce.price(range = nil, as_string = nil)` becomes `Faker::Commerce.price(range: nil, as_string: nil)`
30
+ - `Faker::Commerce.promotion_code(digits = nil)` becomes `Faker::Commerce.promotion_code(digits: nil)`
31
+ - `Faker::Company.polish_register_of_national_economy(length = nil)` becomes `Faker::Company.polish_register_of_national_economy(length: nil)`
32
+ - `Faker::CryptoCoin.acronym(coin = nil)` becomes `Faker::CryptoCoin.acronym(coin: nil)`
33
+ - `Faker::CryptoCoin.coin_name(coin = nil)` becomes `Faker::CryptoCoin.coin_name(coin: nil)`
34
+ - `Faker::CryptoCoin.url_logo(coin = nil)` becomes `Faker::CryptoCoin.url_logo(coin: nil)`
35
+ - `Faker::Date.backward(days = nil)` becomes `Faker::Date.backward(days: nil)`
36
+ - `Faker::Date.between(from, to)` becomes `Faker::Date.between(from:, to:)`
37
+ - `Faker::Date.between_except(from, to, excepted)` becomes `Faker::Date.between_except(from:, to:, excepted:)`
38
+ - `Faker::Date.birthday(min_age = nil, max_age = nil)` becomes `Faker::Date.birthday(min_age: nil, max_age: nil)`
39
+ - `Faker::Date.forward(days = nil)` becomes `Faker::Date.forward(days: nil)`
40
+ - `Faker::Demographic.height(unit = nil)` becomes `Faker::Demographic.height(unit: nil)`
41
+ - `Faker::File.dir(segment_count = nil, root = nil, directory_separator = nil)` becomes `Faker::File.dir(segment_count: nil, root: nil, directory_separator: nil)`
42
+ - `Faker::File.file_name(dir = nil, name = nil, ext = nil, directory_separator = nil)` becomes `Faker::File.file_name(dir: nil, name: nil, ext: nil, directory_separator: nil)`
43
+ - `Faker::Fillmurray.image(grayscale = nil, width = nil, height = nil)` becomes `Faker::Fillmurray.image(grayscale: nil, width: nil, height: nil)`
44
+ - `Faker::Finance.vat_number(country = nil)` becomes `Faker::Finance.vat_number(country: nil)`
45
+ - `Faker::Hipster.paragraph(sentence_count = nil, supplemental = nil, random_sentences_to_add = nil)` becomes `Faker::Hipster.paragraph(sentence_count: nil, supplemental: nil, random_sentences_to_add: nil)`
46
+ - `Faker::Hipster.paragraph_by_chars(chars = nil, supplemental = nil)` becomes `Faker::Hipster.paragraph_by_chars(characters: nil, supplemental: nil)`
47
+ - `Faker::Hipster.paragraphs(paragraph_count = nil, supplemental = nil)` becomes `Faker::Hipster.paragraphs(number: nil, supplemental: nil)`
48
+ - `Faker::Hipster.sentence(word_count = nil, supplemental = nil, random_words_to_add = nil)` becomes `Faker::Hipster.sentence(word_count: nil, supplemental: nil, random_words_to_add: nil)`
49
+ - `Faker::Hipster.sentences(sentence_count = nil, supplemental = nil)` becomes `Faker::Hipster.sentences(number: nil, supplemental: nil)`
50
+ - `Faker::Hipster.words(num = nil, supplemental = nil, spaces_allowed = nil)` becomes `Faker::Hipster.words(number: nil, supplemental: nil, spaces_allowed: nil)`
51
+ - `Faker::Internet.domain_name(subdomain = nil)` becomes `Faker::Internet.domain_name(subdomain: nil)`
52
+ - `Faker::Internet.email(name = nil, *separators)` becomes `Faker::Internet.email(name: nil, separators: nil)`
53
+ - `Faker::Internet.fix_umlauts(string = nil)` becomes `Faker::Internet.fix_umlauts(string: nil)`
54
+ - `Faker::Internet.free_email(name = nil)` becomes `Faker::Internet.free_email(name: nil)`
55
+ - `Faker::Internet.mac_address(prefix = nil)` becomes `Faker::Internet.mac_address(prefix: nil)`
56
+ - `Faker::Internet.password(min_length = nil, max_length = nil, mix_case = nil, special_chars = nil)` becomes `Faker::Internet.password(min_length: nil, max_length: nil, mix_case: nil, special_characters: nil)`
57
+ - `Faker::Internet.safe_email(name = nil)` becomes `Faker::Internet.safe_email(name: nil)`
58
+ - `Faker::Internet.slug(words = nil, glue = nil)` becomes `Faker::Internet.slug(words: nil, glue: nil)`
59
+ - `Faker::Internet.url(host = nil, path = nil, scheme = nil)` becomes `Faker::Internet.url(host: nil, path: nil, scheme: nil)`
60
+ - `Faker::Internet.user_agent(vendor = nil)` becomes `Faker::Internet.user_agent(vendor: nil)`
61
+ - `Faker::Internet.user_name(specifier = nil, separators = nil)` becomes `Faker::Internet.user_name(specifier: nil, separators: nil)`
62
+ - `Faker::Internet.username(specifier = nil, separators = nil)` becomes `Faker::Internet.username(specifier: nil, separators: nil)`
63
+ - `Faker::Invoice.amount_between(from = nil, to = nil)` becomes `Faker::Invoice.amount_between(from: nil, to: nil)`
64
+ - `Faker::Invoice.creditor_reference(ref = nil)` becomes `Faker::Invoice.creditor_reference(ref: nil)`
65
+ - `Faker::Invoice.reference(ref = nil)` becomes `Faker::Invoice.reference(ref: nil)`
66
+ - `Faker::Json.add_depth_to_json(json = nil, width = nil, options = nil)` becomes `Faker::Json.add_depth_to_json(json: nil, width: nil, options: nil)`
67
+ - `Faker::Json.shallow_json(width = nil, options = nil)` becomes `Faker::Json.shallow_json(width: nil, options: nil)`
68
+ - `Faker::Lorem.characters(char_count = nil)` becomes `Faker::Lorem.characters(number: nil)`
69
+ - `Faker::Lorem.paragraph(sentence_count = nil, supplemental = nil, random_sentences_to_add = nil)` becomes `Faker::Lorem.paragraph(sentence_count: nil, supplemental: nil, random_sentences_to_add: nil)`
70
+ - `Faker::Lorem.paragraph_by_chars(chars = nil, supplemental = nil)` becomes `Faker::Lorem.paragraph_by_chars(number: nil, supplemental: nil)`
71
+ - `Faker::Lorem.paragraphs(paragraph_count = nil, supplemental = nil)` becomes `Faker::Lorem.paragraphs(number: nil, supplemental: nil)`
72
+ - `Faker::Lorem.question(word_count = nil, supplemental = nil, random_words_to_add = nil)` becomes `Faker::Lorem.question(word_count: nil, supplemental: nil, random_words_to_add: nil)`
73
+ - `Faker::Lorem.questions(question_count = nil, supplemental = nil)` becomes `Faker::Lorem.questions(number: nil, supplemental: nil)`
74
+ - `Faker::Lorem.sentence(word_count = nil, supplemental = nil, random_words_to_add = nil)` becomes `Faker::Lorem.sentence(word_count: nil, supplemental: nil, random_words_to_add: nil)`
75
+ - `Faker::Lorem.sentences(sentence_count = nil, supplemental = nil)` becomes `Faker::Lorem.sentences(number: nil, supplemental: nil)`
76
+ - `Faker::Lorem.words(num = nil, supplemental = nil)` becomes `Faker::Lorem.words(number: nil, supplemental: nil)`
77
+ - `Faker::LoremFlickr.colorized_image(size = nil, color = nil, search_terms = nil, match_all = nil)` becomes `Faker::LoremFlickr.colorized_image(size: nil, color: nil, search_terms: nil, match_all: nil)`
78
+ - `Faker::LoremFlickr.grayscale_image(size = nil, search_terms = nil, match_all = nil)` becomes `Faker::LoremFlickr.grayscale_image(size: nil, search_terms: nil, match_all: nil)`
79
+ - `Faker::LoremFlickr.image(size = nil, search_terms = nil, match_all = nil)` becomes `Faker::LoremFlickr.image(size: nil, search_terms: nil, match_all: nil)`
80
+ - `Faker::LoremFlickr.pixelated_image(size = nil, search_terms = nil, match_all = nil)` becomes `Faker::LoremFlickr.pixelated_image(size: nil, search_terms: nil, match_all: nil)`
81
+ - `Faker::LoremPixel.image(size = nil, is_gray = nil, category = nil, number = nil, text = nil, secure: nil)` becomes `Faker::LoremPixel.image(size: nil, is_gray: nil, category: nil, number: nil, text: nil, secure: nil)`
82
+ - `Faker::Markdown.sandwich(sentences = nil, repeat = nil)` becomes `Faker::Markdown.sandwich(sentences: nil, repeat: nil)`
83
+ - `Faker::Measurement.height(amount = nil)` becomes `Faker::Measurement.height(amount: nil)`
84
+ - `Faker::Measurement.length(amount = nil)` becomes `Faker::Measurement.length(amount: nil)`
85
+ - `Faker::Measurement.metric_height(amount = nil)` becomes `Faker::Measurement.metric_height(amount: nil)`
86
+ - `Faker::Measurement.metric_length(amount = nil)` becomes `Faker::Measurement.metric_length(amount: nil)`
87
+ - `Faker::Measurement.metric_volume(amount = nil)` becomes `Faker::Measurement.metric_volume(amount: nil)`
88
+ - `Faker::Measurement.metric_weight(amount = nil)` becomes `Faker::Measurement.metric_weight(amount: nil)`
89
+ - `Faker::Measurement.volume(amount = nil)` becomes `Faker::Measurement.volume(amount: nil)`
90
+ - `Faker::Measurement.weight(amount = nil)` becomes `Faker::Measurement.weight(amount: nil)`
91
+ - `Faker::Name.initials(character_count = nil)` becomes `Faker::Name.initials(number: nil)`
92
+ - `Faker::NationalHealthService.check_digit(number = nil)` becomes `Faker::NationalHealthService.check_digit(number: nil)`
93
+ - `Faker::Number.between(from = nil, to = nil)` becomes `Faker::Number.between(from: nil, to: nil)`
94
+ - `Faker::Number.decimal(l_digits = nil, r_digits = nil)` becomes `Faker::Number.decimal(l_digits: nil, r_digits: nil)`
95
+ - `Faker::Number.decimal_part(*args, &block)` becomes `Faker::Number.decimal_part(digits: nil)`
96
+ - `Faker::Number.hexadecimal(digits = nil)` becomes `Faker::Number.hexadecimal(digits: nil)`
97
+ - `Faker::Number.leading_zero_number(*args, &block)` becomes `Faker::Number.leading_zero_number(digits: nil)`
98
+ - `Faker::Number.negative(from = nil, to = nil)` becomes `Faker::Number.negative(from: nil, to: nil)`
99
+ - `Faker::Number.normal(mean = nil, standard_deviation = nil)` becomes `Faker::Number.normal(mean: nil, standard_deviation: nil)`
100
+ - `Faker::Number.number(digits = nil)` becomes `Faker::Number.number(digits: nil)`
101
+ - `Faker::Number.positive(from = nil, to = nil)` becomes `Faker::Number.positive(from: nil, to: nil)`
102
+ - `Faker::Number.within(range = nil)` becomes `Faker::Number.within(range: nil)`
103
+ - `Faker::PhoneNumber.extension(length = nil)` becomes `Faker::PhoneNumber.extension(length: nil)`
104
+ - `Faker::PhoneNumber.subscriber_number(length = nil)` becomes `Faker::PhoneNumber.subscriber_number(length: nil)`
105
+ - `Faker::Placeholdit.image(size = nil, format = nil, background_color = nil, text_color = nil, text = nil)` becomes `Faker::Placeholdit.image(size: nil, format: nil, background_color: nil, text_color: nil, text: nil)`
106
+ - `Faker::Relationship.familial(connection = nil)` becomes `Faker::Relationship.familial(connection: nil)`
107
+ - `Faker::Source.hello_world(lang = nil)` becomes `Faker::Source.hello_world(lang: nil)`
108
+ - `Faker::Source.print_1_to_10(lang = nil)` becomes `Faker::Source.print_1_to_10(lang: nil)`
109
+ - `Faker::String.random(length = nil)` becomes `Faker::String.random(length: nil)`
110
+ - `Faker::Stripe.ccv(card_type = nil)` becomes `Faker::Stripe.ccv(card_type: nil)`
111
+ - `Faker::Stripe.invalid_card(card_error = nil)` becomes `Faker::Stripe.invalid_card(card_error: nil)`
112
+ - `Faker::Stripe.valid_card(card_type = nil)` becomes `Faker::Stripe.valid_card(card_type: nil)`
113
+ - `Faker::Stripe.valid_token(card_type = nil)` becomes `Faker::Stripe.valid_token(card_type: nil)`
114
+ - `Faker::Time.backward(days = nil, period = nil, format = nil)` becomes `Faker::Time.backward(days: nil, period: nil, format: nil)`
115
+ - `Faker::Time.between(from, to, period = nil, format = nil)` becomes `Faker::Time.between(from:, to:, format: nil)`
116
+ - `Faker::Time.forward(days = nil, period = nil, format = nil)` becomes `Faker::Time.forward(days: nil, period: nil, format: nil)`
117
+ - `Faker::Types.complex_rb_hash(key_count = nil)` becomes `Faker::Types.complex_rb_hash(number: nil)`
118
+ - `Faker::Types.rb_array(len = nil)` becomes `Faker::Types.rb_array(len: nil)`
119
+ - `Faker::Types.rb_hash(key_count = nil, type = nil)` becomes `Faker::Types.rb_hash(number: nil, type: nil)`
120
+ - `Faker::Types.rb_integer(from = nil, to = nil)` becomes `Faker::Types.rb_integer(from: nil, to: nil)`
121
+ - `Faker::Types.rb_string(words = nil)` becomes `Faker::Types.rb_string(words: nil)`
122
+ - `Faker::Vehicle.kilometrage(min = nil, max = nil)` becomes `Faker::Vehicle.kilometrage(min: nil, max: nil)`
123
+ - `Faker::Vehicle.license_plate(state_abreviation = nil)` becomes `Faker::Vehicle.license_plate(state_abreviation: nil)`
124
+ - `Faker::Vehicle.mileage(min = nil, max = nil)` becomes `Faker::Vehicle.mileage(min: nil, max: nil)`
125
+ - `Faker::Vehicle.model(make_of_model = nil)` becomes `Faker::Vehicle.model(make_of_model: nil)`
126
+ - `Faker::WorldCup.group(group = nil)` becomes `Faker::WorldCup.group(group: nil)`
127
+ - `Faker::WorldCup.roster(country = nil, type = nil)` becomes `Faker::WorldCup.roster(country: nil, type: nil)`
128
+ - `Faker::Movies::StarWars.quote(character = nil)` becomes `Faker::Movies::StarWars.quote(character: nil)`
129
+ MARKDOWN
130
+
131
+ require "erb"
132
+ require "pathname"
133
+ require "fileutils"
134
+ require "open3"
135
+
136
+ class Array
137
+ def head_tail
138
+ head, *tail = *self
139
+ [head, tail]
140
+ end
141
+ end
142
+
143
+ class WrapperGenerator
144
+ LINE_REGEXP = /- `Faker::(?<class>[^\.]+)\.(?<before>[^`]+)` becomes `Faker::(?:[^\.]+)\.(?<after>[^`]+)`/.freeze
145
+ UNASSIGNED_KEYWORD_ARG_REGEXP = /(?<keyword>[^\(:]+):\s*(?<default_value>[^,\)]*)(?<terminator>[,\)])/m.freeze
146
+ OUTPUT_DIR_PATH = File.expand_path("../../lib/fake_faker", __FILE__).freeze
147
+ TEMPLATES_DIR_PATH = File.expand_path("../../templates", __FILE__).freeze
148
+
149
+ attr_reader :errors
150
+
151
+ def initialize(markdown)
152
+ @markdown = markdown
153
+ @mappings = {}
154
+ @klass_template = File.read(Pathname.new(TEMPLATES_DIR_PATH).join("klass.erb"))
155
+ @errors = []
156
+ end
157
+
158
+ def generate
159
+ extract_method_mappings
160
+
161
+ @mappings.each_pair do |klass, attributes|
162
+ generate_class(klass, attributes)
163
+ end
164
+
165
+ @errors.length == 0 ? true : false
166
+ end
167
+
168
+ private
169
+
170
+ def extract_method_mappings
171
+ @markdown.split("\n").each do |line|
172
+ m = LINE_REGEXP.match(line)
173
+ klass = m[:class]
174
+ @mappings[klass] = [] if @mappings[klass].nil?
175
+ @mappings[klass] <<
176
+ {
177
+ before: m[:before],
178
+ after: m[:after],
179
+ }
180
+ end
181
+ end
182
+
183
+ def generate_class(klass_path, methods)
184
+ modules = klass_path.split("::")
185
+ klass = modules.pop
186
+
187
+ # pass each arg for correspondig keyword arg
188
+
189
+ methods.each do |method|
190
+ method[:after].gsub!(UNASSIGNED_KEYWORD_ARG_REGEXP, '\k<keyword>: \k<keyword>\k<terminator>')
191
+ end
192
+
193
+ rb_text = ERB.new(@klass_template).result(binding)
194
+
195
+ # `downcase` should be replaced by something like `underscore` in ActiveSupport
196
+ dir = Pathname.new(OUTPUT_DIR_PATH).join(*modules.map(&:downcase))
197
+
198
+ FileUtils.mkdir_p(dir)
199
+
200
+ file_path = dir.join("#{klass.downcase}.rb")
201
+ File.write(file_path, rb_text)
202
+
203
+ _, stderr, _ = Open3.capture3("rufo", file_path.to_s)
204
+
205
+ if stderr.length > 0
206
+ @errors << "Failed to generate valid Ruby code. #{file_path} has syntax errors. <#{stderr}>"
207
+ end
208
+ end
209
+ end
210
+
211
+ generator = WrapperGenerator.new(md)
212
+
213
+ if generator.generate
214
+ puts "Succeed to generate wrapper classes witout errors"
215
+ else
216
+ puts "There some errors during the generation."
217
+ generator.errors.each { |error| puts error }
218
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "fake_faker/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fake_faker"
7
+ spec.version = FakeFaker::VERSION
8
+ spec.authors = ["Masatoshi Iwasaki"]
9
+ spec.email = ["mstshiwasaki@gmail.com"]
10
+
11
+ spec.summary = %q{A Faker V2 wrapper to provide Faker V1 interface.}
12
+ spec.description = %q{A Faker V2 wrapper to provide Faker V1 interface.}
13
+ spec.homepage = "https://github.com/masa-iwasaki/fake_faker"
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = "https://github.com/masa-iwasaki/fake_faker"
17
+ spec.metadata["changelog_uri"] = "https://github.com/masa-iwasaki/fake_faker/CHANGELOG.md"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_development_dependency "bundler", "~> 2.0"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "minitest", "~> 5.0"
31
+ spec.add_development_dependency "rufo"
32
+
33
+ spec.add_dependency "faker", ">= 2.0"
34
+ end
@@ -0,0 +1,46 @@
1
+ require "faker"
2
+
3
+ require "fake_faker/version"
4
+
5
+ require "fake_faker/address"
6
+ require "fake_faker/alphanumeric"
7
+ require "fake_faker/avatar"
8
+ require "fake_faker/bank"
9
+ require "fake_faker/books"
10
+ require "fake_faker/chilerut"
11
+ require "fake_faker/code"
12
+ require "fake_faker/commerce"
13
+ require "fake_faker/company"
14
+ require "fake_faker/cryptocoin"
15
+ require "fake_faker/date"
16
+ require "fake_faker/demographic"
17
+ require "fake_faker/file"
18
+ require "fake_faker/fillmurray"
19
+ require "fake_faker/finance"
20
+ require "fake_faker/hipster"
21
+ require "fake_faker/internet"
22
+ require "fake_faker/invoice"
23
+ require "fake_faker/json"
24
+ require "fake_faker/lorem"
25
+ require "fake_faker/loremflickr"
26
+ require "fake_faker/lorempixel"
27
+ require "fake_faker/markdown"
28
+ require "fake_faker/measurement"
29
+ require "fake_faker/movies"
30
+ require "fake_faker/name"
31
+ require "fake_faker/nationalhealthservice"
32
+ require "fake_faker/number"
33
+ require "fake_faker/phonenumber"
34
+ require "fake_faker/placeholdit"
35
+ require "fake_faker/relationship"
36
+ require "fake_faker/source"
37
+ require "fake_faker/string"
38
+ require "fake_faker/stripe"
39
+ require "fake_faker/time"
40
+ require "fake_faker/types"
41
+ require "fake_faker/vehicle"
42
+ require "fake_faker/version"
43
+ require "fake_faker/worldcup"
44
+
45
+ module FakeFaker
46
+ end