random-words 1.0.16 → 1.0.17
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/CHANGELOG.md +8 -0
- data/bin/randw +6 -6
- data/lib/random-words/lorem-markdown.rb +0 -0
- data/lib/random-words/lorem_html.rb +7 -5
- data/lib/random-words/string.rb +6 -0
- data/lib/random-words/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb7dd16845d6ce75d9f10a8e5005636cf13e4060965273bf305ce34980975d95
|
4
|
+
data.tar.gz: ff992ec57cc8cddcad1fa016a25929ecbc5c4d124601e6873f9f5e634c503be3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac1670432a510e98b3b91bca1fdcc0eb7aefa58a9d0b98b50e28a8e0d4848e93866fcc9b2f9e7c6347a66ef4bb579904db3bc71424be9baf47fcda64c4375543
|
7
|
+
data.tar.gz: 61b5b0d50ca33fe03da311c69e63f318fb0585c35cb6b3a39185a3c4c149b63f2c92d5ccaecd83db86b669cb7ac3693d50e0fd596ff09fbd095ad5e526857059
|
data/CHANGELOG.md
CHANGED
data/bin/randw
CHANGED
@@ -288,7 +288,7 @@ when :sentences
|
|
288
288
|
s = @rw.sentences(@options[:count]).join(" ")
|
289
289
|
total[:words] += s.split(/ /).count
|
290
290
|
total[:characters] += s.length
|
291
|
-
print s
|
291
|
+
print s.clean_output
|
292
292
|
debug "#{s.split(/ /).count}w, #{s.length}c"
|
293
293
|
# end
|
294
294
|
debug "Total: #{total[:sentences]}s, #{total[:words]}w, #{total[:characters]}c"
|
@@ -303,18 +303,18 @@ when :paragraphs
|
|
303
303
|
total[:sentences] += p.scan(/[?.!]/).count
|
304
304
|
total[:words] += p.split(/ /).count
|
305
305
|
total[:characters] += p.length
|
306
|
-
print p
|
306
|
+
print p.clean_output
|
307
307
|
debug "#{p.scan(/[?.!]/).count}s, #{p.split(/ /).count}w, #{p.length}c"
|
308
308
|
puts "\n\n"
|
309
309
|
end
|
310
310
|
debug "Total: #{total[:sentences]}s, #{total[:words]}w, #{total[:characters]}c"
|
311
311
|
when :words
|
312
312
|
w = @rw.words(@options[:count])
|
313
|
-
print w
|
313
|
+
print w.clean_output
|
314
314
|
debug "#{w.split(/ /).count}w, #{w.length}c"
|
315
315
|
when :characters
|
316
316
|
c = @rw.characters(@options[:count], whitespace: @options[:whitespace])
|
317
|
-
print c
|
317
|
+
print c.clean_output
|
318
318
|
debug "#{c.split(/ /).count}w, #{c.length}c"
|
319
319
|
when :markdown, :html
|
320
320
|
settings = markdown_settings(@options[:markdown_settings])
|
@@ -326,9 +326,9 @@ when :markdown, :html
|
|
326
326
|
settings[:extended] = @rw.use_extended_punctuation
|
327
327
|
|
328
328
|
if @options[:method] == :markdown
|
329
|
-
puts @rw.markdown(settings)
|
329
|
+
puts @rw.markdown(settings).clean_output
|
330
330
|
else
|
331
|
-
puts @rw.html(settings)
|
331
|
+
puts @rw.html(settings).clean_output
|
332
332
|
end
|
333
333
|
when :password
|
334
334
|
p = @rw.characters(20, whitespace: @options[:whitespace], article: false)
|
File without changes
|
@@ -124,8 +124,8 @@ module RandomWords
|
|
124
124
|
items = { short: 4, medium: 8, long: 10, very_long: 12 }[@options[:length]]
|
125
125
|
|
126
126
|
if @options[:ul] && @options[:ol]
|
127
|
-
inject_block(1, -> { list(items, :ul) })
|
128
|
-
inject_block(1, -> { list(items, :ol) })
|
127
|
+
inject_block(1, -> { list(items, :ul, rule: true) })
|
128
|
+
inject_block(1, -> { list(items, :ol, rule: true) })
|
129
129
|
elsif @options[:ul]
|
130
130
|
inject_block(2, -> { list(items, :ul) })
|
131
131
|
elsif @options[:ol]
|
@@ -189,9 +189,10 @@ module RandomWords
|
|
189
189
|
# Generates a list of items.
|
190
190
|
# @param [Integer] count The number of items to generate.
|
191
191
|
# @param [Symbol] type The type of list to generate (:ul, :ol, :dl).
|
192
|
+
# @param [Boolean] hr whether to add a horizontal rule after list
|
192
193
|
#
|
193
194
|
# @return [String] The generated list.
|
194
|
-
def list(count, type)
|
195
|
+
def list(count, type, rule: false)
|
195
196
|
ul = "\n\n<#{type}>\n"
|
196
197
|
|
197
198
|
count.times do
|
@@ -217,7 +218,9 @@ module RandomWords
|
|
217
218
|
ul += "\t<li>#{long_frag}</li>\n"
|
218
219
|
end
|
219
220
|
end
|
220
|
-
ul
|
221
|
+
ul += "</#{type}>\n\n"
|
222
|
+
ul += "<hr>\n\n" if rule
|
223
|
+
ul
|
221
224
|
end
|
222
225
|
|
223
226
|
# Generates a blockquote.
|
@@ -376,7 +379,6 @@ module RandomWords
|
|
376
379
|
|
377
380
|
@output = "#{grafs.slice!(0, len).join("\n\n")}\n\n"
|
378
381
|
|
379
|
-
# count = { short: 4, medium: 8, long: 10, very_long: 12 }[@options[:length]]
|
380
382
|
@output += block.call
|
381
383
|
added = 1
|
382
384
|
while grafs.any?
|
data/lib/random-words/string.rb
CHANGED
@@ -236,6 +236,8 @@ module RandomWords
|
|
236
236
|
new_source = nil
|
237
237
|
sources = RandomWords::Generator.new.sources
|
238
238
|
|
239
|
+
return sources.map { |k, v| v.name }.sample if /^(random|any)$/i.match?(self)
|
240
|
+
|
239
241
|
sources.each do |_k, v|
|
240
242
|
v.names.each do |name|
|
241
243
|
next unless /^#{self}/i.match?(name.to_s)
|
@@ -355,5 +357,9 @@ module RandomWords
|
|
355
357
|
/\A[aeiou]/i.match?(word) ? "an #{word}" : "a #{word}"
|
356
358
|
end
|
357
359
|
end
|
360
|
+
|
361
|
+
def clean_output
|
362
|
+
encode('iso-8859-1', undef: :replace, invalid: :replace, replace: '').force_encoding('UTF-8')
|
363
|
+
end
|
358
364
|
end
|
359
365
|
end
|
data/lib/random-words/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: random-words
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/random-words/generator.rb
|
74
74
|
- lib/random-words/hash.rb
|
75
75
|
- lib/random-words/html2markdown.rb
|
76
|
+
- lib/random-words/lorem-markdown.rb
|
76
77
|
- lib/random-words/lorem_html.rb
|
77
78
|
- lib/random-words/number_to_word.rb
|
78
79
|
- lib/random-words/numeric.rb
|