random-words 1.0.15 → 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 +17 -0
- data/Gemfile +4 -3
- data/Rakefile +96 -0
- data/bin/randw +6 -6
- data/docker/Dockerfile +12 -0
- data/docker/Dockerfile-2.6 +13 -0
- data/docker/Dockerfile-2.7 +13 -0
- data/docker/Dockerfile-3.0 +13 -0
- data/docker/Dockerfile-3.3 +13 -0
- data/docker/Dockerfile-3.4 +13 -0
- data/docker/bash_profile +17 -0
- data/docker/inputrc +57 -0
- data/docker/sources.list +11 -0
- data/lib/random-words/lorem-markdown.rb +0 -0
- data/lib/random-words/lorem_html.rb +7 -5
- data/lib/random-words/source.rb +1 -1
- data/lib/random-words/string.rb +24 -0
- data/lib/random-words/version.rb +1 -1
- data/random-words.gemspec +2 -1
- data/scripts/runtests.sh +5 -0
- metadata +32 -7
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/Gemfile
CHANGED
@@ -16,6 +16,7 @@ gem "simplecov", "~> 0.21"
|
|
16
16
|
gem "simplecov-console", "~> 0.9"
|
17
17
|
gem "standard", "~> 1.3"
|
18
18
|
gem "yard", "~> 0.9", ">= 0.9.36"
|
19
|
-
gem "rubocop", "~> 1.75.2"
|
20
|
-
gem "rubocop-performance", "~> 1.25.0"
|
21
|
-
gem "rubocop-rspec", "~> 2.0"
|
19
|
+
# gem "rubocop", "~> 1.75.2"
|
20
|
+
# gem "rubocop-performance", "~> 1.25.0"
|
21
|
+
# gem "rubocop-rspec", "~> 2.0"
|
22
|
+
gem "tty-spinner", "~> 0.9", ">= 0.9.0"
|
data/Rakefile
CHANGED
@@ -3,6 +3,18 @@ require 'rspec/core/rake_task'
|
|
3
3
|
require 'rdoc/task'
|
4
4
|
require 'standard/rake'
|
5
5
|
require 'yard'
|
6
|
+
require 'tty-spinner'
|
7
|
+
require 'English'
|
8
|
+
|
9
|
+
## Docker error class
|
10
|
+
class DockerError < StandardError
|
11
|
+
def initialize(msg = nil)
|
12
|
+
msg = msg ? "Docker error: #{msg}" : 'Docker error'
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# task :doc, [*Rake.application[:yard].arg_names] => [:yard]
|
6
18
|
|
7
19
|
Rake::RDocTask.new do |rd|
|
8
20
|
rd.main = 'README.rdoc'
|
@@ -83,3 +95,87 @@ task :bump, :type do |_, args|
|
|
83
95
|
end
|
84
96
|
File.open(version_file, 'w+') { |f| f.puts content }
|
85
97
|
end
|
98
|
+
|
99
|
+
desc 'Run tests in Docker'
|
100
|
+
task :dockertest, :version, :login, :attempt do |_, args|
|
101
|
+
args.with_defaults(version: 'all', login: false, attempt: 1)
|
102
|
+
`open -a Docker`
|
103
|
+
|
104
|
+
Rake::Task['clobber'].reenable
|
105
|
+
Rake::Task['clobber'].invoke
|
106
|
+
Rake::Task['build'].reenable
|
107
|
+
Rake::Task['build'].invoke
|
108
|
+
|
109
|
+
case args[:version]
|
110
|
+
when /^a/
|
111
|
+
%w[26 27 30 33 34].each do |v|
|
112
|
+
Rake::Task['dockertest'].reenable
|
113
|
+
Rake::Task['dockertest'].invoke(v, false)
|
114
|
+
end
|
115
|
+
Process.exit 0
|
116
|
+
when /^3\.?4/
|
117
|
+
version = '3.4'
|
118
|
+
img = 'randwtest34'
|
119
|
+
file = 'docker/Dockerfile-3.4'
|
120
|
+
when /^3\.?3/
|
121
|
+
version = '3.3'
|
122
|
+
img = 'randwtest33'
|
123
|
+
file = 'docker/Dockerfile-3.3'
|
124
|
+
when /^2\.?6/
|
125
|
+
version = '2.6'
|
126
|
+
img = 'randwtest26'
|
127
|
+
file = 'docker/Dockerfile-2.6'
|
128
|
+
when /^2/
|
129
|
+
version = '2.7'
|
130
|
+
img = 'randwtest27'
|
131
|
+
file = 'docker/Dockerfile-2.7'
|
132
|
+
else
|
133
|
+
version = '3.0'
|
134
|
+
img = 'randwtest30'
|
135
|
+
file = 'docker/Dockerfile-3.0'
|
136
|
+
end
|
137
|
+
|
138
|
+
spinner = TTY::Spinner.new("[:spinner] Updating Docker image (#{version})...", hide_cursor: true)
|
139
|
+
`docker build . --file #{file} -t #{img} &> /dev/null`
|
140
|
+
|
141
|
+
unless $CHILD_STATUS.success?
|
142
|
+
spinner.error
|
143
|
+
spinner.stop
|
144
|
+
raise DockerError, 'Error building docker image'
|
145
|
+
end
|
146
|
+
|
147
|
+
spinner.success
|
148
|
+
spinner.stop
|
149
|
+
|
150
|
+
dirs = {
|
151
|
+
File.dirname(__FILE__) => '/randw',
|
152
|
+
File.expand_path('~/.config') => '/root/.config'
|
153
|
+
}
|
154
|
+
dir_args = dirs.map { |s, d| " -v '#{s}:#{d}'" }.join(' ')
|
155
|
+
exec "docker run #{dir_args} --name #{img} -it #{img} /bin/bash -l" if args[:login]
|
156
|
+
|
157
|
+
spinner = TTY::Spinner.new("[:spinner] Running tests (#{version})...", hide_cursor: true)
|
158
|
+
|
159
|
+
spinner.auto_spin
|
160
|
+
output = `docker run --name #{img} --rm #{dir_args} -it #{img} 2>&1`
|
161
|
+
if $CHILD_STATUS.success?
|
162
|
+
spinner.success
|
163
|
+
spinner.stop
|
164
|
+
else
|
165
|
+
spinner.error
|
166
|
+
spinner.stop
|
167
|
+
raise DockerError, 'Error running docker image'
|
168
|
+
puts output
|
169
|
+
end
|
170
|
+
|
171
|
+
# commit = puts `bash -c "docker commit $(docker ps -a|grep #{img}|awk '{print $1}'|head -n 1) #{img}"`.strip
|
172
|
+
|
173
|
+
# puts commit&.empty? ? "Error commiting Docker tag #{img}" : "Committed Docker tag #{img}"
|
174
|
+
rescue DockerError
|
175
|
+
raise StandardError.new('Docker not responding') if args[:attempt] > 3
|
176
|
+
|
177
|
+
`open -a Docker`
|
178
|
+
sleep 3
|
179
|
+
Rake::Task['dockertest'].reenable
|
180
|
+
Rake::Task['dockertest'].invoke(args[:version], args[:login], args[:attempt] + 1)
|
181
|
+
end
|
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)
|
data/docker/Dockerfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
FROM ruby:3.0.1
|
2
|
+
# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
3
|
+
RUN mkdir /randw
|
4
|
+
WORKDIR /randw
|
5
|
+
RUN gem install bundler:2.2
|
6
|
+
COPY ./docker/sources.list /etc/apt/sources.list
|
7
|
+
RUN apt-get update -y --allow-insecure-repositories || true
|
8
|
+
RUN apt-get install -y sudo || true
|
9
|
+
RUN sudo apt-get install -y less vim || true
|
10
|
+
COPY ./docker/inputrc /root/.inputrc
|
11
|
+
COPY ./docker/bash_profile /root/.bash_profile
|
12
|
+
CMD ["/randw/scripts/runtests.sh"]
|
@@ -0,0 +1,13 @@
|
|
1
|
+
FROM ruby:2.6
|
2
|
+
# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
3
|
+
RUN mkdir /randw
|
4
|
+
WORKDIR /randw
|
5
|
+
RUN gem install bundler:2.2
|
6
|
+
RUN bundle config set force_ruby_platform true
|
7
|
+
COPY ./docker/sources.list /etc/apt/sources.list
|
8
|
+
RUN apt-get update -y --allow-insecure-repositories || true
|
9
|
+
RUN apt-get install -y sudo || true
|
10
|
+
RUN sudo apt-get install -y less vim || true
|
11
|
+
COPY ./docker/inputrc /root/.inputrc
|
12
|
+
COPY ./docker/bash_profile /root/.bash_profile
|
13
|
+
CMD ["/randw/scripts/runtests.sh"]
|
@@ -0,0 +1,13 @@
|
|
1
|
+
FROM ruby:2.7
|
2
|
+
# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
3
|
+
RUN mkdir /randw
|
4
|
+
WORKDIR /randw
|
5
|
+
RUN gem install bundler:2.2
|
6
|
+
RUN bundle config set force_ruby_platform true
|
7
|
+
COPY ./docker/sources.list /etc/apt/sources.list
|
8
|
+
RUN apt-get update -y --allow-insecure-repositories || true
|
9
|
+
RUN apt-get install -y sudo || true
|
10
|
+
RUN sudo apt-get install -y less vim || true
|
11
|
+
COPY ./docker/inputrc /root/.inputrc
|
12
|
+
COPY ./docker/bash_profile /root/.bash_profile
|
13
|
+
CMD ["/randw/scripts/runtests.sh"]
|
@@ -0,0 +1,13 @@
|
|
1
|
+
FROM ruby:3.0.1
|
2
|
+
# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
3
|
+
RUN mkdir /randw
|
4
|
+
WORKDIR /randw
|
5
|
+
RUN gem install bundler:2.2
|
6
|
+
RUN bundle config set force_ruby_platform true
|
7
|
+
COPY ./docker/sources.list /etc/apt/sources.list
|
8
|
+
RUN apt-get update -y --allow-insecure-repositories || true
|
9
|
+
RUN apt-get install -y sudo || true
|
10
|
+
RUN sudo apt-get install -y less vim || true
|
11
|
+
COPY ./docker/inputrc /root/.inputrc
|
12
|
+
COPY ./docker/bash_profile /root/.bash_profile
|
13
|
+
CMD ["/randw/scripts/runtests.sh"]
|
@@ -0,0 +1,13 @@
|
|
1
|
+
FROM ruby:3.3.0
|
2
|
+
# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
3
|
+
RUN mkdir /randw
|
4
|
+
WORKDIR /randw
|
5
|
+
RUN gem install bundler:2.6.8
|
6
|
+
RUN bundle config set force_ruby_platform true
|
7
|
+
COPY ./docker/sources.list /etc/apt/sources.list
|
8
|
+
RUN apt-get update -y --allow-insecure-repositories || true
|
9
|
+
RUN apt-get install -y sudo || true
|
10
|
+
RUN sudo apt-get install -y less vim || true
|
11
|
+
COPY ./docker/inputrc /root/.inputrc
|
12
|
+
COPY ./docker/bash_profile /root/.bash_profile
|
13
|
+
CMD ["/randw/scripts/runtests.sh"]
|
@@ -0,0 +1,13 @@
|
|
1
|
+
FROM ruby:3.4.4
|
2
|
+
# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
3
|
+
RUN mkdir /randw
|
4
|
+
WORKDIR /randw
|
5
|
+
RUN gem install bundler:2.6.8
|
6
|
+
RUN bundle config set force_ruby_platform true
|
7
|
+
COPY ./docker/sources.list /etc/apt/sources.list
|
8
|
+
RUN apt-get update -y --allow-insecure-repositories || true
|
9
|
+
RUN apt-get install -y sudo || true
|
10
|
+
RUN sudo apt-get install -y less vim || true
|
11
|
+
COPY ./docker/inputrc /root/.inputrc
|
12
|
+
COPY ./docker/bash_profile /root/.bash_profile
|
13
|
+
CMD ["/randw/scripts/runtests.sh"]
|
data/docker/bash_profile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
export GLI_DEBUG=true
|
3
|
+
export EDITOR="/usr/bin/vim"
|
4
|
+
alias b="bundle exec bin/randw"
|
5
|
+
alias be="bundle exec"
|
6
|
+
alias quit="exit"
|
7
|
+
|
8
|
+
shopt -s nocaseglob
|
9
|
+
shopt -s histappend
|
10
|
+
shopt -s histreedit
|
11
|
+
shopt -s histverify
|
12
|
+
shopt -s cmdhist
|
13
|
+
|
14
|
+
cd /randw
|
15
|
+
bundle update
|
16
|
+
gem update --system
|
17
|
+
gem install pkg/*.gem
|
data/docker/inputrc
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
"\e[3~": delete-char
|
2
|
+
"\ex": 'cd !$ \015ls\015'
|
3
|
+
"\ez": 'cd -\015'
|
4
|
+
"\e\C-m": '\C-a "$(\C-e|fzf)"\C-a'
|
5
|
+
"\e/": '"$(!!|fzf)"\C-a \C-m\C-m'
|
6
|
+
# these allow you to use alt+left/right arrow keys
|
7
|
+
# to jump the cursor over words
|
8
|
+
"\e[1;5C": forward-word
|
9
|
+
"\e[1;5D": backward-word
|
10
|
+
# "\e[D": backward-word
|
11
|
+
# "\e[C": forward-word
|
12
|
+
"\ea": menu-complete
|
13
|
+
# TAB: menu-complete
|
14
|
+
# "\e[Z": "\e-1\C-i"
|
15
|
+
|
16
|
+
"\e\C-l": history-and-alias-expand-line
|
17
|
+
|
18
|
+
# these allow you to start typing a command and
|
19
|
+
# use the up/down arrow to auto complete from
|
20
|
+
# commands in your history
|
21
|
+
"\e[B": history-search-forward
|
22
|
+
"\e[A": history-search-backward
|
23
|
+
"\ew": history-search-backward
|
24
|
+
"\es": history-search-forward
|
25
|
+
# this lets you hit tab to auto-complete a file or
|
26
|
+
# directory name ignoring case
|
27
|
+
set completion-ignore-case On
|
28
|
+
set mark-symlinked-directories On
|
29
|
+
set completion-prefix-display-length 2
|
30
|
+
set bell-style none
|
31
|
+
# set bell-style visible
|
32
|
+
set meta-flag on
|
33
|
+
set convert-meta off
|
34
|
+
set input-meta on
|
35
|
+
set output-meta on
|
36
|
+
set show-all-if-ambiguous on
|
37
|
+
set show-all-if-unmodified on
|
38
|
+
set completion-map-case on
|
39
|
+
set visible-stats on
|
40
|
+
|
41
|
+
# Do history expansion when space entered?
|
42
|
+
$if bash
|
43
|
+
Space: magic-space
|
44
|
+
$endif
|
45
|
+
|
46
|
+
# Show extra file information when completing, like `ls -F` does
|
47
|
+
set visible-stats on
|
48
|
+
|
49
|
+
# Be more intelligent when autocompleting by also looking at the text after
|
50
|
+
# the cursor. For example, when the current line is "cd ~/src/mozil", and
|
51
|
+
# the cursor is on the "z", pressing Tab will not autocomplete it to "cd
|
52
|
+
# ~/src/mozillail", but to "cd ~/src/mozilla". (This is supported by the
|
53
|
+
# Readline used by Bash 4.)
|
54
|
+
set skip-completed-text on
|
55
|
+
|
56
|
+
# Use Alt/Meta + Delete to delete the preceding word
|
57
|
+
"\e[3;3~": kill-word
|
data/docker/sources.list
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
deb http://archive.ubuntu.com/ubuntu/ focal main restricted
|
2
|
+
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
|
3
|
+
deb http://archive.ubuntu.com/ubuntu/ focal universe
|
4
|
+
deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
|
5
|
+
deb http://archive.ubuntu.com/ubuntu/ focal multiverse
|
6
|
+
deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
|
7
|
+
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
|
8
|
+
|
9
|
+
deb http://security.ubuntu.com/ubuntu focal-security main restricted
|
10
|
+
deb http://security.ubuntu.com/ubuntu focal-security universe
|
11
|
+
deb http://security.ubuntu.com/ubuntu focal-security multiversesudo apt update
|
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/source.rb
CHANGED
@@ -78,7 +78,7 @@ module RandomWords
|
|
78
78
|
filename = "#{filename.sub(/\.txt$/, '')}.txt"
|
79
79
|
path = File.join(@path, filename)
|
80
80
|
|
81
|
-
File.read(path).strip.split("\n").map(&:strip) # Changed from split_lines to split("\n")
|
81
|
+
File.read(path).clean_encode.strip.split("\n").map(&:strip) # Changed from split_lines to split("\n")
|
82
82
|
rescue Errno::ENOENT
|
83
83
|
warn "File not found: #{path}"
|
84
84
|
[]
|
data/lib/random-words/string.rb
CHANGED
@@ -13,6 +13,24 @@ module RandomWords
|
|
13
13
|
# str.terminate(["", "."]) # => "Hello World."
|
14
14
|
#
|
15
15
|
class ::String
|
16
|
+
##
|
17
|
+
## Get a clean UTF-8 string by forcing an ISO encoding and then re-encoding
|
18
|
+
##
|
19
|
+
## @return [String] UTF-8 string
|
20
|
+
##
|
21
|
+
def clean_encode
|
22
|
+
force_encoding('ISO-8859-1').encode('utf-8', replace: nil)
|
23
|
+
end
|
24
|
+
|
25
|
+
##
|
26
|
+
## Destructive version of #clean_encode
|
27
|
+
##
|
28
|
+
## @return [String] UTF-8 string, in place
|
29
|
+
##
|
30
|
+
def clean_encode!
|
31
|
+
replace clean_encode
|
32
|
+
end
|
33
|
+
|
16
34
|
# Remove unwanted characters and whitespace from a string.
|
17
35
|
# @return [String] The string with unwanted characters removed.
|
18
36
|
# @example
|
@@ -218,6 +236,8 @@ module RandomWords
|
|
218
236
|
new_source = nil
|
219
237
|
sources = RandomWords::Generator.new.sources
|
220
238
|
|
239
|
+
return sources.map { |k, v| v.name }.sample if /^(random|any)$/i.match?(self)
|
240
|
+
|
221
241
|
sources.each do |_k, v|
|
222
242
|
v.names.each do |name|
|
223
243
|
next unless /^#{self}/i.match?(name.to_s)
|
@@ -337,5 +357,9 @@ module RandomWords
|
|
337
357
|
/\A[aeiou]/i.match?(word) ? "an #{word}" : "a #{word}"
|
338
358
|
end
|
339
359
|
end
|
360
|
+
|
361
|
+
def clean_output
|
362
|
+
encode('iso-8859-1', undef: :replace, invalid: :replace, replace: '').force_encoding('UTF-8')
|
363
|
+
end
|
340
364
|
end
|
341
365
|
end
|
data/lib/random-words/version.rb
CHANGED
data/random-words.gemspec
CHANGED
data/scripts/runtests.sh
ADDED
metadata
CHANGED
@@ -1,28 +1,42 @@
|
|
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
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: json
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - '='
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 2.7.6
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - '='
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 2.7.6
|
12
26
|
- !ruby/object:Gem::Dependency
|
13
27
|
name: nokogiri
|
14
28
|
requirement: !ruby/object:Gem::Requirement
|
15
29
|
requirements:
|
16
|
-
- -
|
30
|
+
- - '='
|
17
31
|
- !ruby/object:Gem::Version
|
18
|
-
version:
|
32
|
+
version: 1.13.2
|
19
33
|
type: :runtime
|
20
34
|
prerelease: false
|
21
35
|
version_requirements: !ruby/object:Gem::Requirement
|
22
36
|
requirements:
|
23
|
-
- -
|
37
|
+
- - '='
|
24
38
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
39
|
+
version: 1.13.2
|
26
40
|
description: Generate random text (lorem ipsum) from a variety of sources.
|
27
41
|
email: me@brettterpstra.com
|
28
42
|
executables:
|
@@ -42,6 +56,15 @@ files:
|
|
42
56
|
- README.md
|
43
57
|
- Rakefile
|
44
58
|
- bin/randw
|
59
|
+
- docker/Dockerfile
|
60
|
+
- docker/Dockerfile-2.6
|
61
|
+
- docker/Dockerfile-2.7
|
62
|
+
- docker/Dockerfile-3.0
|
63
|
+
- docker/Dockerfile-3.3
|
64
|
+
- docker/Dockerfile-3.4
|
65
|
+
- docker/bash_profile
|
66
|
+
- docker/inputrc
|
67
|
+
- docker/sources.list
|
45
68
|
- generator.cgi
|
46
69
|
- lib/random-words.rb
|
47
70
|
- lib/random-words/array.rb
|
@@ -50,6 +73,7 @@ files:
|
|
50
73
|
- lib/random-words/generator.rb
|
51
74
|
- lib/random-words/hash.rb
|
52
75
|
- lib/random-words/html2markdown.rb
|
76
|
+
- lib/random-words/lorem-markdown.rb
|
53
77
|
- lib/random-words/lorem_html.rb
|
54
78
|
- lib/random-words/number_to_word.rb
|
55
79
|
- lib/random-words/numeric.rb
|
@@ -275,6 +299,7 @@ files:
|
|
275
299
|
- lib/random-words/words/walken/verbs-plural.txt
|
276
300
|
- lib/random-words/words/walken/verbs-singular.txt
|
277
301
|
- random-words.gemspec
|
302
|
+
- scripts/runtests.sh
|
278
303
|
- src/_README.md
|
279
304
|
homepage: https://github.com/ttscoff/random-words
|
280
305
|
licenses:
|
@@ -307,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
307
332
|
- !ruby/object:Gem::Version
|
308
333
|
version: '0'
|
309
334
|
requirements: []
|
310
|
-
rubygems_version: 3.6.
|
335
|
+
rubygems_version: 3.6.7
|
311
336
|
specification_version: 4
|
312
337
|
summary: Random words generator
|
313
338
|
test_files: []
|