random-words 1.0.11 → 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 +267 -20
- data/.rubocop_todo.yml +0 -313
- data/CHANGELOG.md +36 -0
- data/bin/randw +54 -194
- 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 +60 -32
- data/lib/random-words/html2markdown.rb +80 -20
- data/lib/random-words/{lorem-markdown.rb → lorem_html.rb} +123 -56
- 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 +185 -0
- data/lib/random-words/version.rb +1 -1
- data/lib/random-words/words/corporate/clauses.txt +100 -100
- 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 +3 -2
- metadata +24 -4
data/bin/randw
CHANGED
@@ -4,188 +4,6 @@
|
|
4
4
|
require_relative "../lib/random-words"
|
5
5
|
require "optparse"
|
6
6
|
|
7
|
-
module RandomWords
|
8
|
-
# Terminal methods for testing
|
9
|
-
class Terminal
|
10
|
-
def initialize(source = :english)
|
11
|
-
# Create an instance of the generator
|
12
|
-
@sentence_generator = RandomWords::Generator.new(source)
|
13
|
-
@sentence_generator.use_extended_punctuation = true
|
14
|
-
@colors = {
|
15
|
-
text: :yellow,
|
16
|
-
counter: :boldcyan,
|
17
|
-
marker: :boldgreen,
|
18
|
-
bracket: :cyan,
|
19
|
-
language: :boldmagenta,
|
20
|
-
}
|
21
|
-
@sources = @sentence_generator.sources.keys.map(&:to_s)
|
22
|
-
end
|
23
|
-
|
24
|
-
def colors
|
25
|
-
{
|
26
|
-
black: 30,
|
27
|
-
red: 31,
|
28
|
-
green: 32,
|
29
|
-
yellow: 33,
|
30
|
-
blue: 34,
|
31
|
-
magenta: 35,
|
32
|
-
cyan: 36,
|
33
|
-
white: 37,
|
34
|
-
boldblack: "1;30",
|
35
|
-
boldred: "1;31",
|
36
|
-
boldgreen: "1;32",
|
37
|
-
boldyellow: "1;33",
|
38
|
-
boldblue: "1;34",
|
39
|
-
boldmagenta: "1;35",
|
40
|
-
boldcyan: "1;36",
|
41
|
-
boldwhite: "1;37",
|
42
|
-
reset: 0,
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
def colorize_text(text, color)
|
47
|
-
return text unless $stdout.isatty
|
48
|
-
|
49
|
-
return text unless colors.key?(color)
|
50
|
-
|
51
|
-
color_code = colors[color]
|
52
|
-
|
53
|
-
"\e[#{color_code}m#{text}\e[0m"
|
54
|
-
end
|
55
|
-
|
56
|
-
def header_1(text)
|
57
|
-
puts colorize_text("\n\n#{text}", :boldgreen)
|
58
|
-
puts colorize_text("=" * text.length, :boldgreen)
|
59
|
-
puts "\n"
|
60
|
-
end
|
61
|
-
|
62
|
-
def header_2(text)
|
63
|
-
puts colorize_text("\n\n#{text}", :boldyellow)
|
64
|
-
puts colorize_text("-" * text.length, :boldyellow)
|
65
|
-
puts "\n"
|
66
|
-
end
|
67
|
-
|
68
|
-
def paragraphs(length, count = 3)
|
69
|
-
@sentence_generator.sentence_length = length
|
70
|
-
@sentence_generator.paragraph_length = count
|
71
|
-
@sentence_generator.source = @sources.sample
|
72
|
-
|
73
|
-
header_2("Random Paragraph (#{@sentence_generator.paragraph_length} #{@sentence_generator.sentence_length} sentences)")
|
74
|
-
graf = @sentence_generator.paragraph
|
75
|
-
puts text(graf)
|
76
|
-
puts counter("#{graf.split(/ /).count} words, #{graf.length} characters")
|
77
|
-
end
|
78
|
-
|
79
|
-
def sentence(length)
|
80
|
-
header_2("Random #{length} sentence")
|
81
|
-
@sentence_generator.sentence_length = length
|
82
|
-
s = @sentence_generator.sentence
|
83
|
-
puts text(s)
|
84
|
-
puts counter("#{s.split(/ /).count} words, #{s.length} characters")
|
85
|
-
end
|
86
|
-
|
87
|
-
# Generate and print random combined sentences
|
88
|
-
def combined_sentences(length = nil)
|
89
|
-
number_of_sentences = length || 2
|
90
|
-
|
91
|
-
header_1("Random Combined Sentences:")
|
92
|
-
@sources.count.times do |i|
|
93
|
-
@sentence_generator.source = @sources[i - 1]
|
94
|
-
@sentence_generator.sentence_length = :medium
|
95
|
-
@sentence_generator.paragraph_length = number_of_sentences
|
96
|
-
@sentence_generator.sentences(number_of_sentences)
|
97
|
-
s = @sentence_generator.sentence
|
98
|
-
puts "#{marker} #{text(s)}"
|
99
|
-
puts counter("#{s.split(/ /).count} words, #{s.length} characters")
|
100
|
-
puts colorize_text(" " * 2, :boldwhite)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def random_sentences
|
105
|
-
header_1("Random Sentences")
|
106
|
-
@sentence_generator.lengths.keys.each_with_index do |length, index|
|
107
|
-
@sentence_generator.source = @sources[index]
|
108
|
-
sentence(length)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def random_paragraphs
|
113
|
-
header_1("Random Paragraphs")
|
114
|
-
@sentence_generator.lengths.keys.each_with_index do |length, index|
|
115
|
-
@sentence_generator.source = @sources[index]
|
116
|
-
paragraphs(length, 3)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
# Generate and print specified number of words
|
121
|
-
def random_words
|
122
|
-
number_of_words = []
|
123
|
-
@sources.count.times do |i|
|
124
|
-
puts i
|
125
|
-
number_of_words << (i * i) * 5 + 10
|
126
|
-
end
|
127
|
-
|
128
|
-
header_1("#{number_of_words} Random Words")
|
129
|
-
@sources.each_with_index do |source, index|
|
130
|
-
header_2("#{number_of_words[index]} Random Words")
|
131
|
-
@sentence_generator.source = source
|
132
|
-
s = @sentence_generator.words(number_of_words[index])
|
133
|
-
puts "#{marker} #{text(s)} "
|
134
|
-
puts counter("#{s.split(/ /).count} words, #{s.length} characters")
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
# Generate and print specified number of characters
|
139
|
-
def random_characters
|
140
|
-
header_1("Random Characters (exact length)")
|
141
|
-
[20, 50, 120, 200, 500].each_with_index do |i, index|
|
142
|
-
@sentence_generator.source = @sources[index]
|
143
|
-
chars = @sentence_generator.characters(i, whole_words: true)
|
144
|
-
puts "#{marker} #{colorize_text("#{i}:", :boldwhite)} #{text(chars)} #{counter(chars.length)}"
|
145
|
-
end
|
146
|
-
|
147
|
-
# Generate and print specified number of characters
|
148
|
-
max_characters = [15, 25, 53, 110, 600]
|
149
|
-
min_characters = [10, 20, 50, 100, 500]
|
150
|
-
|
151
|
-
header_1("Random Characters (length range)")
|
152
|
-
max_characters.count.times do |i|
|
153
|
-
@sentence_generator.source = @sources[i]
|
154
|
-
chars = @sentence_generator.characters(min_characters[i], max_characters[i], whole_words: true)
|
155
|
-
range = "#{marker} #{colorize_text("[#{min_characters[i]}-#{max_characters[i]}]: ", :boldwhite)}"
|
156
|
-
puts "#{range}#{text(chars)} #{counter(chars.length)}"
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
def marker
|
161
|
-
colorize_text("•", @colors[:marker])
|
162
|
-
end
|
163
|
-
|
164
|
-
def text(text)
|
165
|
-
colorize_text(text, @colors[:text])
|
166
|
-
end
|
167
|
-
|
168
|
-
def language
|
169
|
-
"#{colorize_text("(",
|
170
|
-
@colors[:bracket])}#{colorize_text("#{@sentence_generator.source}", @colors[:language])}#{colorize_text(")",
|
171
|
-
@colors[:bracket])}"
|
172
|
-
end
|
173
|
-
|
174
|
-
def counter(length)
|
175
|
-
"#{colorize_text("[",
|
176
|
-
@colors[:bracket])}#{colorize_text("#{length}", @colors[:counter])}#{colorize_text("]", @colors[:bracket])} #{language}"
|
177
|
-
end
|
178
|
-
|
179
|
-
def print_test
|
180
|
-
combined_sentences(3)
|
181
|
-
random_sentences
|
182
|
-
random_paragraphs
|
183
|
-
random_words
|
184
|
-
random_characters
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
7
|
# Default options for the script
|
190
8
|
|
191
9
|
@options = {
|
@@ -210,7 +28,11 @@ markdown_help = <<HELP
|
|
210
28
|
mark: add ==highlights==
|
211
29
|
headers: add headlines
|
212
30
|
image: add images
|
31
|
+
hr: add horizontal rules
|
213
32
|
table: add tables
|
33
|
+
fn: add footnotes
|
34
|
+
complete: complete HTML output
|
35
|
+
meta:[mmd|yaml]: add metadata header
|
214
36
|
HELP
|
215
37
|
|
216
38
|
OptionParser.new do |opts|
|
@@ -333,7 +155,7 @@ OptionParser.new do |opts|
|
|
333
155
|
end.parse!
|
334
156
|
|
335
157
|
def debug(msg)
|
336
|
-
return unless @options[:debug]
|
158
|
+
return unless @options[:debug] && @options[:debug_level]&.positive?
|
337
159
|
|
338
160
|
# length = msg.length
|
339
161
|
# message = RandomWords::Terminal.new.colorize_text(msg, :boldblack)
|
@@ -361,13 +183,18 @@ def markdown_settings(settings)
|
|
361
183
|
mark: false,
|
362
184
|
headers: false,
|
363
185
|
table: false,
|
364
|
-
extended: false
|
186
|
+
extended: false,
|
187
|
+
footnote: false,
|
188
|
+
hr: false,
|
189
|
+
meta_type: nil,
|
190
|
+
complete: false,
|
191
|
+
style: "style.css"
|
365
192
|
}
|
366
193
|
sources = []
|
367
194
|
RandomWords::Generator.new(:latin).sources.each { |k, v| sources.concat(v.names.map(&:to_s)) }
|
368
195
|
|
369
196
|
markdown_options = defaults.dup
|
370
|
-
settings = settings.split(%r{[
|
197
|
+
settings = settings.split(%r{[,/\|]}).map(&:strip)
|
371
198
|
|
372
199
|
settings.each do |setting|
|
373
200
|
case setting
|
@@ -384,7 +211,9 @@ def markdown_settings(settings)
|
|
384
211
|
headers: true,
|
385
212
|
image: true,
|
386
213
|
table: true,
|
387
|
-
extended: true
|
214
|
+
extended: true,
|
215
|
+
footnote: true,
|
216
|
+
hr: true
|
388
217
|
}
|
389
218
|
markdown_options.merge!(new_options)
|
390
219
|
when Regexp.union(sources)
|
@@ -415,6 +244,23 @@ def markdown_settings(settings)
|
|
415
244
|
markdown_options[:length] = setting.to_length
|
416
245
|
when 'x', 'extended'
|
417
246
|
markdown_options[:extended] = true
|
247
|
+
when 'fn', 'footnotes'
|
248
|
+
markdown_options[:footnote] = true
|
249
|
+
when 'img', 'image'
|
250
|
+
markdown_options[:image] = true
|
251
|
+
when 'hr'
|
252
|
+
markdown_options[:hr] = true
|
253
|
+
when 'comp', 'complete'
|
254
|
+
markdown_options[:complete] = true
|
255
|
+
when /^(style|css):(.*)$/i
|
256
|
+
markdown_options[:style] = Regexp.last_match(2)
|
257
|
+
when /^meta:(.*?)$/i
|
258
|
+
case Regexp.last_match(1)
|
259
|
+
when 'mmd', 'multimarkdown'
|
260
|
+
markdown_options[:meta_type] = :multimarkdown
|
261
|
+
when 'yaml'
|
262
|
+
markdown_options[:meta_type] = :yaml
|
263
|
+
end
|
418
264
|
else
|
419
265
|
markdown_options[:source] = setting.to_source
|
420
266
|
end
|
@@ -485,23 +331,36 @@ when :markdown, :html
|
|
485
331
|
puts @rw.html(settings)
|
486
332
|
end
|
487
333
|
when :password
|
488
|
-
p = @rw.characters(20, whitespace: @options[:whitespace])
|
334
|
+
p = @rw.characters(20, whitespace: @options[:whitespace], article: false)
|
489
335
|
|
490
|
-
m = p.match(/[
|
336
|
+
m = p.match(/[olzeasbtg]/i)
|
491
337
|
if m
|
492
338
|
num_char = m.begin(0)
|
493
|
-
char = m[0].tr("
|
339
|
+
char = m[0].tr("olzeasbtbg", "0123456789")
|
494
340
|
else
|
495
341
|
num_char = p.length
|
496
|
-
char = rand(
|
342
|
+
char = rand(9).to_s
|
497
343
|
end
|
498
344
|
p[num_char] = char
|
499
345
|
|
500
|
-
|
501
|
-
|
346
|
+
m = p.match(/[hcigatsbp]/i)
|
347
|
+
if m
|
348
|
+
sp_char = m.begin(0)
|
349
|
+
char = m[0].tr("hcigatsbp", "#<!&@+$>?")
|
350
|
+
end
|
351
|
+
p[sp_char] = char
|
352
|
+
|
353
|
+
cap_char = rand(19)
|
354
|
+
cap_char = rand(19) while p[cap_char] !~ /[a-z]/
|
502
355
|
p[cap_char] = p[cap_char].upcase
|
503
356
|
|
504
|
-
|
357
|
+
special = %w[! @ # $ % ^ & * ( ) _ + - = ; : < > , . ? /]
|
358
|
+
|
359
|
+
tail_char = if special.include?(@options[:separator]) || p =~ /#{Regexp.union(special)}/
|
360
|
+
''
|
361
|
+
else
|
362
|
+
/[^a-z0-9 ]/i.match?(p) ? "" : special.sample
|
363
|
+
end
|
505
364
|
|
506
365
|
print p.gsub(/ /, @options[:separator]) + tail_char
|
507
366
|
debug "#{p.split(@options[:separator]).count}w, #{p.length}c"
|
@@ -509,5 +368,6 @@ when :test
|
|
509
368
|
t = RandomWords::Terminal.new(@options[:source])
|
510
369
|
t.print_test
|
511
370
|
else
|
512
|
-
puts "Please specify a valid method:
|
371
|
+
puts "Please specify a valid method: "
|
372
|
+
puts "sentences, paragraphs, words, characters, password, markdown, html"
|
513
373
|
end
|
data/generator.cgi
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'cgi'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'random-words'
|
9
|
+
|
10
|
+
# Main script execution
|
11
|
+
|
12
|
+
if __FILE__ == $PROGRAM_NAME
|
13
|
+
def param?(param)
|
14
|
+
# Returns true if the parameter is present.
|
15
|
+
@params.key?(param) && @params[param][0].trueish?
|
16
|
+
end
|
17
|
+
|
18
|
+
def markdown_settings(settings)
|
19
|
+
base_config = RandomWords::Config.new(:latin).config
|
20
|
+
|
21
|
+
defaults = {
|
22
|
+
source: base_config[:source].is_a?(String) ? base_config[:source].to_source : base_config[:source],
|
23
|
+
grafs: 10,
|
24
|
+
sentences: base_config[:paragraph_length],
|
25
|
+
length: base_config[:sentence_length],
|
26
|
+
decorate: false,
|
27
|
+
link: false,
|
28
|
+
ul: false,
|
29
|
+
ol: false,
|
30
|
+
dl: false,
|
31
|
+
bq: false,
|
32
|
+
code: false,
|
33
|
+
mark: false,
|
34
|
+
headers: false,
|
35
|
+
table: false,
|
36
|
+
extended: false,
|
37
|
+
footnote: false,
|
38
|
+
hr: false,
|
39
|
+
meta_type: nil,
|
40
|
+
complete: false,
|
41
|
+
style: 'style.css'
|
42
|
+
}
|
43
|
+
sources = []
|
44
|
+
RandomWords::Generator.new(:latin).sources.each { |k, v| sources.concat(v.names.map(&:to_s)) }
|
45
|
+
|
46
|
+
markdown_options = defaults.dup
|
47
|
+
settings = settings.split(%r{[,/\|]}).map(&:strip)
|
48
|
+
|
49
|
+
settings.each do |setting|
|
50
|
+
case setting
|
51
|
+
when /^all$/
|
52
|
+
new_options = {
|
53
|
+
decorate: true,
|
54
|
+
link: true,
|
55
|
+
ul: true,
|
56
|
+
ol: true,
|
57
|
+
dl: true,
|
58
|
+
bq: true,
|
59
|
+
code: true,
|
60
|
+
mark: true,
|
61
|
+
headers: true,
|
62
|
+
image: true,
|
63
|
+
table: true,
|
64
|
+
extended: true,
|
65
|
+
footnote: true,
|
66
|
+
hr: true
|
67
|
+
}
|
68
|
+
markdown_options.merge!(new_options)
|
69
|
+
when Regexp.union(sources)
|
70
|
+
markdown_options[:source] = setting.to_source
|
71
|
+
when /^\d+$/
|
72
|
+
markdown_options[:grafs] = setting.to_i
|
73
|
+
when 'dec', 'decorate'
|
74
|
+
markdown_options[:decorate] = true
|
75
|
+
when 'link'
|
76
|
+
markdown_options[:link] = true
|
77
|
+
when 'ul'
|
78
|
+
markdown_options[:ul] = true
|
79
|
+
when 'ol'
|
80
|
+
markdown_options[:ol] = true
|
81
|
+
when 'dl'
|
82
|
+
markdown_options[:dl] = true
|
83
|
+
when 'bq', 'blockquote'
|
84
|
+
markdown_options[:bq] = true
|
85
|
+
when 'code'
|
86
|
+
markdown_options[:code] = true
|
87
|
+
when 'mark'
|
88
|
+
markdown_options[:mark] = true
|
89
|
+
when 'header', 'h'
|
90
|
+
markdown_options[:headers] = true
|
91
|
+
when 'table', 't'
|
92
|
+
markdown_options[:table] = true
|
93
|
+
when 'short', 's', 'medium', 'med', 'm', 'long', 'l', 'very_long', 'vl'
|
94
|
+
markdown_options[:length] = setting.to_length
|
95
|
+
when 'x', 'extended'
|
96
|
+
markdown_options[:extended] = true
|
97
|
+
when 'fn', 'footnotes'
|
98
|
+
markdown_options[:footnote] = true
|
99
|
+
when 'img', 'image'
|
100
|
+
markdown_options[:image] = true
|
101
|
+
when 'hr'
|
102
|
+
markdown_options[:hr] = true
|
103
|
+
when 'comp', 'complete'
|
104
|
+
markdown_options[:complete] = true
|
105
|
+
when /^(style|css):(.*)$/i
|
106
|
+
markdown_options[:style] = Regexp.last_match(2)
|
107
|
+
when /^meta:(.*?)$/i
|
108
|
+
case Regexp.last_match(1)
|
109
|
+
when 'mmd', 'multimarkdown'
|
110
|
+
markdown_options[:meta_type] = :multimarkdown
|
111
|
+
when 'yaml'
|
112
|
+
markdown_options[:meta_type] = :yaml
|
113
|
+
end
|
114
|
+
else
|
115
|
+
markdown_options[:source] = setting.to_source
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
markdown_options
|
120
|
+
end
|
121
|
+
|
122
|
+
cgi = CGI.new
|
123
|
+
args = ENV.fetch('REQUEST_URI', nil)
|
124
|
+
args = args.sub(%r{^/md-lipsum/api/4}, '') unless args.nil?
|
125
|
+
args = 'all' if args.nil?
|
126
|
+
|
127
|
+
settings = markdown_settings(args)
|
128
|
+
@rw.source = settings[:source]
|
129
|
+
@rw.sentence_length = settings[:length] || :medium
|
130
|
+
@rw.paragraph_length = settings[:sentences] || 5
|
131
|
+
|
132
|
+
@rw.use_extended_punctuation = settings[:extended] ? true : false
|
133
|
+
settings[:extended] = @rw.use_extended_punctuation
|
134
|
+
|
135
|
+
@params = cgi.params
|
136
|
+
settings[:complete] = true if param?('complete')
|
137
|
+
settings[:style] = @params['style'][0] if @params.key?('style')
|
138
|
+
# credit = "\n\n<!-- Generated by [md-lipsum](https://brettterpstra.com/md-lipsum/) -->\n"
|
139
|
+
|
140
|
+
settings[:source] = @params['source'][0].to_source if @params.key?('source')
|
141
|
+
|
142
|
+
if param?('html') || param?('preview') || param?('complete')
|
143
|
+
if param?('preview')
|
144
|
+
print cgi.header('type' => 'text/html', 'expires' => Time.now - 180)
|
145
|
+
puts @rw.html(settings)
|
146
|
+
else
|
147
|
+
print cgi.header('type' => 'text/plain', 'expires' => Time.now - 180)
|
148
|
+
puts @rw.html(settings)
|
149
|
+
end
|
150
|
+
else
|
151
|
+
print cgi.header('type' => 'text/plain', 'expires' => Time.now - 180)
|
152
|
+
|
153
|
+
puts @rw.markdown(settings)
|
154
|
+
end
|
155
|
+
end
|
data/lib/random-words/array.rb
CHANGED
data/lib/random-words/boolean.rb
CHANGED
data/lib/random-words/config.rb
CHANGED
@@ -34,9 +34,6 @@ module RandomWords
|
|
34
34
|
# Source directory for languages
|
35
35
|
attr_reader :source_dir
|
36
36
|
|
37
|
-
# Base config
|
38
|
-
attr_reader :config
|
39
|
-
|
40
37
|
# Initialize the config with the given language
|
41
38
|
# @param lang [Symbol] The language to use
|
42
39
|
# @raise [RuntimeError] if no dictionary is found for the given language
|
@@ -117,7 +114,9 @@ module RandomWords
|
|
117
114
|
# @return [Symbol, nil] The language symbol if successful, nil otherwise
|
118
115
|
def create_user_dictionary(lang = nil)
|
119
116
|
return lang.to_sym if File.directory?(File.join(config_dir, 'words',
|
120
|
-
lang)) && all_parts_of_speech?(
|
117
|
+
lang)) && all_parts_of_speech?(
|
118
|
+
File.join(config_dir, 'words', lang), lang
|
119
|
+
)
|
121
120
|
|
122
121
|
lang_dir = File.join(config_dir, 'words', lang)
|
123
122
|
|
@@ -153,7 +152,8 @@ module RandomWords
|
|
153
152
|
warn "Created #{target_file}"
|
154
153
|
end
|
155
154
|
|
156
|
-
unless all_parts_of_speech?(lang_dir,
|
155
|
+
unless all_parts_of_speech?(lang_dir,
|
156
|
+
lang) || (RandomWords.testing && !RandomWords.tested.include?('create_user_dictionary'))
|
157
157
|
return
|
158
158
|
end
|
159
159
|
|
@@ -212,7 +212,7 @@ module RandomWords
|
|
212
212
|
source: configuration[:source].to_source || :latin,
|
213
213
|
sentence_length: configuration[:length].to_length || :medium,
|
214
214
|
paragraph_length: configuration[:paragraph_length].to_i || 5,
|
215
|
-
use_extended_punctuation:
|
215
|
+
use_extended_punctuation: ext_punc&.trueish? || false
|
216
216
|
}
|
217
217
|
end
|
218
218
|
|