random-words 1.0.8 → 1.0.10
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/.rspec +0 -1
- data/CHANGELOG.md +30 -0
- data/LICENSE +19 -0
- data/README.md +21 -13
- data/bin/randw +20 -7
- data/lib/random-words/array.rb +9 -0
- data/lib/random-words/boolean.rb +60 -0
- data/lib/random-words/config.rb +8 -2
- data/lib/random-words/generator.rb +89 -46
- data/lib/random-words/lorem-markdown.rb +20 -3
- data/lib/random-words/number-to-word.rb +4 -4
- data/lib/random-words/numeric.rb +13 -0
- data/lib/random-words/string.rb +112 -13
- data/lib/random-words/version.rb +1 -1
- data/lib/random-words/words/1984/clauses.txt +79 -79
- data/lib/random-words/words/1984/terminators.txt +1 -0
- data/lib/random-words/words/alice/clauses.txt +81 -81
- data/lib/random-words/words/alice/terminators.txt +1 -0
- data/lib/random-words/words/bacon/clauses.txt +639 -639
- data/lib/random-words/words/bacon/terminators.txt +1 -0
- data/lib/random-words/words/corporate/clauses.txt +100 -100
- data/lib/random-words/words/doctor/clauses.txt +83 -83
- data/lib/random-words/words/english/clauses.txt +639 -639
- data/lib/random-words/words/english/conjunctions-subordinate.txt +0 -1
- data/lib/random-words/words/english/terminators.txt +1 -0
- data/lib/random-words/words/foulmouth/clauses.txt +58 -58
- data/lib/random-words/words/hipster/clauses.txt +180 -180
- data/lib/random-words/words/hipster/conjunctions-coordinating.txt +1 -1
- data/lib/random-words/words/hipster/phrases.txt +3 -3
- data/lib/random-words/words/spanish/clauses.txt +74 -74
- data/lib/random-words/words/spanish/config.yml +1 -1
- data/lib/random-words/words/spanish/terminators.txt +0 -3
- data/lib/random-words/words/veggie/clauses.txt +57 -57
- data/lib/random-words.rb +2 -0
- data/src/_README.md +25 -13
- metadata +5 -3
- data/Gemfile.lock +0 -131
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e432bb793efaf4e7187dda39d35ec168077810dad3076d369aa6884952a5693
|
4
|
+
data.tar.gz: 44d83919366580b073691440d200a605efdc07ea6b6f39bab6995d9b57c7cac4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a507d5bb5f3b44c60e06effbfee25487cbb84a30d941aa910b60b413195a534ce4fb75bcb88113ed0714bc38536c0c94f4b5724a61a8031cf2e5b63eb6a0b565
|
7
|
+
data.tar.gz: 242e5627fbee393dfecf0a9297985c66678c1698b5b66b46c634d796cd301fabb35d5dcceec94b9575547eddbb5b966b5561585617418c00e4ea71b29b48c046
|
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
### 1.0.10
|
2
|
+
|
3
|
+
2025-04-22 06:30
|
4
|
+
|
5
|
+
#### NEW
|
6
|
+
|
7
|
+
- Debug mode that shows parts of speech in output
|
8
|
+
|
9
|
+
#### IMPROVED
|
10
|
+
|
11
|
+
- Fix clauses so sentences make more sense
|
12
|
+
- Number to word phrasing
|
13
|
+
- Fixes for spec tests
|
14
|
+
|
15
|
+
### 1.0.9
|
16
|
+
|
17
|
+
2025-04-20 06:34
|
18
|
+
|
19
|
+
#### NEW
|
20
|
+
|
21
|
+
- Random punctuation between clauses
|
22
|
+
|
23
|
+
#### IMPROVED
|
24
|
+
|
25
|
+
- Add espanol as a trigger for spanish (with tilde)
|
26
|
+
|
27
|
+
#### FIXED
|
28
|
+
|
29
|
+
- Better handling of extended puntuation arguments
|
30
|
+
|
1
31
|
### 1.0.8
|
2
32
|
|
3
33
|
2025-04-17 13:37
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
MIT License Copyright (c) 2025 Brett Terpstra
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is furnished
|
8
|
+
to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice (including the next
|
11
|
+
paragraph) shall be included in all copies or substantial portions of the
|
12
|
+
Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
17
|
+
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
18
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
19
|
+
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
|
3
|
-
[](https://rubygems.org/gems/random-words)
|
3
|
+
[](https://rubygems.org/gems/random-words)[](https://opensource.org/licenses/MIT)
|
4
4
|
|
5
5
|
A random text (Lorem Ipsum) generator.
|
6
6
|
|
@@ -17,7 +17,7 @@ you use [Homebrew](https://brew.sh).
|
|
17
17
|
### CLI
|
18
18
|
|
19
19
|
The gem installs a binary `randw`. It can generate random
|
20
|
-
characters, sentences, paragraphs, markdown, html,
|
20
|
+
characters, sentences, paragraphs, markdown, html, and
|
21
21
|
passwords.
|
22
22
|
|
23
23
|
```console
|
@@ -67,7 +67,7 @@ elements to include.
|
|
67
67
|
|
68
68
|
First, the source language (defaults to latin), then the
|
69
69
|
length of paragraphs and tables: e.g. `english/medium`. You
|
70
|
-
can add any digits to determine how many
|
70
|
+
can add any digits to determine how many paragraphs are
|
71
71
|
generated (default 5), e.g. `corporate/medium/10`.
|
72
72
|
|
73
73
|
Then you can add individual elements, or use `/all` to
|
@@ -86,6 +86,7 @@ trigger all elements. The elements available are:
|
|
86
86
|
| headers | add headlines |
|
87
87
|
| image | add images |
|
88
88
|
| table | add tables |
|
89
|
+
| x | add extended punctuation |
|
89
90
|
|
90
91
|
The number of elements inserted depends on the length you specify.
|
91
92
|
|
@@ -167,6 +168,7 @@ YAML configuration. It contains the keys:
|
|
167
168
|
name: english
|
168
169
|
description: English words
|
169
170
|
triggers: [english]
|
171
|
+
extended_punctuation: false
|
170
172
|
```
|
171
173
|
|
172
174
|
A default configuration file will be created when running `--create-dictionary` with the CLI.
|
@@ -177,8 +179,11 @@ A default configuration file will be created when running `--create-dictionary`
|
|
177
179
|
- `description`: Just used for display when running `--list-dictionaries`
|
178
180
|
- `triggers`: An array of triggers that can be used to trigger the language.
|
179
181
|
|
180
|
-
For example, the `bacon` language has the triggers
|
181
|
-
|
182
|
+
For example, the `bacon` language has the triggers
|
183
|
+
`[bacon, meat, carnivore]`, so you can use `randw -S
|
184
|
+
meat` on the command line (or with the library).
|
185
|
+
- `extended_punctuation`: Whether to include extended
|
186
|
+
punctuation like parenthesis, quotes, and ellipsis.
|
182
187
|
|
183
188
|
|
184
189
|
##### Terminators
|
@@ -211,13 +216,13 @@ the most likely to be used.
|
|
211
216
|
|
212
217
|
##### Names
|
213
218
|
|
214
|
-
The `names.txt` file is just used when creating
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
219
|
+
The `names.txt` file is just used when creating random
|
220
|
+
names. Sections are split by blank lines: first names, last
|
221
|
+
names, and optionally full names. If the first line contains
|
222
|
+
characters other than letters, single quotes, and dashes, it
|
223
|
+
will be assumed that you've skipped straight to full names
|
224
|
+
and those will be used instead of generating random
|
225
|
+
combinations.
|
221
226
|
|
222
227
|
#### Language Notes
|
223
228
|
|
@@ -232,8 +237,11 @@ If you create a fun dictionary, please let me know (or make a PR) and I'll gladl
|
|
232
237
|
```ruby
|
233
238
|
require 'random-words'
|
234
239
|
|
235
|
-
# Argument defines source dictionary (latin, english, corporate, bacon)
|
240
|
+
# Argument defines source dictionary (latin, english, corporate, bacon, etc.)
|
236
241
|
rw = RandomWords::Generator.new(:corporate)
|
242
|
+
|
243
|
+
rw.sources # List all available dictionaries
|
244
|
+
|
237
245
|
# Change source dictionary and re-init
|
238
246
|
rw.source = :bacon
|
239
247
|
|
data/bin/randw
CHANGED
@@ -44,6 +44,10 @@ module RandomWords
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def colorize_text(text, color)
|
47
|
+
return text unless $stdout.isatty
|
48
|
+
|
49
|
+
return text unless colors.key?(color)
|
50
|
+
|
47
51
|
color_code = colors[color]
|
48
52
|
|
49
53
|
"\e[#{color_code}m#{text}\e[0m"
|
@@ -190,10 +194,9 @@ end
|
|
190
194
|
paragraph_length: 3,
|
191
195
|
count: 1,
|
192
196
|
method: nil,
|
193
|
-
debug:
|
197
|
+
debug: 0,
|
194
198
|
whitespace: true,
|
195
|
-
separator: " "
|
196
|
-
use_extended_punctuation: false,
|
199
|
+
separator: " "
|
197
200
|
}
|
198
201
|
|
199
202
|
markdown_help = <<HELP
|
@@ -308,8 +311,9 @@ OptionParser.new do |opts|
|
|
308
311
|
|
309
312
|
opts.separator "OTHER OPTIONS:"
|
310
313
|
|
311
|
-
opts.on("-d", "--debug", "Enable debug mode, displays sentence/word/character counts") do
|
314
|
+
opts.on("-d", "--debug [LEVEL]", "Enable debug mode, 1 displays sentence/word/character counts, 2 displays parts of speech (default 1)") do |level|
|
312
315
|
@options[:debug] = true
|
316
|
+
@options[:debug_level] = level.to_i || 1
|
313
317
|
end
|
314
318
|
|
315
319
|
opts.on("-h", "--help", "Display this help message") do
|
@@ -357,6 +361,7 @@ def markdown_settings(settings)
|
|
357
361
|
mark: false,
|
358
362
|
headers: false,
|
359
363
|
table: false,
|
364
|
+
extended: false
|
360
365
|
}
|
361
366
|
sources = []
|
362
367
|
RandomWords::Generator.new(:latin).sources.each { |k, v| sources.concat(v.names.map(&:to_s)) }
|
@@ -379,6 +384,7 @@ def markdown_settings(settings)
|
|
379
384
|
headers: true,
|
380
385
|
image: true,
|
381
386
|
table: true,
|
387
|
+
extended: true
|
382
388
|
}
|
383
389
|
markdown_options.merge!(new_options)
|
384
390
|
when Regexp.union(sources)
|
@@ -407,6 +413,8 @@ def markdown_settings(settings)
|
|
407
413
|
markdown_options[:table] = true
|
408
414
|
when 'short', 's', 'medium', 'med', 'm', 'long', 'l', 'very_long', 'vl'
|
409
415
|
markdown_options[:length] = setting.to_length
|
416
|
+
when 'x', 'extended'
|
417
|
+
markdown_options[:extended] = true
|
410
418
|
else
|
411
419
|
markdown_options[:source] = setting.to_source
|
412
420
|
end
|
@@ -415,10 +423,12 @@ def markdown_settings(settings)
|
|
415
423
|
markdown_options
|
416
424
|
end
|
417
425
|
|
418
|
-
@rw = RandomWords::Generator.new(@options[:source])
|
426
|
+
@rw = RandomWords::Generator.new(@options[:source], { debug: @options[:debug_level] > 1 })
|
419
427
|
@rw.sentence_length = @options[:length] || :medium
|
420
428
|
@rw.paragraph_length = @options[:paragraph_length] || 3
|
421
|
-
@
|
429
|
+
@options[:use_extended_punctuation] = @options[:use_extended_punctuation] ? true : false
|
430
|
+
@rw.use_extended_punctuation = @options[:use_extended_punctuation] ? true : @rw.config.config[:use_extended_punctuation]
|
431
|
+
|
422
432
|
@options[:count] = @options[:count].to_i
|
423
433
|
|
424
434
|
case @options[:method]
|
@@ -465,7 +475,10 @@ when :markdown, :html
|
|
465
475
|
@rw.source = settings[:source]
|
466
476
|
@rw.sentence_length = settings[:length] || :medium
|
467
477
|
@rw.paragraph_length = settings[:sentences] || 5
|
468
|
-
|
478
|
+
|
479
|
+
@rw.use_extended_punctuation = settings[:extended] ? true : @options[:use_extended_punctuation]
|
480
|
+
settings[:extended] = @rw.use_extended_punctuation
|
481
|
+
|
469
482
|
if @options[:method] == :markdown
|
470
483
|
puts @rw.markdown(settings)
|
471
484
|
else
|
data/lib/random-words/array.rb
CHANGED
@@ -67,5 +67,14 @@ module RandomWords
|
|
67
67
|
full_names.delete_if(&:empty?)
|
68
68
|
[first_names, last_names, full_names]
|
69
69
|
end
|
70
|
+
|
71
|
+
def rotate
|
72
|
+
return self if empty?
|
73
|
+
|
74
|
+
# Rotate the array by moving the first element to the end
|
75
|
+
first_element = shift
|
76
|
+
push(first_element)
|
77
|
+
self
|
78
|
+
end
|
70
79
|
end
|
71
80
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RandomWords
|
4
|
+
# @!visibility private
|
5
|
+
# This class is used to convert boolean values to strings, integers, and floats.
|
6
|
+
# It also provides a method to check if the value is truish.
|
7
|
+
class ::FalseClass
|
8
|
+
# Convert a boolean value to a string.
|
9
|
+
# @return [String] "true" or "false"
|
10
|
+
def to_s
|
11
|
+
'false'
|
12
|
+
end
|
13
|
+
|
14
|
+
# Convert a boolean value to an integer.
|
15
|
+
# @return [Integer] 1 for true, 0 for false
|
16
|
+
def to_i
|
17
|
+
0
|
18
|
+
end
|
19
|
+
|
20
|
+
# Convert a boolean value to a float.
|
21
|
+
# @return [Float] 1.0 for true, 0.0 for false
|
22
|
+
def to_f
|
23
|
+
0.0
|
24
|
+
end
|
25
|
+
|
26
|
+
# Shim for truish
|
27
|
+
# @return [Boolean] false
|
28
|
+
def trueish?
|
29
|
+
false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# @!visibility private
|
34
|
+
# This class is used to convert boolean values to strings, integers, and floats.
|
35
|
+
# It also provides a method to check if the value is truish.
|
36
|
+
class ::TrueClass
|
37
|
+
# Convert a boolean value to a string.
|
38
|
+
# @return [String] "true" or "false"
|
39
|
+
def to_s
|
40
|
+
'true'
|
41
|
+
end
|
42
|
+
|
43
|
+
# Convert a boolean value to an integer.
|
44
|
+
# @return [Integer] 1 for true, 0 for false
|
45
|
+
def to_i
|
46
|
+
1
|
47
|
+
end
|
48
|
+
|
49
|
+
# Convert a boolean value to a float.
|
50
|
+
# @return [Float] 1.0 for true, 0.0 for false
|
51
|
+
def to_f
|
52
|
+
1.0
|
53
|
+
end
|
54
|
+
|
55
|
+
# Shim for truish
|
56
|
+
def trueish?
|
57
|
+
true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/random-words/config.rb
CHANGED
@@ -34,6 +34,9 @@ module RandomWords
|
|
34
34
|
# Source directory for languages
|
35
35
|
attr_reader :source_dir
|
36
36
|
|
37
|
+
# Base config
|
38
|
+
attr_reader :config
|
39
|
+
|
37
40
|
# Initialize the config with the given language
|
38
41
|
# @param lang [Symbol] The language to use
|
39
42
|
# @raise [RuntimeError] if no dictionary is found for the given language
|
@@ -204,10 +207,12 @@ module RandomWords
|
|
204
207
|
# @param configuration [Hash] The configuration hash
|
205
208
|
# @return [Hash] The converted configuration hash
|
206
209
|
def handle_config(configuration)
|
210
|
+
ext_punc = configuration[:extended_punctuation]
|
207
211
|
{
|
208
212
|
source: configuration[:source].to_source || :latin,
|
209
213
|
sentence_length: configuration[:length].to_length || :medium,
|
210
|
-
paragraph_length: configuration[:paragraph_length].to_i || 5
|
214
|
+
paragraph_length: configuration[:paragraph_length].to_i || 5,
|
215
|
+
use_extended_punctuation: (ext_punc && ext_punc.trueish?) || false
|
211
216
|
}
|
212
217
|
end
|
213
218
|
|
@@ -244,7 +249,8 @@ module RandomWords
|
|
244
249
|
config = {
|
245
250
|
'source' => 'latin',
|
246
251
|
'length' => 'medium',
|
247
|
-
'paragraph_length' => 5
|
252
|
+
'paragraph_length' => 5,
|
253
|
+
'extended_punctuation' => false
|
248
254
|
}
|
249
255
|
File.write(config_file, config.to_yaml)
|
250
256
|
warn "Created #{config_file}"
|