crazipsum 0.1.2 → 0.2.0
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 +4 -4
- data/.rubocop_todo.yml +19 -18
- data/.travis.yml +6 -3
- data/Gemfile +2 -0
- data/README.md +23 -15
- data/Rakefile +3 -1
- data/ataru_setup.rb +11 -0
- data/bin/console +1 -0
- data/crazipsum.gemspec +10 -6
- data/data/animal.txt +521 -0
- data/data/car_make.txt +150 -0
- data/data/constellation.txt +88 -0
- data/data/country.txt +196 -0
- data/lib/crazipsum.rb +50 -79
- data/lib/crazipsum/dictionnary.rb +15 -0
- data/lib/crazipsum/generator.rb +88 -0
- data/lib/crazipsum/registry.rb +40 -0
- data/lib/crazipsum/version.rb +4 -2
- metadata +46 -24
data/data/car_make.txt
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
Abarth
|
2
|
+
Ac
|
3
|
+
Acura
|
4
|
+
Alfa Romeo
|
5
|
+
Allard
|
6
|
+
Alpina
|
7
|
+
Alpine
|
8
|
+
Alvis
|
9
|
+
Amc
|
10
|
+
Ariel
|
11
|
+
Armstrong Siddeley
|
12
|
+
Ascari
|
13
|
+
Aston Martin
|
14
|
+
Audi
|
15
|
+
Austin
|
16
|
+
Austin-Healey
|
17
|
+
Autobianchi
|
18
|
+
Auverland
|
19
|
+
Avanti
|
20
|
+
Beijing
|
21
|
+
Bentley
|
22
|
+
Berkeley
|
23
|
+
Bitter
|
24
|
+
Bizzarrini
|
25
|
+
Bmw
|
26
|
+
Brilliance
|
27
|
+
Bristol
|
28
|
+
Bugatti
|
29
|
+
Buick
|
30
|
+
Cadillac
|
31
|
+
Caterham
|
32
|
+
Checker
|
33
|
+
Chevrolet
|
34
|
+
Citroen
|
35
|
+
Dacia
|
36
|
+
Daewoo
|
37
|
+
Daf
|
38
|
+
Daihatsu
|
39
|
+
Daimler
|
40
|
+
Datsun
|
41
|
+
De Tomaso
|
42
|
+
Dkw
|
43
|
+
Dodge
|
44
|
+
Donkervoort
|
45
|
+
Eagle
|
46
|
+
Fairthorpe
|
47
|
+
Ferrari
|
48
|
+
Fisker
|
49
|
+
Ford
|
50
|
+
Gaz
|
51
|
+
Ginetta
|
52
|
+
Gmc
|
53
|
+
Holden
|
54
|
+
Hudson
|
55
|
+
Humber
|
56
|
+
Hummer
|
57
|
+
Hyundai
|
58
|
+
Infiniti
|
59
|
+
Innocenti
|
60
|
+
Isuzu
|
61
|
+
Italdesign
|
62
|
+
Jaguar
|
63
|
+
Jeep
|
64
|
+
Kia
|
65
|
+
Koenigsegg
|
66
|
+
Lada
|
67
|
+
Lamborghini
|
68
|
+
Lancia
|
69
|
+
Land Rover
|
70
|
+
Lexus
|
71
|
+
Lincoln
|
72
|
+
Lotec
|
73
|
+
Lotus
|
74
|
+
Luxgen
|
75
|
+
Mahindra
|
76
|
+
Marcos
|
77
|
+
Maserati
|
78
|
+
Matra-Simca
|
79
|
+
Maybach
|
80
|
+
Mazda
|
81
|
+
Mcc
|
82
|
+
Mclaren
|
83
|
+
Mercedes-Benz
|
84
|
+
Mercury
|
85
|
+
Mg
|
86
|
+
Mini
|
87
|
+
Mitsubishi
|
88
|
+
Monteverdi
|
89
|
+
Moretti
|
90
|
+
Morgan
|
91
|
+
Morris
|
92
|
+
Nissan
|
93
|
+
Noble
|
94
|
+
Nsu
|
95
|
+
Oldsmobile
|
96
|
+
Opel
|
97
|
+
Packard
|
98
|
+
Pagani
|
99
|
+
Panoz
|
100
|
+
Peugeot
|
101
|
+
Pininfarina
|
102
|
+
Plymouth
|
103
|
+
Pontiac
|
104
|
+
Porsche
|
105
|
+
Proton
|
106
|
+
Reliant
|
107
|
+
Renault
|
108
|
+
Riley
|
109
|
+
Rolls-Royce
|
110
|
+
Rover
|
111
|
+
Saab
|
112
|
+
Saleen
|
113
|
+
Samsung
|
114
|
+
Saturn
|
115
|
+
Scion
|
116
|
+
Seat
|
117
|
+
Simca
|
118
|
+
Singer
|
119
|
+
Skoda
|
120
|
+
Smart
|
121
|
+
Spyker
|
122
|
+
Ssangyong
|
123
|
+
Ssc
|
124
|
+
Steyr
|
125
|
+
Studebaker
|
126
|
+
Subaru
|
127
|
+
Sunbeam
|
128
|
+
Suzuki
|
129
|
+
Talbot
|
130
|
+
Tata
|
131
|
+
Tatra
|
132
|
+
Tesla
|
133
|
+
Toyota
|
134
|
+
Trabant
|
135
|
+
Triumph
|
136
|
+
Tvr
|
137
|
+
Vauxhall
|
138
|
+
Vector
|
139
|
+
Venturi
|
140
|
+
Volkswagen
|
141
|
+
Volvo
|
142
|
+
Wartburg
|
143
|
+
Westfield
|
144
|
+
Willys-Overland
|
145
|
+
Xedos
|
146
|
+
Zagato
|
147
|
+
Zastava
|
148
|
+
Zaz
|
149
|
+
Zenvo
|
150
|
+
Zil
|
@@ -0,0 +1,88 @@
|
|
1
|
+
Andromeda
|
2
|
+
Antlia
|
3
|
+
Apus
|
4
|
+
Aquarius
|
5
|
+
Aquila
|
6
|
+
Ara
|
7
|
+
Aries
|
8
|
+
Auriga
|
9
|
+
Boötes
|
10
|
+
Caelum
|
11
|
+
Camelopardalis
|
12
|
+
Cancer
|
13
|
+
Canes Venatici
|
14
|
+
Canis Major
|
15
|
+
Canis Minor
|
16
|
+
Capricornus
|
17
|
+
Carina
|
18
|
+
Cassiopeia
|
19
|
+
Centaurus
|
20
|
+
Cepheus
|
21
|
+
Cetus
|
22
|
+
Chamaeleon
|
23
|
+
Circinus
|
24
|
+
Columba
|
25
|
+
Coma Berenices
|
26
|
+
Corona Austrina
|
27
|
+
Corona Borealis
|
28
|
+
Corvus
|
29
|
+
Crater
|
30
|
+
Crux
|
31
|
+
Cygnus
|
32
|
+
Delphinus
|
33
|
+
Dorado
|
34
|
+
Draco
|
35
|
+
Equuleus
|
36
|
+
Eridanus
|
37
|
+
Fornax
|
38
|
+
Gemini
|
39
|
+
Grus
|
40
|
+
Hercules
|
41
|
+
Horologium
|
42
|
+
Hydra
|
43
|
+
Hydrus
|
44
|
+
Indus
|
45
|
+
Lacerta
|
46
|
+
Leo
|
47
|
+
Leo Minor
|
48
|
+
Lepus
|
49
|
+
Libra
|
50
|
+
Lupus
|
51
|
+
Lynx
|
52
|
+
Lyra
|
53
|
+
Mensa
|
54
|
+
Microscopium
|
55
|
+
Monoceros
|
56
|
+
Musca
|
57
|
+
Norma
|
58
|
+
Octans
|
59
|
+
Ophiuchus
|
60
|
+
Orion
|
61
|
+
Pavo
|
62
|
+
Pegasus
|
63
|
+
Perseus
|
64
|
+
Phoenix
|
65
|
+
Pictor
|
66
|
+
Pisces
|
67
|
+
Piscis Austrinus
|
68
|
+
Puppis
|
69
|
+
Pyxis
|
70
|
+
Reticulum
|
71
|
+
Sagitta
|
72
|
+
Sagittarius
|
73
|
+
Scorpius
|
74
|
+
Sculptor
|
75
|
+
Scutum
|
76
|
+
Serpens
|
77
|
+
Sextans
|
78
|
+
Taurus
|
79
|
+
Telescopium
|
80
|
+
Triangulum
|
81
|
+
Triangulum Australe
|
82
|
+
Tucana
|
83
|
+
Ursa Major
|
84
|
+
Ursa Minor
|
85
|
+
Vela
|
86
|
+
Virgo
|
87
|
+
Volans
|
88
|
+
Vulpecula
|
data/data/country.txt
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
Afghanistan
|
2
|
+
Albania
|
3
|
+
Algeria
|
4
|
+
Andorra
|
5
|
+
Angola
|
6
|
+
Antigua & Deps
|
7
|
+
Argentina
|
8
|
+
Armenia
|
9
|
+
Australia
|
10
|
+
Austria
|
11
|
+
Azerbaijan
|
12
|
+
Bahamas
|
13
|
+
Bahrain
|
14
|
+
Bangladesh
|
15
|
+
Barbados
|
16
|
+
Belarus
|
17
|
+
Belgium
|
18
|
+
Belize
|
19
|
+
Benin
|
20
|
+
Bhutan
|
21
|
+
Bolivia
|
22
|
+
Bosnia Herzegovina
|
23
|
+
Botswana
|
24
|
+
Brazil
|
25
|
+
Brunei
|
26
|
+
Bulgaria
|
27
|
+
Burkina
|
28
|
+
Burundi
|
29
|
+
Cambodia
|
30
|
+
Cameroon
|
31
|
+
Canada
|
32
|
+
Cape Verde
|
33
|
+
Central African Rep
|
34
|
+
Chad
|
35
|
+
Chile
|
36
|
+
China
|
37
|
+
Colombia
|
38
|
+
Comoros
|
39
|
+
Congo
|
40
|
+
Costa Rica
|
41
|
+
Croatia
|
42
|
+
Cuba
|
43
|
+
Cyprus
|
44
|
+
Czech Republic
|
45
|
+
Democratic Republic of the Congo
|
46
|
+
Denmark
|
47
|
+
Djibouti
|
48
|
+
Dominica
|
49
|
+
Dominican Republic
|
50
|
+
East Timor
|
51
|
+
Ecuador
|
52
|
+
Egypt
|
53
|
+
El Salvador
|
54
|
+
Equatorial Guinea
|
55
|
+
Eritrea
|
56
|
+
Estonia
|
57
|
+
Ethiopia
|
58
|
+
Fiji
|
59
|
+
Finland
|
60
|
+
France
|
61
|
+
Gabon
|
62
|
+
Gambia
|
63
|
+
Georgia
|
64
|
+
Germany
|
65
|
+
Ghana
|
66
|
+
Greece
|
67
|
+
Grenada
|
68
|
+
Guatemala
|
69
|
+
Guinea
|
70
|
+
Guinea-Bissau
|
71
|
+
Guyana
|
72
|
+
Haiti
|
73
|
+
Honduras
|
74
|
+
Hungary
|
75
|
+
Iceland
|
76
|
+
India
|
77
|
+
Indonesia
|
78
|
+
Iran
|
79
|
+
Iraq
|
80
|
+
Ireland
|
81
|
+
Israel
|
82
|
+
Italy
|
83
|
+
Ivory Coast
|
84
|
+
Jamaica
|
85
|
+
Japan
|
86
|
+
Jordan
|
87
|
+
Kazakhstan
|
88
|
+
Kenya
|
89
|
+
Kiribati
|
90
|
+
Korea North
|
91
|
+
Korea South
|
92
|
+
Kosovo
|
93
|
+
Kuwait
|
94
|
+
Kyrgyzstan
|
95
|
+
Laos
|
96
|
+
Latvia
|
97
|
+
Lebanon
|
98
|
+
Lesotho
|
99
|
+
Liberia
|
100
|
+
Libya
|
101
|
+
Liechtenstein
|
102
|
+
Lithuania
|
103
|
+
Luxembourg
|
104
|
+
Macedonia
|
105
|
+
Madagascar
|
106
|
+
Malawi
|
107
|
+
Malaysia
|
108
|
+
Maldives
|
109
|
+
Mali
|
110
|
+
Malta
|
111
|
+
Marshall Islands
|
112
|
+
Mauritania
|
113
|
+
Mauritius
|
114
|
+
Mexico
|
115
|
+
Micronesia
|
116
|
+
Moldova
|
117
|
+
Monaco
|
118
|
+
Mongolia
|
119
|
+
Montenegro
|
120
|
+
Morocco
|
121
|
+
Mozambique
|
122
|
+
Myanmar
|
123
|
+
Namibia
|
124
|
+
Nauru
|
125
|
+
Nepal
|
126
|
+
Netherlands
|
127
|
+
New Zealand
|
128
|
+
Nicaragua
|
129
|
+
Niger
|
130
|
+
Nigeria
|
131
|
+
Norway
|
132
|
+
Oman
|
133
|
+
Pakistan
|
134
|
+
Palau
|
135
|
+
Panama
|
136
|
+
Papua New Guinea
|
137
|
+
Paraguay
|
138
|
+
Peru
|
139
|
+
Philippines
|
140
|
+
Poland
|
141
|
+
Portugal
|
142
|
+
Qatar
|
143
|
+
Romania
|
144
|
+
Russian Federation
|
145
|
+
Rwanda
|
146
|
+
St Kitts & Nevis
|
147
|
+
St Lucia
|
148
|
+
Saint Vincent & the Grenadines
|
149
|
+
Samoa
|
150
|
+
San Marino
|
151
|
+
Sao Tome & Principe
|
152
|
+
Saudi Arabia
|
153
|
+
Senegal
|
154
|
+
Serbia
|
155
|
+
Seychelles
|
156
|
+
Sierra Leone
|
157
|
+
Singapore
|
158
|
+
Slovakia
|
159
|
+
Slovenia
|
160
|
+
Solomon Islands
|
161
|
+
Somalia
|
162
|
+
South Africa
|
163
|
+
South Sudan
|
164
|
+
Spain
|
165
|
+
Sri Lanka
|
166
|
+
Sudan
|
167
|
+
Suriname
|
168
|
+
Swaziland
|
169
|
+
Sweden
|
170
|
+
Switzerland
|
171
|
+
Syria
|
172
|
+
Taiwan
|
173
|
+
Tajikistan
|
174
|
+
Tanzania
|
175
|
+
Thailand
|
176
|
+
Togo
|
177
|
+
Tonga
|
178
|
+
Trinidad & Tobago
|
179
|
+
Tunisia
|
180
|
+
Turkey
|
181
|
+
Turkmenistan
|
182
|
+
Tuvalu
|
183
|
+
Uganda
|
184
|
+
Ukraine
|
185
|
+
United Arab Emirates
|
186
|
+
United Kingdom
|
187
|
+
United States
|
188
|
+
Uruguay
|
189
|
+
Uzbekistan
|
190
|
+
Vanuatu
|
191
|
+
Vatican City
|
192
|
+
Venezuela
|
193
|
+
Vietnam
|
194
|
+
Yemen
|
195
|
+
Zambia
|
196
|
+
Zimbabwe
|
data/lib/crazipsum.rb
CHANGED
@@ -1,86 +1,57 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Crazipsum
|
4
|
-
REGISTER = Hash.new { Crazipsum.new([], fillers: false) }
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def register(type, path, opts = {})
|
8
|
-
fillers = opts[:fillers]
|
9
|
-
opts[:fillers] = parse_dictionnary(local_dictionnary_path(:fillers)) if fillers.nil? || fillers
|
10
|
-
words = parse_dictionnary(path)
|
11
|
-
REGISTER[type] = new(words, opts)
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def parse_dictionnary(path_or_array)
|
17
|
-
return path_or_array if path_or_array.is_a?(Array)
|
18
|
-
file_content = File.read(path_or_array)
|
19
|
-
file_content.split("\n")
|
20
|
-
end
|
21
|
-
|
22
|
-
def register_from_gem(type)
|
23
|
-
register(type, local_dictionnary_path(type))
|
24
|
-
end
|
25
|
-
|
26
|
-
def local_dictionnary_path(type)
|
27
|
-
File.expand_path("../../data/#{type}.txt", __FILE__)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def sentence(opts = {})
|
32
|
-
quantity = opts[:word_count] || rand(7..15)
|
33
|
-
quantity = 0 if quantity < 0
|
34
|
-
sentence_fillers = opts[:fillers]
|
35
|
-
sentence_fillers = fillers if sentence_fillers.nil?
|
36
|
-
dict = dictionnary
|
37
|
-
words = (0...quantity).map do
|
38
|
-
next dict.sample unless sentence_fillers
|
39
|
-
rand(3) == 0 ? dict.sample : sentence_fillers.sample
|
40
|
-
end
|
41
|
-
return '' if words.empty?
|
42
|
-
words[0] = words[0].capitalize
|
43
|
-
words = words.join(' ')
|
44
|
-
"#{words}."
|
45
|
-
end
|
46
|
-
|
47
|
-
def paragraph(opts = {})
|
48
|
-
quantity = opts[:sentence_count] || rand(4..7)
|
49
|
-
paragraph = []
|
50
|
-
quantity.times do
|
51
|
-
s = sentence(opts)
|
52
|
-
paragraph << s unless s.empty?
|
53
|
-
end
|
54
|
-
paragraph.join(' ')
|
55
|
-
end
|
56
|
-
alias sentences paragraph
|
1
|
+
# frozen_string_literal: true
|
57
2
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
3
|
+
require 'crazipsum/version'
|
4
|
+
require 'crazipsum/registry'
|
5
|
+
|
6
|
+
data_dir = File.expand_path('../data', __dir__)
|
7
|
+
DEFAULT_FILLERS = File.read(File.join(data_dir, 'fillers.txt')).split("\n")
|
8
|
+
|
9
|
+
# Ever wanted some dumber, crazier (fancier?) lorem ipsum? Here you go!
|
10
|
+
module Crazipsum
|
11
|
+
module_function
|
12
|
+
|
13
|
+
# Registers a new type of Dictionnary that can later be retrieved with Crazipsum().
|
14
|
+
#
|
15
|
+
# @param [String,Symbol] type a name for that dictionnary. This type will be
|
16
|
+
# used later when calling `Crazipsum(type)`.
|
17
|
+
# @param [Array<String>] words a list of words used when generating the lorem ipsum.
|
18
|
+
# @param [Array<String>] fillers a list of words used to fill in the sentences when generating the lorem ipsum.
|
19
|
+
def register(type, words, fillers: DEFAULT_FILLERS)
|
20
|
+
Crazipsum::Registry.instance.register(type, words, fillers: fillers)
|
66
21
|
end
|
22
|
+
end
|
67
23
|
|
68
|
-
|
69
|
-
|
70
|
-
|
24
|
+
# Returns a lorem ipsum generator which will generate lorem ipsums of the given
|
25
|
+
# type.
|
26
|
+
#
|
27
|
+
# There are a few default types registered:
|
28
|
+
# * `car_make`
|
29
|
+
# * `phobia`
|
30
|
+
# * `programming_language`
|
31
|
+
# * `animal`
|
32
|
+
# * `fruit`
|
33
|
+
# * `constellation`
|
34
|
+
# * `mineral`
|
35
|
+
# * `religion`
|
36
|
+
# * `country`
|
37
|
+
#
|
38
|
+
# You can register new types of lorem ipsum via `Crazipsum.register(type, words, fillers: fillers)`.
|
39
|
+
#
|
40
|
+
# @param type [Symbol,String] the type of lorem ipsum you'd like to generate.
|
41
|
+
# @return [Crazipsum::Generator] a funky lorem ipsum generator.
|
42
|
+
def Crazipsum(type) # rubocop:disable Naming/MethodName
|
43
|
+
dictionnary = Crazipsum::Registry.instance[type]
|
44
|
+
raise ArgumentError, 'unregistered ipsum type' if dictionnary.nil?
|
45
|
+
|
46
|
+
Crazipsum::Generator.new(dictionnary)
|
47
|
+
end
|
71
48
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
49
|
+
Dir[File.join(data_dir, '*')].each do |file|
|
50
|
+
type = File.basename(file, '.txt')
|
51
|
+
next if type == 'fillers'
|
76
52
|
|
77
|
-
|
78
|
-
|
79
|
-
register_from_gem(:fruit)
|
80
|
-
register_from_gem(:mineral)
|
81
|
-
register_from_gem(:programming_language)
|
82
|
-
end
|
53
|
+
file_content = File.read(file)
|
54
|
+
words = file_content.split("\n")
|
83
55
|
|
84
|
-
|
85
|
-
Crazipsum::REGISTER[type]
|
56
|
+
Crazipsum.register(type, words)
|
86
57
|
end
|