random-words 1.0.6 → 1.0.8

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +3 -3
  3. data/.rubocop.yml +4 -1
  4. data/.rubocop_todo.yml +313 -0
  5. data/.vscode/launch.json +26 -0
  6. data/CHANGELOG.md +34 -1
  7. data/Gemfile +15 -12
  8. data/Gemfile.lock +44 -27
  9. data/README.md +81 -37
  10. data/bin/randw +109 -89
  11. data/lib/random-words/array.rb +27 -7
  12. data/lib/random-words/config.rb +29 -23
  13. data/lib/random-words/generator.rb +42 -25
  14. data/lib/random-words/hash.rb +1 -1
  15. data/lib/random-words/html2markdown.rb +7 -7
  16. data/lib/random-words/lorem-markdown.rb +19 -20
  17. data/lib/random-words/number-to-word.rb +23 -21
  18. data/lib/random-words/source.rb +10 -9
  19. data/lib/random-words/string.rb +26 -21
  20. data/lib/random-words/table-cleanup.rb +3 -3
  21. data/lib/random-words/version.rb +1 -1
  22. data/lib/random-words/words/1984/names.txt +10 -72
  23. data/lib/random-words/words/1984/phrases.txt +16 -0
  24. data/lib/random-words/words/alice/names.txt +10 -74
  25. data/lib/random-words/words/alice/phrases.txt +16 -0
  26. data/lib/random-words/words/bacon/names.txt +53 -73
  27. data/lib/random-words/words/bacon/phrases.txt +20 -0
  28. data/lib/random-words/words/corporate/phrases.txt +29 -0
  29. data/lib/random-words/words/doctor/names.txt +18 -18
  30. data/lib/random-words/words/doctor/phrases.txt +29 -0
  31. data/lib/random-words/words/english/phrases.txt +29 -0
  32. data/lib/random-words/words/foulmouth/articles-plural.txt +3 -1
  33. data/lib/random-words/words/foulmouth/articles-singular.txt +2 -1
  34. data/lib/random-words/words/foulmouth/config.yml +1 -1
  35. data/lib/random-words/words/foulmouth/names.txt +80 -73
  36. data/lib/random-words/words/foulmouth/phrases.txt +30 -0
  37. data/lib/random-words/words/hipster/names.txt +72 -73
  38. data/lib/random-words/words/hipster/phrases.txt +21 -0
  39. data/lib/random-words/words/latin/names.txt +92 -73
  40. data/lib/random-words/words/latin/phrases.txt +16 -0
  41. data/lib/random-words/words/spanish/names.txt +55 -68
  42. data/lib/random-words/words/spanish/phrases.txt +31 -0
  43. data/lib/random-words/words/veggie/names.txt +92 -73
  44. data/lib/random-words/words/veggie/phrases.txt +20 -0
  45. data/lib/random-words.rb +3 -3
  46. data/random-words.gemspec +1 -1
  47. data/src/_README.md +81 -37
  48. metadata +16 -5
  49. data/.rspec_status +0 -148
@@ -1,15 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
+
3
4
  module RandomWords
4
5
  # String extensions for RandomWords
5
6
  # This module extends the String class with additional methods for cleaning,
6
7
  # compressing, and manipulating strings.
7
8
  #
8
9
  # @example
9
- # str = " Hello, World! "
10
- # str.clean # => "Hello World"
11
- # str.compress # => "Hello World"
12
- # str.terminate # => "Hello World."
10
+ # str = " Hello, World! "
11
+ # str.clean # => "Hello World"
12
+ # str.compress # => "Hello, World!"
13
+ # str.terminate(["", "."]) # => "Hello World."
13
14
  #
14
15
  class ::String
15
16
  # Remove unwanted characters and whitespace from a string.
@@ -42,12 +43,10 @@ module RandomWords
42
43
 
43
44
  letters = split('')
44
45
  string = []
45
- while letters[0] !~ /[[:word:]]/
46
- string << letters.shift
47
- end
46
+ string << letters.shift while letters[0] !~ /[[:word:]]/
48
47
  string << letters.shift.upcase
49
48
  string.concat(letters)
50
- string.join("")
49
+ string.join('')
51
50
  end
52
51
 
53
52
  # Downcase the first letter of a string, respecting punctuation.
@@ -57,12 +56,10 @@ module RandomWords
57
56
 
58
57
  letters = split('')
59
58
  string = []
