random-words 1.0.12 → 1.0.13
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.yml +18 -86
- data/CHANGELOG.md +16 -0
- data/bin/randw +23 -9
- data/generator.cgi +155 -0
- data/lib/random-words/array.rb +0 -2
- data/lib/random-words/boolean.rb +1 -1
- data/lib/random-words/config.rb +6 -6
- data/lib/random-words/generator.rb +25 -27
- data/lib/random-words/html2markdown.rb +5 -5
- data/lib/random-words/{lorem-html.rb → lorem_html.rb} +89 -59
- data/lib/random-words/{number-to-word.rb → number_to_word.rb} +5 -5
- data/lib/random-words/numeric.rb +2 -2
- data/lib/random-words/string.rb +10 -3
- data/lib/random-words/terminal.rb +15 -13
- data/lib/random-words/version.rb +1 -1
- data/lib/random-words/words/walken/adjectives.txt +139 -0
- data/lib/random-words/words/walken/adverbs.txt +164 -0
- data/lib/random-words/words/walken/articles-plural.txt +10 -0
- data/lib/random-words/words/walken/articles-singular.txt +10 -0
- data/lib/random-words/words/walken/clauses.txt +200 -0
- data/lib/random-words/words/walken/config.yml +4 -0
- data/lib/random-words/words/walken/conjunctions-coordinating.txt +20 -0
- data/lib/random-words/words/walken/conjunctions-subordinate.txt +28 -0
- data/lib/random-words/words/walken/names.txt +101 -0
- data/lib/random-words/words/walken/nouns-plural.txt +330 -0
- data/lib/random-words/words/walken/nouns-singular.txt +500 -0
- data/lib/random-words/words/walken/numbers.yml +5 -0
- data/lib/random-words/words/walken/phrases.txt +45 -0
- data/lib/random-words/words/walken/prepositions.txt +45 -0
- data/lib/random-words/words/walken/terminators.txt +17 -0
- data/lib/random-words/words/walken/verbs-passive.txt +370 -0
- data/lib/random-words/words/walken/verbs-plural.txt +294 -0
- data/lib/random-words/words/walken/verbs-singular.txt +262 -0
- data/lib/random-words.rb +2 -2
- metadata +23 -4
@@ -42,16 +42,16 @@ module RandomWords
|
|
42
42
|
EOMETA
|
43
43
|
case @meta_type
|
44
44
|
when :multimarkdown
|
45
|
-
meta = <<~
|
45
|
+
meta = <<~EOMMD
|
46
46
|
#{meta}
|
47
47
|
|
48
|
-
|
48
|
+
EOMMD
|
49
49
|
when :yaml
|
50
|
-
meta = <<~
|
50
|
+
meta = <<~EOYAML
|
51
51
|
---
|
52
52
|
#{meta}
|
53
53
|
---
|
54
|
-
|
54
|
+
EOYAML
|
55
55
|
end
|
56
56
|
end
|
57
57
|
i = 0
|
@@ -140,7 +140,7 @@ module RandomWords
|
|
140
140
|
@title = node.content
|
141
141
|
''
|
142
142
|
when 'head'
|
143
|
-
|
143
|
+
output_for_children(node)
|
144
144
|
''
|
145
145
|
when 'style', 'script'
|
146
146
|
''
|
@@ -14,10 +14,26 @@ module RandomWords
|
|
14
14
|
|
15
15
|
# Generates random Lorem Ipsum text.
|
16
16
|
# @param options [Hash] Options for generating Lorem Ipsum text.
|
17
|
+
#
|
18
|
+
# @option options [Symbol] :source The source of the words (:latin, :english, :french, etc.).
|
19
|
+
# @option options [Integer] :grafs The number of paragraphs to generate.
|
20
|
+
# @option options [Integer] :sentences The number of sentences per paragraph.
|
21
|
+
# @option options [Symbol] :length The length of the text (:short, :medium, :long, :very_long).
|
22
|
+
# @option options [Boolean] :decorate Whether to include emphasis and strong tags.
|
23
|
+
# @option options [Boolean] :link Whether to include links.
|
24
|
+
# @option options [Boolean] :ul Whether to include unordered lists.
|
25
|
+
# @option options [Boolean] :ol Whether to include ordered lists.
|
26
|
+
# @option options [Boolean] :dl Whether to include definition lists.
|
27
|
+
# @option options [Boolean] :bq Whether to include blockquotes.
|
28
|
+
# @option options [Boolean] :code Whether to include code blocks.
|
29
|
+
# @option options [Boolean] :mark Whether to include mark tags.
|
30
|
+
# @option options [Boolean] :headers Whether to include headers.
|
31
|
+
# @option options [Boolean] :table Whether to include tables.
|
32
|
+
# @option options [Boolean] :extended Whether to use extended punctuation.
|
17
33
|
# @return [String] A string of random Lorem Ipsum text.
|
18
34
|
def initialize(options = {})
|
19
35
|
@added = {
|
20
|
-
|
36
|
+
italic: false,
|
21
37
|
strong: false,
|
22
38
|
link: false,
|
23
39
|
code: false,
|
@@ -58,31 +74,32 @@ module RandomWords
|
|
58
74
|
|
59
75
|
@output = ''
|
60
76
|
strong = @options[:decorate]
|
61
|
-
|
77
|
+
italic = @options[:decorate]
|
62
78
|
links = @options[:link]
|
63
79
|
code = @options[:code]
|
64
80
|
mark = @options[:mark]
|
65
81
|
footnotes = @options[:footnote]
|
66
|
-
|
67
|
-
|
82
|
+
@options[:hr]
|
83
|
+
@options[:image]
|
68
84
|
force = []
|
69
85
|
# Generate the specified number of paragraphs.
|
70
86
|
@options[:grafs].times.with_index do |_, i|
|
71
|
-
@
|
87
|
+
if @options[:grafs] == 1 || i == @options[:grafs] - 2
|
88
|
+
force << :footnote if !@added[:footnote] && @options[:footnote]
|
89
|
+
force << :code if !@added[:code] && @options[:code]
|
90
|
+
force << :link if !@added[:link] && @options[:link]
|
91
|
+
force << :italic if !@added[:italic] && @options[:decorate]
|
92
|
+
force << :strong if !@added[:strong] && @options[:decorate]
|
93
|
+
end
|
94
|
+
|
95
|
+
@output += paragraph(1, italic: italic, strong: strong, links: links, code: code, mark: mark, footnotes: footnotes,
|
72
96
|
force: force)
|
73
|
-
|
97
|
+
italic = Random.rand(0..3).zero? && @options[:decorate]
|
74
98
|
strong = Random.rand(0..3).zero? && @options[:decorate]
|
75
99
|
links = Random.rand(0..3).zero? && @options[:link]
|
76
100
|
code = Random.rand(0..3).zero? && @options[:code]
|
77
101
|
footnotes = Random.rand(0..3).zero? && @options[:footnote]
|
78
102
|
|
79
|
-
if i == @options[:grafs] - 2
|
80
|
-
force << :footnote if !@added[:footnote] && @options[:footnote]
|
81
|
-
force << :code if !@added[:code] && @options[:code]
|
82
|
-
force << :link if !@added[:link] && @options[:link]
|
83
|
-
force << :em if !@added[:em] && @options[:decorate]
|
84
|
-
force << :strong if !@added[:strong] && @options[:decorate]
|
85
|
-
end
|
86
103
|
@output += "\n\n"
|
87
104
|
end
|
88
105
|
|
@@ -90,57 +107,61 @@ module RandomWords
|
|
90
107
|
end
|
91
108
|
|
92
109
|
# Use the RandomWords class to generate the Lorem Ipsum text.
|
110
|
+
#
|
111
|
+
# @return [String] The generated Lorem Ipsum HTML.
|
93
112
|
def generate
|
94
113
|
compress_newlines
|
114
|
+
handle_lists
|
115
|
+
handle_basic_elements
|
116
|
+
handle_content_blocks
|
117
|
+
finalize_output
|
118
|
+
@output
|
119
|
+
end
|
120
|
+
|
121
|
+
private
|
95
122
|
|
123
|
+
def handle_lists
|
96
124
|
items = { short: 4, medium: 8, long: 10, very_long: 12 }[@options[:length]]
|
97
125
|
|
98
126
|
if @options[:ul] && @options[:ol]
|
99
|
-
# If both unordered and ordered lists are specified, add them both.
|
100
127
|
inject_block(1, -> { list(items, :ul) })
|
101
128
|
inject_block(1, -> { list(items, :ol) })
|
102
129
|
elsif @options[:ul]
|
103
|
-
# If only unordered list is specified, add it.
|
104
130
|
inject_block(2, -> { list(items, :ul) })
|
105
131
|
elsif @options[:ol]
|
106
|
-
# If only ordered list is specified, add it.
|
107
132
|
inject_block(2, -> { list(items, :ol) })
|
108
133
|
end
|
134
|
+
end
|
109
135
|
|
110
|
-
|
136
|
+
def handle_basic_elements
|
111
137
|
inject_block(1, -> { "<hr>\n\n" }) if @options[:hr]
|
112
138
|
|
113
|
-
|
114
|
-
if @options[:image]
|
115
|
-
inject_block(1, lambda {
|
116
|
-
"<img src=\"https://picsum.photos/400/200\" alt=\"#{fragment(1, 4).cap_first}\" />\n\n"
|
117
|
-
})
|
118
|
-
end
|
139
|
+
return unless @options[:image]
|
119
140
|
|
120
|
-
|
121
|
-
|
141
|
+
inject_block(1, lambda {
|
142
|
+
"<img src=\"https://picsum.photos/400/200\" alt=\"#{fragment(1, 4).cap_first}\" />\n\n"
|
143
|
+
})
|
144
|
+
end
|
122
145
|
|
123
|
-
|
124
|
-
|
146
|
+
def handle_content_blocks
|
147
|
+
items = { short: 4, medium: 8, long: 10, very_long: 12 }[@options[:length]]
|
125
148
|
|
126
|
-
|
149
|
+
inject_block(1, -> { list(items, :dl) }) if @options[:dl]
|
150
|
+
inject_block(1, -> { blockquote(items / 2) }) if @options[:bq]
|
127
151
|
inject_headers if @options[:headers]
|
128
|
-
|
129
|
-
# Add code block if specified.
|
130
152
|
inject_block(1, -> { code }) if @options[:code]
|
131
|
-
|
132
|
-
# Add table if specified.
|
133
153
|
inject_block(1, -> { table }) if @options[:table]
|
154
|
+
end
|
134
155
|
|
156
|
+
def finalize_output
|
135
157
|
ensure_block_newlines
|
136
158
|
compress_newlines
|
137
159
|
convert_punctuation
|
138
160
|
end
|
139
161
|
|
140
|
-
private
|
141
|
-
|
142
162
|
# Convert non-ascii punctuation to Markdown equivalents.
|
143
163
|
# @param [String] text The text to convert.
|
164
|
+
#
|
144
165
|
# @return [String] The converted text.
|
145
166
|
def convert_punctuation
|
146
167
|
text = @output
|
@@ -154,29 +175,36 @@ module RandomWords
|
|
154
175
|
@output = text
|
155
176
|
end
|
156
177
|
|
157
|
-
#
|
158
|
-
|
159
|
-
|
178
|
+
# Roll a random number to determine if an action should occur
|
179
|
+
# @param percent [Integer] 1-100 percent chance of the action occurring (1-100)
|
180
|
+
#
|
181
|
+
# @return [Boolean] True if the action occurs, false otherwise
|
182
|
+
#
|
183
|
+
# @example
|
184
|
+
# roll(50) # 50% chance of returning true
|
185
|
+
def roll(percent)
|
186
|
+
rand(1..100) <= percent
|
160
187
|
end
|
161
188
|
|
162
189
|
# Generates a list of items.
|
163
190
|
# @param [Integer] count The number of items to generate.
|
164
191
|
# @param [Symbol] type The type of list to generate (:ul, :ol, :dl).
|
192
|
+
#
|
165
193
|
# @return [String] The generated list.
|
166
194
|
def list(count, type)
|
167
195
|
ul = "\n\n<#{type}>\n"
|
168
196
|
|
169
197
|
count.times do
|
170
|
-
links = roll(
|
171
|
-
|
172
|
-
strong = roll(
|
173
|
-
code = roll(
|
174
|
-
mark = roll(
|
198
|
+
links = roll(20) && @options[:link]
|
199
|
+
italic = roll(50) && @options[:decorate]
|
200
|
+
strong = roll(50) && @options[:decorate]
|
201
|
+
code = roll(10) && @options[:code]
|
202
|
+
mark = roll(10) && @options[:mark]
|
175
203
|
|
176
204
|
frag = fragment(1, 4).cap_first
|
177
205
|
long_frag = fragment(4, 8).cap_first
|
178
206
|
long_frag = inject_inline(long_frag, -> { link }) if links
|
179
|
-
long_frag = inject_inline(long_frag, -> { emphasis(:em) }) if
|
207
|
+
long_frag = inject_inline(long_frag, -> { emphasis(:em) }) if italic
|
180
208
|
long_frag = inject_inline(long_frag, -> { emphasis(:strong) }) if strong
|
181
209
|
long_frag = inject_inline(long_frag, -> { code_span }, 1) if code
|
182
210
|
long_frag = inject_inline(long_frag, -> { emphasis(:mark) }, 1) if mark
|
@@ -195,8 +223,9 @@ module RandomWords
|
|
195
223
|
# Generates a blockquote.
|
196
224
|
# @param [Integer] count The number of items to generate.
|
197
225
|
# @param [Boolean] nested Whether the blockquote is nested.
|
226
|
+
#
|
198
227
|
# @return [String] The generated blockquote.
|
199
|
-
def blockquote(count, nested
|
228
|
+
def blockquote(count, nested: false)
|
200
229
|
if count > 1 && !nested
|
201
230
|
level1 = Random.rand(1..count - 1).to_i
|
202
231
|
level2 = count - level1
|
@@ -208,12 +237,12 @@ module RandomWords
|
|
208
237
|
newline = nested ? '' : "\n\n"
|
209
238
|
quote = "#{newline}<blockquote>\n"
|
210
239
|
quote += paragraph(level1,
|
211
|
-
|
240
|
+
italic: @options[:decorate],
|
212
241
|
strong: @options[:decorate],
|
213
242
|
links: @options[:link],
|
214
243
|
code: @options[:code],
|
215
244
|
mark: @options[:mark]).squeeze("\n")
|
216
|
-
quote += blockquote(level2, true).strip if level2.positive?
|
245
|
+
quote += blockquote(level2, nested: true).strip if level2.positive?
|
217
246
|
"#{quote}#{cite}</blockquote>#{newline}"
|
218
247
|
end
|
219
248
|
|
@@ -320,7 +349,7 @@ module RandomWords
|
|
320
349
|
path = "/#{path_string(4, 8)}/#{path_string(4, 8)}"
|
321
350
|
title = fragment(4, 8).cap_first
|
322
351
|
"<a%%href=\"https://example.com#{path}\"%%title=\"#{title.preserve_spaces}\">#{fragment(1,
|
323
|
-
8)
|
352
|
+
8)}</a>"
|
324
353
|
end
|
325
354
|
|
326
355
|
# Generates a random footnote
|
@@ -370,7 +399,7 @@ module RandomWords
|
|
370
399
|
def inject_inline(text, block, max = nil)
|
371
400
|
max ||= { short: 1, medium: 2, long: 3, very_long: 4 }[@options[:length]]
|
372
401
|
|
373
|
-
words = text.split
|
402
|
+
words = text.split
|
374
403
|
out = []
|
375
404
|
count = 0
|
376
405
|
while words.any?
|
@@ -390,29 +419,30 @@ module RandomWords
|
|
390
419
|
# Generates a paragraph of Lorem Ipsum text.
|
391
420
|
# The `words` method generates a specified number of words.
|
392
421
|
# @param [Integer] count The number of paragraphs to generate.
|
393
|
-
# @param [Boolean]
|
422
|
+
# @param [Boolean] italic Whether to include italic tags.
|
394
423
|
# @param [Boolean] strong Whether to include strong tags.
|
395
424
|
# @param [Boolean] links Whether to include links.
|
396
425
|
# @param [Boolean] code Whether to include code tags.
|
397
426
|
# @param [Boolean] mark Whether to include mark tags.
|
398
427
|
# @param [Array] force An array of tags to force.
|
399
428
|
# @return [String] The generated paragraph.
|
400
|
-
def paragraph(count,
|
429
|
+
def paragraph(count, italic: false, strong: false, links: false, code: false, mark: false, footnotes: false, force: [])
|
401
430
|
output = ''
|
431
|
+
|
402
432
|
s = { short: 2, medium: 4, long: 6, very_long: 8 }[@options[:length]]
|
403
433
|
count.times do
|
404
434
|
p = @generator.sentences(s).join(' ')
|
405
|
-
should_em = force.include?(:
|
406
|
-
should_strong = force.include?(:strong) || (strong && roll(
|
407
|
-
should_code = force.include?(:code) || (code && roll(
|
408
|
-
should_link = force.include?(:
|
409
|
-
should_mark = force.include?(:mark) || (mark && roll(
|
410
|
-
should_footnote = force.include?(:footnote) || (footnotes && roll(
|
435
|
+
should_em = force.include?(:italic) || (italic && roll(60))
|
436
|
+
should_strong = force.include?(:strong) || (strong && roll(60))
|
437
|
+
should_code = force.include?(:code) || (code && roll(40))
|
438
|
+
should_link = force.include?(:link) || (links && roll(40))
|
439
|
+
should_mark = force.include?(:mark) || (mark && roll(40))
|
440
|
+
should_footnote = force.include?(:footnote) || (footnotes && roll(40))
|
411
441
|
|
412
442
|
p = inject_inline(p, -> { link }) if should_link
|
413
|
-
p = inject_inline(p, -> { emphasis(
|
414
|
-
p = inject_inline(p, -> { emphasis(
|
415
|
-
p = inject_inline(p, -> { emphasis(
|
443
|
+
p = inject_inline(p, -> { emphasis(:em) }) if should_em
|
444
|
+
p = inject_inline(p, -> { emphasis(:strong) }) if should_strong
|
445
|
+
p = inject_inline(p, -> { emphasis(:mark) }, 1) if should_mark
|
416
446
|
p = inject_inline(p, -> { code_span }, 1) if should_code
|
417
447
|
fn = should_footnote ? footnote.restore_spaces : ''
|
418
448
|
output += "<p>#{p.restore_spaces.cap_first.term('.')}#{fn}</p>\n\n"
|
@@ -33,10 +33,10 @@ module RandomWords
|
|
33
33
|
# 126620.to_word # => "one hundred twenty six thousand six hundred twenty"
|
34
34
|
def to_word(numbers)
|
35
35
|
tmp = self / 1000
|
36
|
-
final = (self % 1000).hundred_to_word(
|
36
|
+
final = (self % 1000).hundred_to_word(numbers, 2)
|
37
37
|
place = 3 # special-case the tens and below
|
38
38
|
until tmp.zero?
|
39
|
-
final = (tmp % 1000).hundred_to_word(
|
39
|
+
final = "#{(tmp % 1000).hundred_to_word(numbers, place)} #{final}"
|
40
40
|
place += 1
|
41
41
|
tmp /= 1000
|
42
42
|
end
|
@@ -54,7 +54,7 @@ module RandomWords
|
|
54
54
|
protected
|
55
55
|
|
56
56
|
# Convert a number to its word representation for the hundreds place.
|
57
|
-
def hundred_to_word(place = 0
|
57
|
+
def hundred_to_word(numbers, place = 0)
|
58
58
|
if zero?
|
59
59
|
''
|
60
60
|
elsif self < 10
|
@@ -83,7 +83,7 @@ module RandomWords
|
|
83
83
|
def append_place(word, place, numbers)
|
84
84
|
places = numbers[:places]
|
85
85
|
if place > 2
|
86
|
-
word
|
86
|
+
"#{word} #{places[place]}"
|
87
87
|
else
|
88
88
|
word
|
89
89
|
end
|
@@ -100,7 +100,7 @@ module RandomWords
|
|
100
100
|
tens = self / 10
|
101
101
|
ones = self % 10
|
102
102
|
ten = numbers[:tens][tens - 2]
|
103
|
-
ten
|
103
|
+
"#{ten} #{ones.zero? ? '' : ones.digit_to_word(numbers)}"
|
104
104
|
else
|
105
105
|
teen_to_word(numbers)
|
106
106
|
end
|
data/lib/random-words/numeric.rb
CHANGED
@@ -6,8 +6,8 @@ module RandomWords
|
|
6
6
|
def to_commas
|
7
7
|
num = to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse
|
8
8
|
dec = num.split('.')
|
9
|
-
num = dec[0]
|
9
|
+
num = "#{dec[0]}.#{dec[1].to_s.ljust(2, '0')[0, 2]}" if dec[1]
|
10
10
|
num
|
11
11
|
end
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
data/lib/random-words/string.rb
CHANGED
@@ -280,7 +280,7 @@ module RandomWords
|
|
280
280
|
# @return [String] The colorized text.
|
281
281
|
# @example
|
282
282
|
# colorize_text("Hello, World!", :red) # => "\e[31mHello, World!\e[0m"
|
283
|
-
def colorize_text(text, color, testing
|
283
|
+
def colorize_text(text, color, testing: false)
|
284
284
|
return text if !$stdout.isatty && !testing
|
285
285
|
|
286
286
|
return text unless colors.key?(color)
|
@@ -321,13 +321,20 @@ module RandomWords
|
|
321
321
|
|
322
322
|
# Expand abbreviated debug statements in the string.
|
323
323
|
# @return [String] The expanded debug string.
|
324
|
-
def expand_debug(testing
|
324
|
+
def expand_debug(testing: false)
|
325
325
|
gsub(/%(#{Regexp.union(expansions.keys)})%?/) do
|
326
326
|
match = Regexp.last_match
|
327
327
|
|
328
328
|
return match unless expansions.key?(match[1])
|
329
329
|
|
330
|
-
colorize_text("[#{expansions[match[1]][0] || match}]", expansions[match[1]][1] || :white, testing)
|
330
|
+
colorize_text("[#{expansions[match[1]][0] || match}]", expansions[match[1]][1] || :white, testing: testing)
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
def article_agree
|
335
|
+
gsub(/\ban? (\w)/i) do |match|
|
336
|
+
word = match[1]
|
337
|
+
/\A[aeiou]/i.match?(word) ? "an #{word}" : "a #{word}"
|
331
338
|
end
|
332
339
|
end
|
333
340
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RandomWords
|
2
4
|
# Terminal methods for testing
|
3
5
|
class Terminal
|
@@ -47,13 +49,13 @@ module RandomWords
|
|
47
49
|
"\e[#{color_code}m#{text}\e[0m"
|
48
50
|
end
|
49
51
|
|
50
|
-
def
|
52
|
+
def header1(text)
|
51
53
|
puts colorize_text("\n\n#{text}", :boldgreen)
|
52
54
|
puts colorize_text('=' * text.length, :boldgreen)
|
53
55
|
puts "\n"
|
54
56
|
end
|
55
57
|
|
56
|
-
def
|
58
|
+
def header2(text)
|
57
59
|
puts colorize_text("\n\n#{text}", :boldyellow)
|
58
60
|
puts colorize_text('-' * text.length, :boldyellow)
|
59
61
|
puts "\n"
|
@@ -64,14 +66,14 @@ module RandomWords
|
|
64
66
|
@sentence_generator.paragraph_length = count
|
65
67
|
@sentence_generator.source = @sources.sample
|
66
68
|
|
67
|
-
|
69
|
+
header2("Random Paragraph (#{@sentence_generator.paragraph_length} #{@sentence_generator.sentence_length} sentences)")
|
68
70
|
graf = @sentence_generator.paragraph
|
69
71
|
puts text(graf)
|
70
72
|
puts counter("#{graf.split(/ /).count} words, #{graf.length} characters")
|
71
73
|
end
|
72
74
|
|
73
75
|
def sentence(length)
|
74
|
-
|
76
|
+
header2("Random #{length} sentence")
|
75
77
|
@sentence_generator.sentence_length = length
|
76
78
|
s = @sentence_generator.sentence
|
77
79
|
puts text(s)
|
@@ -82,7 +84,7 @@ module RandomWords
|
|
82
84
|
def combined_sentences(length = nil)
|
83
85
|
number_of_sentences = length || 2
|
84
86
|
|
85
|
-
|
87
|
+
header1('Random Combined Sentences:')
|
86
88
|
@sources.count.times do |i|
|
87
89
|
@sentence_generator.source = @sources[i - 1]
|
88
90
|
@sentence_generator.sentence_length = :medium
|
@@ -96,7 +98,7 @@ module RandomWords
|
|
96
98
|
end
|
97
99
|
|
98
100
|
def random_sentences
|
99
|
-
|
101
|
+
header1('Random Sentences')
|
100
102
|
@sentence_generator.lengths.keys.each_with_index do |length, index|
|
101
103
|
@sentence_generator.source = @sources[index]
|
102
104
|
sentence(length)
|
@@ -104,7 +106,7 @@ module RandomWords
|
|
104
106
|
end
|
105
107
|
|
106
108
|
def random_paragraphs
|
107
|
-
|
109
|
+
header1('Random Paragraphs')
|
108
110
|
@sentence_generator.lengths.keys.each_with_index do |length, index|
|
109
111
|
@sentence_generator.source = @sources[index]
|
110
112
|
paragraphs(length, 3)
|
@@ -118,9 +120,9 @@ module RandomWords
|
|
118
120
|
number_of_words << (((i * i) * 5) + 10)
|
119
121
|
end
|
120
122
|
|
121
|
-
|
123
|
+
header1("#{number_of_words} Random Words")
|
122
124
|
@sources.each_with_index do |source, index|
|
123
|
-
|
125
|
+
header2("#{number_of_words[index]} Random Words")
|
124
126
|
@sentence_generator.source = source
|
125
127
|
s = @sentence_generator.words(number_of_words[index])
|
126
128
|
puts "#{marker} #{text(s)} "
|
@@ -130,7 +132,7 @@ module RandomWords
|
|
130
132
|
|
131
133
|
# Generate and print specified number of characters
|
132
134
|
def random_characters
|
133
|
-
|
135
|
+
header1('Random Characters (exact length)')
|
134
136
|
[20, 50, 120, 200, 500].each_with_index do |i, index|
|
135
137
|
@sentence_generator.source = @sources[index]
|
136
138
|
chars = @sentence_generator.characters(i, whole_words: true)
|
@@ -141,7 +143,7 @@ module RandomWords
|
|
141
143
|
max_characters = [15, 25, 53, 110, 600]
|
142
144
|
min_characters = [10, 20, 50, 100, 500]
|
143
145
|
|
144
|
-
|
146
|
+
header1('Random Characters (length range)')
|
145
147
|
max_characters.count.times do |i|
|
146
148
|
@sentence_generator.source = @sources[i]
|
147
149
|
chars = @sentence_generator.characters(min_characters[i], max_characters[i], whole_words: true)
|
@@ -160,14 +162,14 @@ module RandomWords
|
|
160
162
|
|
161
163
|
def language
|
162
164
|
"#{colorize_text('(',
|
163
|
-
@colors[:bracket])}#{colorize_text(
|
165
|
+
@colors[:bracket])}#{colorize_text(@sentence_generator.source,
|
164
166
|
@colors[:language])}#{colorize_text(')',
|
165
167
|
@colors[:bracket])}"
|
166
168
|
end
|
167
169
|
|
168
170
|
def counter(length)
|
169
171
|
"#{colorize_text('[',
|
170
|
-
@colors[:bracket])}#{colorize_text(
|
172
|
+
@colors[:bracket])}#{colorize_text(length.to_s,
|
171
173
|
@colors[:counter])}#{colorize_text(']',
|
172
174
|
@colors[:bracket])} #{language}"
|
173
175
|
end
|
data/lib/random-words/version.rb
CHANGED
@@ -0,0 +1,139 @@
|
|
1
|
+
absurd
|
2
|
+
aggressive
|
3
|
+
aloof
|
4
|
+
ambitious
|
5
|
+
anxious
|
6
|
+
artistic
|
7
|
+
assertive
|
8
|
+
astute
|
9
|
+
authentic
|
10
|
+
awkward
|
11
|
+
bold
|
12
|
+
brave
|
13
|
+
brilliant
|
14
|
+
calm
|
15
|
+
candid
|
16
|
+
captivating
|
17
|
+
chaotic
|
18
|
+
charming
|
19
|
+
clever
|
20
|
+
cold
|
21
|
+
compelling
|
22
|
+
confident
|
23
|
+
conventional
|
24
|
+
corrupt
|
25
|
+
courageous
|
26
|
+
creative
|
27
|
+
curious
|
28
|
+
dangerous
|
29
|
+
dark
|
30
|
+
decisive
|
31
|
+
deceptive
|
32
|
+
delicate
|
33
|
+
demanding
|
34
|
+
desperate
|
35
|
+
difficult
|
36
|
+
diverse
|
37
|
+
dramatic
|
38
|
+
dynamic
|
39
|
+
eccentric
|
40
|
+
empathetic
|
41
|
+
enigmatic
|
42
|
+
enthusiastic
|
43
|
+
epic
|
44
|
+
erratic
|
45
|
+
exciting
|
46
|
+
exotic
|
47
|
+
expressive
|
48
|
+
fearless
|
49
|
+
fiery
|
50
|
+
fragile
|
51
|
+
funny
|
52
|
+
generous
|
53
|
+
genuine
|
54
|
+
graceful
|
55
|
+
gritty
|
56
|
+
hardcore
|
57
|
+
harmonious
|
58
|
+
harsh
|
59
|
+
honest
|
60
|
+
hopeful
|
61
|
+
humorous
|
62
|
+
imaginative
|
63
|
+
impulsive
|
64
|
+
incredible
|
65
|
+
independent
|
66
|
+
intense
|
67
|
+
intriguing
|
68
|
+
ironic
|
69
|
+
jovial
|
70
|
+
keen
|
71
|
+
laid-back
|
72
|
+
lavish
|
73
|
+
legendary
|
74
|
+
logical
|
75
|
+
lovable
|
76
|
+
loyal
|
77
|
+
luminous
|
78
|
+
magnificent
|
79
|
+
manipulative
|
80
|
+
mature
|
81
|
+
meaningful
|
82
|
+
mellow
|
83
|
+
meticulous
|
84
|
+
mischievous
|
85
|
+
mysterious
|
86
|
+
naive
|
87
|
+
nervous
|
88
|
+
noble
|
89
|
+
obscure
|
90
|
+
optimistic
|
91
|
+
outlandish
|
92
|
+
passionate
|
93
|
+
patient
|
94
|
+
peculiar
|
95
|
+
playful
|
96
|
+
poignant
|
97
|
+
polarizing
|
98
|
+
powerful
|
99
|
+
prescient
|
100
|
+
provocative
|
101
|
+
quirky
|
102
|
+
radiant
|
103
|
+
raw
|
104
|
+
realistic
|
105
|
+
rebellious
|
106
|
+
refined
|
107
|
+
relentless
|
108
|
+
remarkable
|
109
|
+
resilient
|
110
|
+
resourceful
|
111
|
+
respectful
|
112
|
+
restless
|
113
|
+
risky
|
114
|
+
romantic
|
115
|
+
sardonic
|
116
|
+
satirical
|
117
|
+
sincere
|
118
|
+
skilled
|
119
|
+
sophisticated
|
120
|
+
spontaneous
|
121
|
+
strange
|
122
|
+
subtle
|
123
|
+
surreal
|
124
|
+
tactful
|
125
|
+
tense
|
126
|
+
thoughtful
|
127
|
+
turbulent
|
128
|
+
unconventional
|
129
|
+
unique
|
130
|
+
unsettling
|
131
|
+
unstable
|
132
|
+
vibrant
|
133
|
+
vivid
|
134
|
+
vulnerable
|
135
|
+
witty
|
136
|
+
xenophobic
|
137
|
+
youthful
|
138
|
+
zealous
|
139
|
+
zany
|