rrandom 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +22 -0
- data/README.md +59 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rrandom.rb +72 -0
- data/lib/rrandom/source/female_first_names.txt +100 -0
- data/lib/rrandom/source/last_names.txt +100 -0
- data/lib/rrandom/source/male_first_names.txt +100 -0
- data/lib/rrandom/version.rb +3 -0
- data/rrandom.gemspec +27 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ccdb0e1200a6fb2dbabfbc1936343b257e8ab11651ffb0b86b87d6a2606e5670
|
4
|
+
data.tar.gz: 708144abc2e4b50f6379d194575a4409b8fa139a915be3148c8e84c66a2ca3e3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 355dd6517dea508487eb60af3da132e334121586d13dcec1164d24cc51edf5810bfba83786cd5f959c95e76007485492e50571d9ddbb98022879b723492e3e05
|
7
|
+
data.tar.gz: ea6e02bc6378f517b82da7a4c9153507e72516b4ca3a6cbc8c08b2ca97e59f95b0c49f40d77b29250f07afd392a2fd12fc695162a28e15aa7855e62608b37231
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rrandom (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
minitest (5.11.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
|
12
|
+
PLATFORMS
|
13
|
+
ruby
|
14
|
+
|
15
|
+
DEPENDENCIES
|
16
|
+
bundler (~> 1.17)
|
17
|
+
minitest (~> 5.0)
|
18
|
+
rake (~> 10.0)
|
19
|
+
rrandom!
|
20
|
+
|
21
|
+
BUNDLED WITH
|
22
|
+
1.17.2
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# RRandom
|
2
|
+
|
3
|
+
Do you want to generate some random data? You've come to the right place.
|
4
|
+
|
5
|
+
This is an alternative to the faker gem which is:
|
6
|
+
|
7
|
+
1. Simpler. Way smaller API surface, looking at the faker API docs gives me
|
8
|
+
choice anxiety.
|
9
|
+
2. Consistent. Want to generate names and email addresses that match for the
|
10
|
+
same person? Yeah, me too.
|
11
|
+
3. Small. Doesn't load anything into memory unless you're actually using it.
|
12
|
+
Really simple code base.
|
13
|
+
4. Unfinished. I just started building this thing to fit a specific use case
|
14
|
+
where I needed it, it's not finished. There are way more things it could
|
15
|
+
generate than are currently provided. I might add those later, I might not.
|
16
|
+
Use this if you find it useful.
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
Add this line to your application's Gemfile:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem 'rrandom'
|
24
|
+
```
|
25
|
+
|
26
|
+
And then execute:
|
27
|
+
|
28
|
+
$ bundle
|
29
|
+
|
30
|
+
Or install it yourself as:
|
31
|
+
|
32
|
+
$ gem install rrandom
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
|
36
|
+
``` ruby
|
37
|
+
random = RRandom.new
|
38
|
+
random.first_name
|
39
|
+
random.last_name
|
40
|
+
random.name
|
41
|
+
random.email
|
42
|
+
random.gender
|
43
|
+
```
|
44
|
+
|
45
|
+
## A note on gender
|
46
|
+
|
47
|
+
This gem currently returns a binary male/female value for the gender option. I
|
48
|
+
personally do not believe that gender is binary and I acknowledge, accept and
|
49
|
+
respect those who identify as a different gender than the traditional
|
50
|
+
male/female distinction. The reason to stick to the "traditional" binary
|
51
|
+
distinction for now is for simplicity and maximum interoperability with legacy
|
52
|
+
systems. In the future I would like to implement a more comprehensive system
|
53
|
+
for dealing with gender, however I myself am not sure on what the best and most
|
54
|
+
respectful way of achieving this is, so I'd definitely appreciate any help on
|
55
|
+
this front. If you have any input on this front, please open an issue.
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jnicklas/rrandom
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rrandom"
|
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__)
|
data/bin/setup
ADDED
data/lib/rrandom.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "rrandom/version"
|
3
|
+
|
4
|
+
class RRandom
|
5
|
+
class Loader
|
6
|
+
def initialize
|
7
|
+
@mutex = Mutex.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def get(name)
|
11
|
+
ivar_name = :"@_list_#{name}"
|
12
|
+
|
13
|
+
return instance_variable_get(ivar_name) if instance_variable_get(ivar_name)
|
14
|
+
|
15
|
+
@mutex.synchronize do
|
16
|
+
# do it again, in case of race condition
|
17
|
+
return instance_variable_get(ivar_name) if instance_variable_get(ivar_name)
|
18
|
+
|
19
|
+
list = load_list(name)
|
20
|
+
instance_variable_set(ivar_name, list)
|
21
|
+
list
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def load_list(name)
|
26
|
+
File.read(File.expand_path("rrandom/source/#{name}.txt", __dir__)).chomp.lines
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Error < StandardError; end
|
31
|
+
|
32
|
+
class << self
|
33
|
+
attr_accessor :loader
|
34
|
+
end
|
35
|
+
|
36
|
+
def initialize(random_domain: false)
|
37
|
+
@use_random_domain = random_domain
|
38
|
+
end
|
39
|
+
|
40
|
+
def use_random_domain?
|
41
|
+
@use_random_domain
|
42
|
+
end
|
43
|
+
|
44
|
+
def gender
|
45
|
+
@gender ||= ["male", "female"].sample
|
46
|
+
end
|
47
|
+
|
48
|
+
def first_name
|
49
|
+
@first_name ||= case gender
|
50
|
+
when "male" then RRandom.loader.get(:male_first_names).sample.chomp
|
51
|
+
when "female" then RRandom.loader.get(:female_first_names).sample.chomp
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def last_name
|
56
|
+
@last_name ||= RRandom.loader.get(:last_names).sample.chomp
|
57
|
+
end
|
58
|
+
|
59
|
+
def name
|
60
|
+
"#{first_name} #{last_name}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def email
|
64
|
+
"#{first_name.downcase}.#{last_name.downcase}@#{domain}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def domain
|
68
|
+
"example.com"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
RRandom.loader = RRandom::Loader.new
|
@@ -0,0 +1,100 @@
|
|
1
|
+
Mary
|
2
|
+
Patricia
|
3
|
+
Jennifer
|
4
|
+
Linda
|
5
|
+
Elizabeth
|
6
|
+
Barbara
|
7
|
+
Susan
|
8
|
+
Jessica
|
9
|
+
Sarah
|
10
|
+
Karen
|
11
|
+
Nancy
|
12
|
+
Margaret
|
13
|
+
Lisa
|
14
|
+
Betty
|
15
|
+
Dorothy
|
16
|
+
Sandra
|
17
|
+
Ashley
|
18
|
+
Kimberly
|
19
|
+
Donna
|
20
|
+
Emily
|
21
|
+
Michelle
|
22
|
+
Carol
|
23
|
+
Amanda
|
24
|
+
Melissa
|
25
|
+
Deborah
|
26
|
+
Stephanie
|
27
|
+
Rebecca
|
28
|
+
Laura
|
29
|
+
Sharon
|
30
|
+
Cynthia
|
31
|
+
Kathleen
|
32
|
+
Helen
|
33
|
+
Amy
|
34
|
+
Shirley
|
35
|
+
Angela
|
36
|
+
Anna
|
37
|
+
Brenda
|
38
|
+
Pamela
|
39
|
+
Nicole
|
40
|
+
Ruth
|
41
|
+
Katherine
|
42
|
+
Samantha
|
43
|
+
Christine
|
44
|
+
Emma
|
45
|
+
Catherine
|
46
|
+
Debra
|
47
|
+
Virginia
|
48
|
+
Rachel
|
49
|
+
Carolyn
|
50
|
+
Janet
|
51
|
+
Maria
|
52
|
+
Heather
|
53
|
+
Diane
|
54
|
+
Julie
|
55
|
+
Joyce
|
56
|
+
Victoria
|
57
|
+
Kelly
|
58
|
+
Christina
|
59
|
+
Joan
|
60
|
+
Evelyn
|
61
|
+
Lauren
|
62
|
+
Judith
|
63
|
+
Olivia
|
64
|
+
Frances
|
65
|
+
Martha
|
66
|
+
Cheryl
|
67
|
+
Megan
|
68
|
+
Andrea
|
69
|
+
Hannah
|
70
|
+
Jacqueline
|
71
|
+
Ann
|
72
|
+
Jean
|
73
|
+
Alice
|
74
|
+
Kathryn
|
75
|
+
Gloria
|
76
|
+
Teresa
|
77
|
+
Doris
|
78
|
+
Sara
|
79
|
+
Janice
|
80
|
+
Julia
|
81
|
+
Marie
|
82
|
+
Madison
|
83
|
+
Grace
|
84
|
+
Judy
|
85
|
+
Theresa
|
86
|
+
Beverly
|
87
|
+
Denise
|
88
|
+
Marilyn
|
89
|
+
Amber
|
90
|
+
Danielle
|
91
|
+
Abigail
|
92
|
+
Brittany
|
93
|
+
Rose
|
94
|
+
Diana
|
95
|
+
Natalie
|
96
|
+
Sophia
|
97
|
+
Alexis
|
98
|
+
Lori
|
99
|
+
Kayla
|
100
|
+
Jane
|
@@ -0,0 +1,100 @@
|
|
1
|
+
Smith
|
2
|
+
Johnson
|
3
|
+
Williams
|
4
|
+
Jones
|
5
|
+
Brown
|
6
|
+
Davis
|
7
|
+
Miller
|
8
|
+
Wilson
|
9
|
+
Moore
|
10
|
+
Taylor
|
11
|
+
Anderson
|
12
|
+
Thomas
|
13
|
+
Jackson
|
14
|
+
White
|
15
|
+
Harris
|
16
|
+
Martin
|
17
|
+
Thompson
|
18
|
+
Garcia
|
19
|
+
Martinez
|
20
|
+
Robinson
|
21
|
+
Clark
|
22
|
+
Rodriguez
|
23
|
+
Lewis
|
24
|
+
Lee
|
25
|
+
Walker
|
26
|
+
Hall
|
27
|
+
Allen
|
28
|
+
Young
|
29
|
+
Hernandez
|
30
|
+
King
|
31
|
+
Wright
|
32
|
+
Lopez
|
33
|
+
Hill
|
34
|
+
Scott
|
35
|
+
Green
|
36
|
+
Adams
|
37
|
+
Baker
|
38
|
+
Gonzalez
|
39
|
+
Nelson
|
40
|
+
Carter
|
41
|
+
Mitchell
|
42
|
+
Perez
|
43
|
+
Roberts
|
44
|
+
Turner
|
45
|
+
Phillips
|
46
|
+
Campbell
|
47
|
+
Parker
|
48
|
+
Evans
|
49
|
+
Edwards
|
50
|
+
Collins
|
51
|
+
Stewart
|
52
|
+
Sanchez
|
53
|
+
Morris
|
54
|
+
Rogers
|
55
|
+
Reed
|
56
|
+
Cook
|
57
|
+
Morgan
|
58
|
+
Bell
|
59
|
+
Murphy
|
60
|
+
Bailey
|
61
|
+
Rivera
|
62
|
+
Cooper
|
63
|
+
Richardson
|
64
|
+
Cox
|
65
|
+
Howard
|
66
|
+
Ward
|
67
|
+
Torres
|
68
|
+
Peterson
|
69
|
+
Gray
|
70
|
+
Ramirez
|
71
|
+
James
|
72
|
+
Watson
|
73
|
+
Brooks
|
74
|
+
Kelly
|
75
|
+
Sanders
|
76
|
+
Price
|
77
|
+
Bennett
|
78
|
+
Wood
|
79
|
+
Barnes
|
80
|
+
Ross
|
81
|
+
Henderson
|
82
|
+
Coleman
|
83
|
+
Jenkins
|
84
|
+
Perry
|
85
|
+
Powell
|
86
|
+
Long
|
87
|
+
Patterson
|
88
|
+
Hughes
|
89
|
+
Flores
|
90
|
+
Washington
|
91
|
+
Butler
|
92
|
+
Simmons
|
93
|
+
Foster
|
94
|
+
Gonzales
|
95
|
+
Bryant
|
96
|
+
Alexander
|
97
|
+
Russell
|
98
|
+
Griffin
|
99
|
+
Diaz
|
100
|
+
Hayes
|
@@ -0,0 +1,100 @@
|
|
1
|
+
James
|
2
|
+
John
|
3
|
+
Robert
|
4
|
+
Michael
|
5
|
+
William
|
6
|
+
David
|
7
|
+
Richard
|
8
|
+
Joseph
|
9
|
+
Thomas
|
10
|
+
Charles
|
11
|
+
Christopher
|
12
|
+
Daniel
|
13
|
+
Matthew
|
14
|
+
Anthony
|
15
|
+
Donald
|
16
|
+
Mark
|
17
|
+
Paul
|
18
|
+
Steven
|
19
|
+
Andrew
|
20
|
+
Kenneth
|
21
|
+
Joshua
|
22
|
+
George
|
23
|
+
Kevin
|
24
|
+
Brian
|
25
|
+
Edward
|
26
|
+
Ronald
|
27
|
+
Timothy
|
28
|
+
Jason
|
29
|
+
Jeffrey
|
30
|
+
Ryan
|
31
|
+
Jacob
|
32
|
+
Gary
|
33
|
+
Nicholas
|
34
|
+
Eric
|
35
|
+
Stephen
|
36
|
+
Jonathan
|
37
|
+
Larry
|
38
|
+
Justin
|
39
|
+
Scott
|
40
|
+
Brandon
|
41
|
+
Frank
|
42
|
+
Benjamin
|
43
|
+
Gregory
|
44
|
+
Samuel
|
45
|
+
Raymond
|
46
|
+
Patrick
|
47
|
+
Alexander
|
48
|
+
Jack
|
49
|
+
Dennis
|
50
|
+
Jerry
|
51
|
+
Tyler
|
52
|
+
Aaron
|
53
|
+
Jose
|
54
|
+
Henry
|
55
|
+
Douglas
|
56
|
+
Adam
|
57
|
+
Peter
|
58
|
+
Nathan
|
59
|
+
Zachary
|
60
|
+
Walter
|
61
|
+
Kyle
|
62
|
+
Harold
|
63
|
+
Carl
|
64
|
+
Jeremy
|
65
|
+
Keith
|
66
|
+
Roger
|
67
|
+
Gerald
|
68
|
+
Ethan
|
69
|
+
Arthur
|
70
|
+
Terry
|
71
|
+
Christian
|
72
|
+
Sean
|
73
|
+
Lawrence
|
74
|
+
Austin
|
75
|
+
Joe
|
76
|
+
Noah
|
77
|
+
Jesse
|
78
|
+
Albert
|
79
|
+
Bryan
|
80
|
+
Billy
|
81
|
+
Bruce
|
82
|
+
Willie
|
83
|
+
Jordan
|
84
|
+
Dylan
|
85
|
+
Alan
|
86
|
+
Ralph
|
87
|
+
Gabriel
|
88
|
+
Roy
|
89
|
+
Juan
|
90
|
+
Wayne
|
91
|
+
Eugene
|
92
|
+
Logan
|
93
|
+
Randy
|
94
|
+
Louis
|
95
|
+
Russell
|
96
|
+
Vincent
|
97
|
+
Philip
|
98
|
+
Bobby
|
99
|
+
Johnny
|
100
|
+
Bradley
|
data/rrandom.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "rrandom/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rrandom"
|
8
|
+
spec.version = RRandom::VERSION
|
9
|
+
spec.authors = ["Jonas Nicklas"]
|
10
|
+
spec.email = ["jonas@jnicklas.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Generate random data}
|
13
|
+
spec.homepage = "https://github.com/jnicklas/rrandom"
|
14
|
+
|
15
|
+
# Specify which files should be added to the gem when it is released.
|
16
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rrandom
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonas Nicklas
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- jonas@jnicklas.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- lib/rrandom.rb
|
71
|
+
- lib/rrandom/source/female_first_names.txt
|
72
|
+
- lib/rrandom/source/last_names.txt
|
73
|
+
- lib/rrandom/source/male_first_names.txt
|
74
|
+
- lib/rrandom/version.rb
|
75
|
+
- rrandom.gemspec
|
76
|
+
homepage: https://github.com/jnicklas/rrandom
|
77
|
+
licenses: []
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubygems_version: 3.0.3
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Generate random data
|
98
|
+
test_files: []
|