60
- while letters[0] !~ /[[:word:]]/
61
- string << letters.shift
62
- end
59
+ string << letters.shift while letters[0] !~ /[[:word:]]/
63
60
  string << letters.shift.downcase
64
61
  string.concat(letters)
65
- string.join("")
62
+ string.join('')
66
63
  end
67
64
 
68
65
  # Capitalize the first letter of each sentence in a string.
@@ -75,7 +72,7 @@ module RandomWords
75
72
  def fix_caps(terminators)
76
73
  return self if empty?
77
74
 
78
- terminator_ends = terminators.map { |t| t[1].split("").last }.delete_if(&:empty?)
75
+ terminator_ends = terminators.map { |t| t[1].split('').last }.delete_if(&:empty?)
79
76
  return capitalize if terminator_ends.empty?
80
77
 
81
78
  terminator_regex = Regexp.new("[#{Regexp.escape(terminator_ends.join)}]")
@@ -83,7 +80,7 @@ module RandomWords
83
80
 
84
81
  split(/(?<=#{terminator_regex}) /).map do |sentence|
85
82
  sentence.capitalize
86
- end.join(" ")
83
+ end.join(' ')
87
84
  end
88
85
 
89
86
  # Remove duplicate commas
@@ -91,7 +88,7 @@ module RandomWords
91
88
  # @example
92
89
  # "Hello, , World!".remove_duplicate_commas # => "Hello, World!"
93
90
  def dedup_commas
94
- gsub(/(, *)+/, ',').gsub(/,/, ', ')
91
+ gsub(/(, *)+/, ',').gsub(',', ', ')
95
92
  end
96
93
 
97
94
  # Generate a sentence with capitalization and terminator
@@ -128,8 +125,17 @@ module RandomWords
128
125
 
129
126
  # Remove any punctuation mark from the end of a string.
130
127
  # @return [String] The string with the last punctuation mark removed.
131
- def no_term
132
- sub(/[.!?;,:-]+$/, '')
128
+ def no_term(terminators)
129
+ str = dup
130
+ leading = terminators.map { |t| t[0] }.delete_if(&:empty?).sort.uniq.join
131
+ trailing = terminators.map { |t| t[1] }.delete_if(&:empty?).sort.uniq.join
132
+ return self if leading.empty? && trailing.empty?
133
+
134
+ str.gsub!(/[#{Regexp.escape(leading)}]+/, '') unless leading.empty?
135
+
136
+ str.gsub!(/[#{Regexp.escape(trailing)}]+/, '') unless trailing.empty?
137
+
138
+ str
133
139
  end
134
140
 
135
141
  # Indent every line in a string with a specified string.
@@ -181,7 +187,7 @@ module RandomWords
181
187
  # @return [String] The string with spaces restored.
182
188
  def restore_spaces
183
189
  # Restores spaces in the output.
184
- gsub(/%%/, ' ')
190
+ gsub('%%', ' ')
185
191
  end
186
192
 
187
193
  # Check if the string is trueish (starts with 't', 'y', or '1').
@@ -196,7 +202,7 @@ module RandomWords
196
202
  new_source = nil
197
203
  sources = RandomWords::Generator.new.sources
198
204
 
199
- sources.each do |k, v|
205
+ sources.each do |_k, v|
200
206
  v.names.each do |name|
201
207
  next unless name.to_s =~ /^#{self}/i
202
208
 
@@ -224,7 +230,6 @@ module RandomWords
224
230
  else
225
231
  :medium
226
232
  end
227
-
228
233
  end
229
234
  end
230
- end
235
+ end
@@ -125,7 +125,7 @@ module RandomWords
125
125
  @alignment.zip(@widths).each do |align, width|
126
126
  @string << ':' if align == :left
127
127
  width = @max_cell_width - 2 if width >= @max_cell_width
128
- @string << '-' * (width + (align == :center ? 2 : 1))
128
+ @string << ('-' * (width + (align == :center ? 2 : 1)))
129
129
  @string << ':' if align == :right
130
130
  @string << '|'
131
131
  end
@@ -189,7 +189,7 @@ module RandomWords
189
189
  end
190
190
  end
191
191
 
192
- lines = t['table'].split(/\n/)
192
+ lines = t['table'].split("\n")
193
193
  lines.delete_if(&:alignment?)
194
194
 
195
195
  lines.each do |row|
@@ -207,4 +207,4 @@ module RandomWords
207
207
  @content
208
208
  end
209
209
  end
210
- end
210
+ end
@@ -1,4 +1,4 @@
1
1
  module RandomWords
2
2
  # The version of the RandomWords gem.
3
- VERSION = '1.0.6'
3
+ VERSION = '1.0.8'
4
4
  end
@@ -1,74 +1,12 @@
1
- John
2
- Jane
3
- Mary
4
- Michael
5
- Sarah
6
- David
7
- Emily
8
- James
9
- Jessica
10
- Robert
11
- Linda
12
- William
13
- Patricia
14
- Brett
15
- Ashley
16
- Matthew
17
- Jennifer
18
- Yasmin
1
+ Winston
2
+ Julia
3
+ Katherine
19
4
 
20
5
  Smith
21
- Johnson
22
- Williams
23
- Brown
24
- Jones
25
- Garcia
26
- Miller
27
- Davis
28
- Rodriguez
29
- Martinez
30
- Hernandez
31
- Lopez
32
- Gonzalez
33
- Wilson
34
- Anderson
35
- Taylor
36
- Thomas
37
- Moore
38
- Jackson
39
- Martin
40
- Lee
41
- Perez
42
- Thompson
43
- White
44
- Harris
45
- Sanchez
46
- Clark
47
- Ramirez
48
- Lewis
49
- Robinson
50
- Walker
51
- Young
52
- Allen
53
- King
54
- Wright
55
- Scott
56
- Torres
57
- Nguyen
58
- Hill
59
- Flores
60
- Green
61
- Adams
62
- Nelson
63
- Baker
64
- Hall
65
- Rivera
66
- Campbell
67
- Mitchell
68
- Carter
69
- Roberts
70
- Gomez
71
- Phillips
72
- Evans
73
- Turner
74
- Diaz
6
+ O’Brien
7
+ Parsons
8
+ Syme
9
+ Goldstein
10
+
11
+ Big Brother
12
+ Winston's Mother
@@ -0,0 +1,16 @@
1
+ big brother is watching you
2
+ war is peace
3
+ freedom is slavery
4
+ ignorance is strength
5
+ I love big brother
6
+ the past was dead, the future was unimaginable
7
+ thoughtcrime does not entail death: thoughtcrime IS death
8
+ who controls the past controls the future
9
+ the Ministry of Truth is responsible for news
10
+ reality exists in the human mind
11
+ the party told you to reject the evidence of your eyes and ears
12
+ if you want to keep a secret, you must also hide it from yourself
13
+ the lie becomes truth
14
+ it was a bright cold day in April
15
+ doublethink means the power of holding two contradictory beliefs
16
+ you are not allowed to think for yourself
@@ -1,74 +1,10 @@
1
- John
2
- Jane
3
- Mary
4
- Michael
5
- Sarah
6
- David
7
- Emily
8
- James
9
- Jessica
10
- Robert
11
- Linda
12
- William
13
- Patricia
14
- Brett
15
- Ashley
16
- Matthew
17
- Jennifer
18
- Yasmin
19
-
20
- Smith
21
- Johnson
22
- Williams
23
- Brown
24
- Jones
25
- Garcia
26
- Miller
27
- Davis
28
- Rodriguez
29
- Martinez
30
- Hernandez
31
- Lopez
32
- Gonzalez
33
- Wilson
34
- Anderson
35
- Taylor
36
- Thomas
37
- Moore
38
- Jackson
39
- Martin
40
- Lee
41
- Perez
42
- Thompson
43
- White
44
- Harris
45
- Sanchez
46
- Clark
47
- Ramirez
48
- Lewis
49
- Robinson
50
- Walker
51
- Young
52
- Allen
53
- King
54
- Wright
55
- Scott
56
- Torres
57
- Nguyen
58
- Hill
59
- Flores
60
- Green
61
- Adams
62
- Nelson
63
- Baker
64
- Hall
65
- Rivera
66
- Campbell
67
- Mitchell
68
- Carter
69
- Roberts
70
- Gomez
71
- Phillips
72
- Evans
73
- Turner
74
- Diaz
1
+ Mad Hatter
2
+ Alice
3
+ Cheshire Cat
4
+ Queen of Hearts
5
+ White Rabbit
6
+ Caterpillar
7
+ March Hare
8
+ Tweedledee
9
+ Tweedledum
10
+ Dormouse
@@ -0,0 +1,16 @@
1
+ curiouser and curiouser
2
+ it’s no use going back to yesterday
3
+ we're all mad here
4
+ why, sometimes I've believed as many as six impossible things before breakfast
5
+ off with their heads!
6
+ you’re entirely bonkers
7
+ it’s a rabbit hole, of course
8
+ I can’t go back to yesterday because I was a different person then
9
+ would you like an adventure now, or shall we have our tea first?
10
+ the hurrier I go, the behinder I get
11
+ I've had enough nonsense
12
+ I'll try to be nicer if you'll try to be smarter
13
+ we're all just a little mad
14
+ I’m late, I’m late, for a very important date
15
+ take care of the sense, and the sounds will take care of themselves
16
+ the best way to explain it is to do it
@@ -1,74 +1,54 @@
1
- John
2
- Jane
3
- Mary
4
- Michael
5
- Sarah
6
- David
7
- Emily
8
- James
9
- Jessica
10
- Robert
11
- Linda
12
- William
13
- Patricia
14
- Brett
15
- Ashley
16
- Matthew
17
- Jennifer
18
- Yasmin
1
+ Bacon
2
+ Hammy
3
+ Sizzles
4
+ Porky
5
+ Banger
6
+ Chops
7
+ Salami
8
+ Meatball
19
9
 
20
- Smith
21
- Johnson
22
- Williams
23
- Brown
24
- Jones
25
- Garcia
26
- Miller
27
- Davis
28
- Rodriguez
29
- Martinez
30
- Hernandez
31
- Lopez
32
- Gonzalez
33
- Wilson
34
- Anderson
35
- Taylor
36
- Thomas
37
- Moore
38
- Jackson
39
- Martin
40
- Lee
41
- Perez
42
- Thompson
43
- White
44
- Harris
45
- Sanchez
46
- Clark
47
- Ramirez
48
- Lewis
49
- Robinson
50
- Walker
51
- Young
52
- Allen
53
- King
54
- Wright
55
- Scott
56
- Torres
57
- Nguyen
58
- Hill
59
- Flores
60
- Green
61
- Adams
62
- Nelson
63
- Baker
64
- Hall
65
- Rivera
66
- Campbell
67
- Mitchell
68
- Carter
69
- Roberts
70
- Gomez
71
- Phillips
72
- Evans
73
- Turner
74
- Diaz
10
+ Baconbottom
11
+ Porkbelly
12
+ Hamfist
13
+ Sizzlesticks
14
+ Meatwhacker
15
+ Chopson
16
+ Wurstler
17
+ Grillmaster
18
+ Steakhouse
19
+ Sausageface
20
+ McSizzlefest
21
+ McBaconFace
22
+
23
+ Sir Loin
24
+ Winnie the Ham
25
+ Bacon McSizzle
26
+ Charlie Chorizo
27
+ Daisy McPorkbelly
28
+ Elijah Eggplant
29
+ Fiona Fryingpan
30
+ Gus McGrill
31
+ Hannah Hamhock
32
+ Iggy McBaconbits
33
+ Jasper Jerky
34
+ Kylie McMeatball
35
+ Lola Loin
36
+ Marty McRib
37
+ Nina Nacho
38
+ Olive McSausage
39
+ Penny Porkchop
40
+ Quincy Quiche
41
+ Randy Ribeye
42
+ Sally Sausage
43
+ Tina T-Bone
44
+ Ursula Umami
45
+ Vicky Veggiebacon
46
+ Wally Wurst
47
+ Xander X-tra Bacon
48
+ Yvonne Yummy
49
+ Zachary Zesty
50
+ Benny Brisket
51
+ Chad Cheeseburger
52
+ Lenny Lard
53
+ Maddie Meatloaf
54
+ Ricky Rumpsteak
@@ -0,0 +1,20 @@
1
+ I can't resist a good steak
2
+ have you tried that smoky barbecue place?
3
+ nothing beats a juicy burger
4
+ I love a hearty meatloaf
5
+ let's grill some chicken this weekend
6
+ I prefer my meals with protein
7
+ this bacon is incredible
8
+ I'm all about that meat lovers pizza
9
+ I enjoy cooking with different cuts of meat
10
+ that roast is cooked to perfection
11
+ I think barbecue is the best cuisine
12
+ I need my daily dose of meat
13
+ this sausage adds so much flavor
14
+ I'm always looking for the best ribs in town
15
+ I love a classic cheeseburger
16
+ how about a meat-filled casserole?
17
+ I can't imagine a meal without meat
18
+ this dish is so satisfying with some meat
19
+ I think meat is a staple in any diet
20
+ I enjoy trying different types of meat
@@ -0,0 +1,29 @@
1
+ a blessing in disguise
2
+ bite the bullet
3
+ break the ice
4
+ burning the midnight oil
5
+ caught between a rock and a hard place
6
+ cutting corners
7
+ every cloud has a silver lining
8
+ hit the nail on the head
9
+ in the heat of the moment
10
+ jumping on the bandwagon
11
+ keep your chin up
12
+ let the cat out of the bag
13
+ on cloud nine
14
+ out of the blue
15
+ piece of cake
16
+ pulling someone's leg
17
+ see eye to eye
18
+ sitting on the fence
19
+ spill the beans
20
+ the ball is in your court
21
+ the best of both worlds
22
+ the early bird catches the worm
23
+ through thick and thin
24
+ turn a blind eye
25
+ under the weather
26
+ walking on eggshells
27
+ when pigs fly
28
+ you can't judge a book by its cover
29
+ your guess is as good as mine
@@ -1,21 +1,21 @@
1
- John
2
- Jane
3
- Mary
4
- Michael
5
- Sarah
6
- David
7
- Emily
8
- James
9
- Jessica
10
- Robert
11
- Linda
12
- William
13
- Patricia
14
- Brett
15
- Ashley
16
- Matthew
17
- Jennifer
18
- Yasmin
1
+ Dr. John
2
+ Dr. Jane
3
+ Dr. Mary
4
+ Dr. Michael
5
+ Dr. Sarah
6
+ Dr. David
7
+ Dr. Emily
8
+ Dr. James
9
+ Dr. Jessica
10
+ Dr. Robert
11
+ Dr. Linda
12
+ Dr. William
13
+ Dr. Patricia
14
+ Dr. Brett
15
+ Dr. Ashley
16
+ Dr. Matthew
17
+ Dr. Jennifer
18
+ Dr. Yasmin
19
19
 
20
20
  Smith
21
21
  Johnson
@@ -0,0 +1,29 @@
1
+ a blessing in disguise
2
+ bite the bullet
3
+ break the ice
4
+ burning the midnight oil
5
+ caught between a rock and a hard place
6
+ cutting corners
7
+ every cloud has a silver lining
8
+ hit the nail on the head
9
+ in the heat of the moment
10
+ jumping on the bandwagon
11
+ keep your chin up
12
+ let the cat out of the bag
13
+ on cloud nine
14
+ out of the blue
15
+ piece of cake
16
+ pulling someone's leg
17
+ see eye to eye
18
+ sitting on the fence
19
+ spill the beans
20
+ the ball is in your court
21
+ the best of both worlds
22
+ the early bird catches the worm
23
+ through thick and thin
24
+ turn a blind eye
25
+ under the weather
26
+ walking on eggshells
27
+ when pigs fly
28
+ you can't judge a book by its cover
29
+ your guess is as good as mine
@@ -0,0 +1,29 @@
1
+ a blessing in disguise
2
+ bite the bullet
3
+ break the ice
4
+ burning the midnight oil
5
+ caught between a rock and a hard place
6
+ cutting corners
7
+ every cloud has a silver lining
8
+ hit the nail on the head
9
+ in the heat of the moment
10
+ jumping on the bandwagon
11
+ keep your chin up
12
+ let the cat out of the bag
13
+ on cloud nine
14
+ out of the blue
15
+ piece of cake
16
+ pulling someone's leg
17
+ see eye to eye
18
+ sitting on the fence
19
+ spill the beans
20
+ the ball is in your court
21
+ the best of both worlds
22
+ the early bird catches the worm
23
+ through thick and thin
24
+ turn a blind eye
25
+ under the weather
26
+ walking on eggshells
27
+ when pigs fly
28
+ you can't judge a book by its cover
29
+ your guess is as good as mine
@@ -7,4 +7,6 @@ some
7
7
  these
8
8
  those
9
9
  three
10
- two
10
+ two
11
+ a fuckton of
12
+ a shitload of
@@ -7,4 +7,5 @@ neither
7
7
  any
8
8
  one
9
9
  this
10
- that
10
+ that
11
+ a hell of a
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  name: foulmouth
3
3
  description: Naughty words
4
- triggers: [foulmouth, swear, curse]
4
+ triggers: [foulmouth, swear, curse, fuck]