faker_extensions 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +70 -0
- data/Rakefile +2 -0
- data/faker_extensions.gemspec +23 -0
- data/lib/faker_extensions.rb +6 -0
- data/lib/faker_extensions/faker.rb +41 -0
- data/lib/faker_extensions/version.rb +3 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f76cd5a9d9e7e17f90587b771663f48d1277366d
|
4
|
+
data.tar.gz: 01dca4dab18d9dc1a22fc85e757a69881fe9cca8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 830dc65efcd26daafb0515d891e63a405a0a66ddae5aaaba84f37ad1fbb4325230930782266c827db3019f9158432595b9f5e75f702aea12f4d81c3e60106be6
|
7
|
+
data.tar.gz: 11cee2941341ed2c4112fe448f797e470ba5899792d06c4fb095416b83c1663fb843b0ec39fb941e706588685b1904d5b5cd8f83bdc029fbd8bd5099602f1f70
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.idea
|
24
|
+
.idea/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Mike Urban
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
FakerExtensions
|
2
|
+
===============
|
3
|
+
Handy extensions to enhance the capabilities of the [Faker Gem](https://github.com/stympy/faker)
|
4
|
+
|
5
|
+
It comes in very handy for generating realistic dummy or seed data in large quantities for testing.
|
6
|
+
|
7
|
+
Installing
|
8
|
+
----------
|
9
|
+
```bash
|
10
|
+
gem install faker_extensions
|
11
|
+
```
|
12
|
+
|
13
|
+
##Usage
|
14
|
+
-----
|
15
|
+
```ruby
|
16
|
+
|
17
|
+
# => returns true or false always a 50/50 proposition
|
18
|
+
Faker::coin_flip
|
19
|
+
|
20
|
+
# => returns true or false always a 50/50 proposition
|
21
|
+
Faker::random_paragraphs(p_max_paragraphs, p_paragraph_separator, p_allow_nil)
|
22
|
+
|
23
|
+
Faker::random_paragraphs(5, "\n", true) #generate either none or up to 5 paragraphs separated by a newline
|
24
|
+
Faker::random_paragraphs(10, " ", false) #generate 1 to 10 paragraphs separated by 2 spaces
|
25
|
+
|
26
|
+
# => returns true most of the time..between 51 and 99, default - 75% true
|
27
|
+
Faker::mostly_true(p_pct = 75)
|
28
|
+
|
29
|
+
Faker::mostly_true #return true approximately 75% (randomly) of the time
|
30
|
+
Faker::mostly_true(99) #return true approximately 99% (randomly) of the time
|
31
|
+
|
32
|
+
# => returns false most of the time..between 51 and 99, default - 75% true
|
33
|
+
Faker::mostly_false(p_pct = 75)
|
34
|
+
|
35
|
+
Faker::mostly_false #return false approximately 75% (randomly) of the time
|
36
|
+
Faker::mostly_false(99) #return false approximately 99% (randomly) of the time
|
37
|
+
|
38
|
+
|
39
|
+
# => returns the male parameter 50% of the time and the female fo% of the time (approximately and randomly)
|
40
|
+
Faker::gender(p_male = 'male', p_female = 'female')
|
41
|
+
|
42
|
+
Faker:gender #randomly select between male and female
|
43
|
+
Faker:gender('boy', 'girl') #randomly select between boy and girl
|
44
|
+
Faker:gender('grandma', 'grandpa') #randomly select between grandma and grandpa
|
45
|
+
Faker:gender(I18n.t('gender.male'), I18n.t('gender.female')) #internationalization way to select gender
|
46
|
+
#Note Internationalization must be handled by calling method, fake does nothing more in this case than choose between two values
|
47
|
+
|
48
|
+
# => returns a randomly selected integer between p_from and p_to
|
49
|
+
Faker::integer_range(p_from, p_to)
|
50
|
+
|
51
|
+
Faker::integer_range(p_from, p_to) #get an integer between one and 5
|
52
|
+
|
53
|
+
# => returns a randomly selected date between p_from and p_to
|
54
|
+
Faker::date_range(p_from, p_to)
|
55
|
+
|
56
|
+
Faker::date_range(Date.today - 1.year, Date.today) #get an date from a year ago until today
|
57
|
+
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
Contributing
|
62
|
+
------------
|
63
|
+
|
64
|
+
Contact
|
65
|
+
-------
|
66
|
+
Comments and feedback are welcome. Send an email to Mike Urban via mike@marskalgroup.com
|
67
|
+
|
68
|
+
License
|
69
|
+
-------
|
70
|
+
This code is free to use under the terms of the MIT license.
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'faker_extensions/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "faker_extensions"
|
8
|
+
spec.version = FakerExtensions::VERSION
|
9
|
+
spec.authors = ["Mike Urban"]
|
10
|
+
spec.email = ["mike@marskalgroup.com"]
|
11
|
+
spec.summary = %q{This gem adds a few extra handy methods to the Faker gem}
|
12
|
+
spec.description = %q{It comes in very handy for generating realistic dummy or seed data in large quantities for testing.}
|
13
|
+
spec.homepage = 'https://github.com/MarskalGroup/faker_extensions'
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.add_development_dependency 'Faker', '~> 1.4'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0")
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake", "~> 0"
|
23
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#Added by Mike Urban to enhance data population abilities provided by the faker module 10/2014
|
2
|
+
module Faker
|
3
|
+
|
4
|
+
def self.coin_flip
|
5
|
+
[true,false].shuffle.first #rand select for boolean, essentially a coin flip
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.random_paragraphs(p_max_paragraphs, p_paragraph_separator, p_allow_nil)
|
9
|
+
l_text = ''
|
10
|
+
l_start = p_allow_nil ? 0 : 1
|
11
|
+
l_num_paragraphs = (l_start..p_max_paragraphs).to_a.shuffle.first
|
12
|
+
l_num_paragraphs.times do |ctr|
|
13
|
+
l_text += "#{p_paragraph_separator}" if ctr > 0
|
14
|
+
l_text += Faker::Lorem.paragraph
|
15
|
+
end
|
16
|
+
l_text.blank? ? nil : l_text
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.mostly_true(p_pct=75)
|
20
|
+
#no more than 99%, no less than 51% can be mostly true
|
21
|
+
p_num_true = [[p_pct.to_i, 99].min, 51].max
|
22
|
+
(1..100).to_a.shuffle.first <= p_num_true
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.mostly_false(p_pct=75)
|
26
|
+
!mostly_true(p_pct)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.gender(p_male = 'male', p_female = 'female')
|
30
|
+
l_gender = coin_flip ? p_male : p_female #genders need to be passed if different than english or you want boy/girl for example
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.integer_range(p_from, p_to)
|
34
|
+
(p_from..p_to).to_a.shuffle.first
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.date_range(p_from, p_to)
|
38
|
+
(p_from..p_to).to_a.shuffle.first
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: faker_extensions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Urban
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: Faker
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: It comes in very handy for generating realistic dummy or seed data in
|
56
|
+
large quantities for testing.
|
57
|
+
email:
|
58
|
+
- mike@marskalgroup.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- faker_extensions.gemspec
|
69
|
+
- lib/faker_extensions.rb
|
70
|
+
- lib/faker_extensions/faker.rb
|
71
|
+
- lib/faker_extensions/version.rb
|
72
|
+
homepage: https://github.com/MarskalGroup/faker_extensions
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.4.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: This gem adds a few extra handy methods to the Faker gem
|
96
|
+
test_files: []
|