Seedr 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +9 -0
- data/README.md +79 -0
- data/Rakefile +1 -0
- data/Seedr.gemspec +21 -0
- data/img/logo.png +0 -0
- data/lib/Seedr.rb +152 -0
- data/lib/Seedr/version.rb +3 -0
- data/test.rb +37 -0
- metadata +71 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Copyright (c) 2013 Ashe Avenue. Created by Tim Boisvert and Rob Farrell
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
![Seedr](/img/logo.png)
|
2
|
+
|
3
|
+
Seedr is a non-expansive, simple alternative to Forgery, Faker, FFaker, and the like. It aims to provide a single namespace with a limited set of options, focusing instead on the most basic of dummy data.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem from the command line:
|
8
|
+
|
9
|
+
$ sudo gem install Seedr
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
### Rails
|
14
|
+
|
15
|
+
Add the following to your Gemfile:
|
16
|
+
|
17
|
+
gem 'Seedr'
|
18
|
+
|
19
|
+
Within your seeds.rb file, any of Seedr's data elements can be called and a random result will be returned. Example:
|
20
|
+
|
21
|
+
10.times do
|
22
|
+
p = Profile.new
|
23
|
+
p.first_name = Seedr.first_name
|
24
|
+
p.last_name = Seedr.last_name
|
25
|
+
p.address_line_1 = Seedr.address_line_1
|
26
|
+
p.email = Seedr.email
|
27
|
+
p.save!
|
28
|
+
end
|
29
|
+
|
30
|
+
### Ruby
|
31
|
+
|
32
|
+
Seedr can naturally be used outside of a Rails context. Example:
|
33
|
+
|
34
|
+
require 'Seedr'
|
35
|
+
name = Seedr.full_name
|
36
|
+
puts name
|
37
|
+
|
38
|
+
## API
|
39
|
+
|
40
|
+
### Generic Randoms
|
41
|
+
|
42
|
+
Seedr.random_string(length=1)
|
43
|
+
Seedr.random_integer(length=1)
|
44
|
+
|
45
|
+
### Dates/Times
|
46
|
+
|
47
|
+
Seedr.date
|
48
|
+
Seedr.datetime
|
49
|
+
|
50
|
+
### Profile
|
51
|
+
|
52
|
+
Seedr.first_name
|
53
|
+
Seedr.last_name
|
54
|
+
Seedr.middle_initial
|
55
|
+
Seedr.username
|
56
|
+
Seedr.full_name
|
57
|
+
Seedr.email
|
58
|
+
Seedr.phone_number(separator='')
|
59
|
+
Seedr.company_name
|
60
|
+
Seedr.address_line_1
|
61
|
+
Seedr.address_line_2
|
62
|
+
Seedr.city
|
63
|
+
Seedr.state(abbreviation=FALSE)
|
64
|
+
Seedr.province(abbreviation=FALSE)
|
65
|
+
Seedr.country(abbreviation=FALSE)
|
66
|
+
|
67
|
+
### Editorial
|
68
|
+
|
69
|
+
Seedr.category
|
70
|
+
Seedr.article_type
|
71
|
+
Seedr.series
|
72
|
+
Seedr.title
|
73
|
+
Seedr.body
|
74
|
+
|
75
|
+
##Finally...
|
76
|
+
|
77
|
+
© 2013 <a href="http://www.asheavenue.com">Ashe Avenue</a>. Created by <a href="http://twitter.com/timboisvert">Tim Boisvert</a> and Rob Farrell.
|
78
|
+
<br />
|
79
|
+
Seedr is released under the <a href="http://opensource.org/licenses/MIT">MIT license</a>.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/Seedr.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'Seedr/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "Seedr"
|
8
|
+
gem.version = Seedr::VERSION
|
9
|
+
gem.authors = ["Ashe Avenue -- Tim Boisvert and Rob Farrell"]
|
10
|
+
gem.email = ["tboisvert@asheavenue.com"]
|
11
|
+
gem.description = 'A friendly Rails seeding assistant'
|
12
|
+
gem.summary = 'A friendly Rails seeding assistant'
|
13
|
+
gem.homepage = 'http://github.com/AsheAvenue/Seedr'
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency("titleize")
|
21
|
+
end
|
data/img/logo.png
ADDED
Binary file
|
data/lib/Seedr.rb
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
require "Seedr/version"
|
2
|
+
require "titleize"
|
3
|
+
require 'time'
|
4
|
+
|
5
|
+
module Seedr
|
6
|
+
|
7
|
+
# RANDOMS
|
8
|
+
|
9
|
+
def self.random_string(length=1)
|
10
|
+
range = [*'a'..'z', *'A'..'Z']
|
11
|
+
Array.new(length){range.sample}.join
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.random_integer(length=1)
|
15
|
+
range = [*0..9]
|
16
|
+
Array.new(length){range.sample}.join
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.random_word
|
20
|
+
['sed', 'posuere', 'consectetur', 'est', 'at' 'lobortis', 'lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing' 'elit', 'nullam', 'id', 'dolor', 'id', 'nibh', 'ultricies', 'vehicula', 'ut', 'id', 'elit', 'maecenas', 'sed', 'diam', 'eget', 'risus', 'varius', 'blandit', 'sit', 'amet', 'non', 'magna'].sample
|
21
|
+
end
|
22
|
+
|
23
|
+
#DATES/TIMES
|
24
|
+
|
25
|
+
def self.date(start=0.0,stop=Time.now)
|
26
|
+
Time.at(start + rand * (stop.to_f - start.to_f)).to_date
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.datetime(start=0.0,stop=Time.now)
|
30
|
+
Time.at(start + rand * (stop.to_f - start.to_f)).to_datetime
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
# PROFILE
|
35
|
+
|
36
|
+
def self.first_name
|
37
|
+
['Joe','Rob','Tim','John','Matt','Gob','Ricky','Bubbles','Walt','Sally','Natalie','Jane','Oscar','Lupe','Benjamin','Lindsay'].sample
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.last_name
|
41
|
+
['Bluth','Morgan','Pinkman','Skywalker','Lahee','Griswald','Farakahn','Greenpoint','Seinfeld','Simpson','Briggs','Baxter'].sample
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.middle_initial
|
45
|
+
[*'A'..'Z'].sample
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.username
|
49
|
+
['bewbewbew002','nicCage80085','murphdawg23','captain0bv3us','username123','jesuslovesme','grannyPants419','art_vandelay','theRealMacafee','iLoveScreech1492','thugLife187'].sample
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.full_name
|
53
|
+
"#{self.first_name} #{self.middle_initial}. #{self.last_name}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.email
|
57
|
+
username = ['bob', 'horace', 'jimmy', 'info', 'noreply', 'stuff', 'juan', 'daisuke', 'veronica', 'marge', 'inquiries']
|
58
|
+
host = ['gmail', 'hotmail', 'yahoo', 'nytimes', 'runners', 'hotdating', 'cnn', 'maryjanetimes', 'nyc', 'navy']
|
59
|
+
tld = ['com', 'net', 'io', 'gov', 'mil', 'co.uk', 'es']
|
60
|
+
"#{username.sample}@#{host.sample}.#{tld.sample}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.phone_number(separator='')
|
64
|
+
"#{self.random_integer(3)}#{separator}#{self.random_integer(3)}#{separator}#{self.random_integer(4)}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.company_name
|
68
|
+
word1 = ['ACME', 'American', 'International', 'Blue', "Dad's", 'Stargazer', 'East River', 'Nissan', 'Red', 'Standard']
|
69
|
+
word2 = ['Computer', 'Plumbing', 'Construction', 'Welding', 'Mercantile', 'Design', 'Refrigeration', 'Shipping', 'Culinary', 'Dry Goods']
|
70
|
+
word3 = [' Company', ' Society', ' Association', ' Union', ' Supply', '', '', '', '', '']
|
71
|
+
word4 = [' of North Carolina', ', Inc.', ', LLC', '', '', '', '', '', '']
|
72
|
+
"#{word1.sample} #{word2.sample}#{word3.sample}#{word4.sample}"
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.address_line_1
|
76
|
+
direction = ['N.', 'S.', 'E.', 'W.', 'North', 'South', 'East', 'West']
|
77
|
+
street = ['First', 'Third', 'Franklin', 'Lakeland', 'Hillsborough', 'Pennsylvania', 'Cardigan', 'High', 'China Lake', 'Columbia']
|
78
|
+
type = ['St.', 'Ave.', 'Blvd.', 'Rd.', 'Way', 'Court']
|
79
|
+
"#{Random.rand(1000)} #{direction.sample} #{street.sample} #{type.sample}"
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.address_line_2
|
83
|
+
["Apt. #{Random.rand(10) + 1}#{Array('A'..'G').sample}", "Suite #{Random.rand(90) + 1}", "#{Random.rand(10) + 4}th Floor"].sample
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.city
|
87
|
+
['Lincoln', 'Orange', 'Ridgecrest', 'Springville', 'Laserville', 'Oak Ridge', 'Nashville', 'Los Gatos', 'Shreveport'].sample
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.state(abbreviation=FALSE)
|
91
|
+
if abbreviation
|
92
|
+
['CA', 'NC', 'OK', 'NY', 'UT', 'MT', 'OR', 'AZ', 'SC', 'KY', 'WV', 'VA', 'ME', 'FL'].sample
|
93
|
+
else
|
94
|
+
['California', 'North Carolina', 'Oklahoma', 'New York', 'Utah', 'Montana', 'Oregon', 'Arizona', 'South Carolina', 'Kentucky', 'West Virginia', 'Virginia', 'Maine', 'Florida'].sample
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.province(abbreviation=FALSE)
|
99
|
+
if abbreviation
|
100
|
+
['AB', 'SK', 'BC', 'NB', 'ON', 'QC', 'NS'].sample
|
101
|
+
else
|
102
|
+
['Alberta', 'Saskatchewan', 'British Columbia', 'New Brunswick', 'Ontario', 'Quebec', 'Nova Scotia'].sample
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.country(abbreviation=FALSE)
|
107
|
+
if abbreviation
|
108
|
+
['US', 'MX', 'CA', 'FR', 'ES', 'JP', 'SG', 'NM'].sample
|
109
|
+
else
|
110
|
+
['United States', 'Mexico', 'Canada', 'France', 'Spain', 'Japan', 'Singapore', 'Namibia'].sample
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
# EDITORIAL
|
116
|
+
|
117
|
+
def self.category
|
118
|
+
['News', 'Entertainment', 'Sports', 'Music', 'Technology', 'World', 'Arts', 'Real Estate', 'Style', 'Business', 'Finance', 'Classifieds', 'Travel', 'Food'].sample
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.article_type
|
122
|
+
['Text', 'Video', 'Gallery', 'Poll'].sample
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.series
|
126
|
+
['101', 'Grow', 'Art Talk', 'Fringes', 'Noisey Raps'].sample
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.title
|
130
|
+
words = ['sed', 'posuere', 'consectetur', 'est', 'at' 'lobortis', 'lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing' 'elit', 'nullam', 'id', 'dolor', 'id', 'nibh', 'ultricies', 'vehicula', 'ut', 'id', 'elit', 'maecenas', 'sed', 'diam', 'eget', 'risus', 'varius', 'blandit', 'sit', 'amet', 'non', 'magna']
|
131
|
+
random_number_of_words = Random.rand(5) + 3
|
132
|
+
"#{words.shuffle[0..(Random.rand(5) + 3)].join(" ").titleize}."
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.body
|
136
|
+
words = ['sed', 'posuere', 'consectetur', 'est', 'at' 'lobortis', 'lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing' 'elit', 'nullam', 'id', 'dolor', 'id', 'nibh', 'ultricies', 'vehicula', 'ut', 'id', 'elit', 'maecenas', 'sed', 'diam', 'eget', 'risus', 'varius', 'blandit', 'sit', 'amet', 'non', 'magna']
|
137
|
+
random_number_of_paragraphs = Random.rand(6) + 1
|
138
|
+
random_number_of_sentences = Random.rand(6) + 1
|
139
|
+
random_number_of_words = Random.rand(10) + 3
|
140
|
+
result = ""
|
141
|
+
random_number_of_paragraphs.times do
|
142
|
+
random_number_of_sentences.times do
|
143
|
+
sentence = "#{words.shuffle[0..random_number_of_words].join(" ")}. "
|
144
|
+
sentence = sentence.slice(0,1).capitalize + sentence.slice(1..-1)
|
145
|
+
result += sentence
|
146
|
+
end
|
147
|
+
result += "\n"
|
148
|
+
end
|
149
|
+
result
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
data/test.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "Seedr"
|
2
|
+
|
3
|
+
puts ""
|
4
|
+
puts "Randoms:"
|
5
|
+
puts "Random integer: #{Seedr.random_integer}"
|
6
|
+
puts "Random character: #{Seedr.random_string}"
|
7
|
+
puts "Random integers (8): #{Seedr.random_integer(8)}"
|
8
|
+
puts "Random characters (8): #{Seedr.random_string(8)}"
|
9
|
+
puts "Random date: #{Seedr.date}"
|
10
|
+
puts "Random datetime: #{Seedr.datetime}"
|
11
|
+
puts ""
|
12
|
+
puts "Profile:"
|
13
|
+
puts "First name: #{Seedr.first_name}"
|
14
|
+
puts "Last name: #{Seedr.last_name}"
|
15
|
+
puts "Middle inital: #{Seedr.middle_initial}"
|
16
|
+
puts "Full name: #{Seedr.full_name}"
|
17
|
+
puts "Username: #{Seedr.username}"
|
18
|
+
puts "Company name: #{Seedr.company_name}"
|
19
|
+
puts "Email: #{Seedr.email}"
|
20
|
+
puts "Phone Number: #{Seedr.phone_number}"
|
21
|
+
puts "Phone Number (separator): #{Seedr.phone_number('-')}"
|
22
|
+
puts "Address line 1: #{Seedr.address_line_1}"
|
23
|
+
puts "Address line 2: #{Seedr.address_line_2}"
|
24
|
+
puts "City: #{Seedr.city}"
|
25
|
+
puts "State: #{Seedr.state}"
|
26
|
+
puts "State (abbreviation): #{Seedr.state(true)}"
|
27
|
+
puts "Province: #{Seedr.province}"
|
28
|
+
puts "Province (abbreviation): #{Seedr.province(true)}"
|
29
|
+
puts "Country: #{Seedr.country}"
|
30
|
+
puts "Country (abbreviation): #{Seedr.country(true)}"
|
31
|
+
puts ""
|
32
|
+
puts "Editorial:"
|
33
|
+
puts "Category: #{Seedr.category}"
|
34
|
+
puts "Article type: #{Seedr.article_type}"
|
35
|
+
puts "Series: #{Seedr.series}"
|
36
|
+
puts "Title: #{Seedr.title}"
|
37
|
+
puts "Body: #{Seedr.body}"
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Seedr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ashe Avenue -- Tim Boisvert and Rob Farrell
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: titleize
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: A friendly Rails seeding assistant
|
31
|
+
email:
|
32
|
+
- tboisvert@asheavenue.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- Seedr.gemspec
|
43
|
+
- img/logo.png
|
44
|
+
- lib/Seedr.rb
|
45
|
+
- lib/Seedr/version.rb
|
46
|
+
- test.rb
|
47
|
+
homepage: http://github.com/AsheAvenue/Seedr
|
48
|
+
licenses: []
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.8.24
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: A friendly Rails seeding assistant
|
71
|
+
test_files: []
|