word_salad 2.0.0 → 3.1.0
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 +7 -0
- data/lib/word_salad/core_ext.rb +29 -36
- data/lib/word_salad/dictionary +585 -437
- data/lib/word_salad.rb +19 -13
- metadata +54 -57
- data/.gitignore +0 -3
- data/Gemfile +0 -4
- data/History.txt +0 -13
- data/README.txt +0 -48
- data/Rakefile +0 -2
- data/lib/version.rb +0 -3
- data/lib/word_salad/version.rb +0 -3
- data/spec/word_salad_spec.rb +0 -98
- data/word_salad.gemspec +0 -21
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 4cf04e92ce6207b4ff8f9314766652e4b4225b0cde9e422369045b8df9d0e708
|
|
4
|
+
data.tar.gz: fe5bc278afe8bc834f302e6fc19e056e935cdf7213ddb078669a74edd56d3e2e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f82a5f65cf626acb53f5f56ab73963212fafcf526826c69d583b9773894ced461505106ee5a2adc7227c0f6b8946425db346199f19798f55ff60677628947922
|
|
7
|
+
data.tar.gz: 6ff1b6ab2ee0df6e57ac9326c182670aa06314d2f226c7380f30ab78d4a299ba5c0550a19167ef572826516092193bc219db336c7bb93426aa78efc761047ecc
|
data/lib/word_salad/core_ext.rb
CHANGED
|
@@ -1,47 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
(1..self).to_a.map do |x|
|
|
7
|
-
WordSalad.words[rand(WordSalad.size)].strip
|
|
8
|
-
end
|
|
9
|
-
end
|
|
3
|
+
%w[word words sentence sentences paragraph paragraphs].each do |meth|
|
|
4
|
+
raise "#{meth} is already defined in Integer class" if Integer.method_defined?(meth)
|
|
5
|
+
end
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def sentences(size=10)
|
|
18
|
-
(1..self).to_a.map do |x|
|
|
19
|
-
variance = rand(size/3 + 1)
|
|
20
|
-
variance = 0 - variance if rand(2) == 0 # plus or minus
|
|
21
|
-
w = (size + variance).words
|
|
22
|
-
w[0].capitalize!
|
|
23
|
-
w.join(' ') + '.'
|
|
24
|
-
end
|
|
25
|
-
end
|
|
7
|
+
# extends the Integer class
|
|
8
|
+
class Integer
|
|
9
|
+
# Returns 1 random word from the dictionary
|
|
10
|
+
def word = WordSalad.words.sample
|
|
11
|
+
# Returns an array of +num+ random words from the dictionary.
|
|
12
|
+
def words = WordSalad.words.sample(self)
|
|
26
13
|
|
|
27
14
|
# Returns 1 sentence of random words about +size+ long
|
|
28
|
-
def sentence(size=10)
|
|
29
|
-
|
|
15
|
+
def sentence(size = 10, variance: true)
|
|
16
|
+
words = if variance
|
|
17
|
+
variance = rand((size / 4) + 1)
|
|
18
|
+
variance = 0 - variance if rand(2).zero? # plus or minus
|
|
19
|
+
(size + variance).words
|
|
20
|
+
else
|
|
21
|
+
size.words
|
|
22
|
+
end
|
|
23
|
+
"#{words.join(' ').capitalize}."
|
|
30
24
|
end
|
|
31
25
|
|
|
32
|
-
# Returns +num+
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
(1..self).to_a.map do |x|
|
|
36
|
-
psize.sentences(ssize).join(' ')
|
|
37
|
-
end
|
|
26
|
+
# Returns an array of +num+ sentences of random words about +size+ long
|
|
27
|
+
def sentences(size = 10, variance: true)
|
|
28
|
+
times.collect { sentence(size, variance: variance) }
|
|
38
29
|
end
|
|
39
30
|
|
|
40
|
-
# Returns 1 paragraph of +psize+ sentences,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
1.paragraphs(psize, ssize).first
|
|
31
|
+
# Returns 1 paragraph of +psize+ sentences, each about +ssize+ words long
|
|
32
|
+
def paragraph(psize = 5, ssize = 10, variance: true)
|
|
33
|
+
psize.sentences(ssize, variance: variance).join(' ')
|
|
44
34
|
end
|
|
45
35
|
|
|
36
|
+
# Returns +num+ paragraphs of +psize+ sentences about +ssize+ words long
|
|
37
|
+
def paragraphs(psize = 5, ssize = 10, variance: true)
|
|
38
|
+
times.collect { paragraph(psize, ssize, variance: variance) }
|
|
39
|
+
end
|
|
46
40
|
end
|
|
47
|
-
|