cat_ipsum 0.2.1 → 0.2.2
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 +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +18 -0
- data/lib/cat_ipsum.rb +8 -8
- data/lib/cat_ipsum/random.rb +22 -20
- data/lib/cat_ipsum/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecdb29735ddb74f486cc3a1cc4a1248ead45fd1fabe80687738a1171ff1f246f
|
4
|
+
data.tar.gz: 8de53b0fbb61e1b8b58b6e1df8983b1295ee7f8a686bfb0bd78bd1117592d653
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55124eb1c3f00332b47ddc2b09143faaf77192c59f0971edc88a107e472fe69094fa8fd84e9d1c74b856f4998f837622aa0513b15c4570674f49301f9ea7cf5c
|
7
|
+
data.tar.gz: 5b74c1fa03009b91706471f00eb5905a1c92a4e13583462cd554022fda6d8b45aab214f7d52f48987f0b36f1e7116cc273c27a1d0a3ec016172ff0480245c99c
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
Metrics/LineLength:
|
2
2
|
Max: 120
|
3
3
|
|
4
|
+
Metrics/BlockLength:
|
5
|
+
Exclude:
|
6
|
+
- spec/*
|
7
|
+
|
4
8
|
Style/Documentation:
|
5
9
|
Enabled: false
|
6
10
|
|
@@ -10,3 +14,6 @@ Style/GuardClause:
|
|
10
14
|
|
11
15
|
Style/FrozenStringLiteralComment:
|
12
16
|
Enabled: false
|
17
|
+
|
18
|
+
Style/ModuleFunction:
|
19
|
+
Enabled: false
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -32,6 +32,24 @@ CatIpsum.paragraph
|
|
32
32
|
|
33
33
|
`CatIpsum.sentences` and `CatIpsum.paragraphs` returns arrays of their original methods.
|
34
34
|
|
35
|
+
All of the methods could take integer parameter to configure count of sentence parts or elements in array.
|
36
|
+
Some examples:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
CatIpsum.sentence(1)
|
40
|
+
# => "Stand in front of the computer screen."
|
41
|
+
|
42
|
+
CatIpsum.sentence(2)
|
43
|
+
# => "Get on the high shelf, swat at dog."
|
44
|
+
|
45
|
+
CatIpsum.sentences(1)
|
46
|
+
#=> ["Play time, stretch, need to chase tail."]
|
47
|
+
|
48
|
+
CatIpsum.sentences(2)
|
49
|
+
#=> ["Sleep on keyboard, intently stare at the same spot, sweet beast.", "Intrigued by the shower, rub face on everything, burrow under covers."]
|
50
|
+
|
51
|
+
```
|
52
|
+
|
35
53
|
`CatIpsum.phrase` and `CatIpsum.phrases` are aliases to `CatIpsum.sentence` and `CatIpsum.sentence`.
|
36
54
|
|
37
55
|
#### Working with randomizing seeds
|
data/lib/cat_ipsum.rb
CHANGED
@@ -5,23 +5,23 @@ require 'cat_ipsum/random'
|
|
5
5
|
module CatIpsum
|
6
6
|
extend self
|
7
7
|
|
8
|
-
def sentence
|
9
|
-
Random.sample(CAT_ACTIONS.dup).join(', ').capitalize
|
8
|
+
def sentence(actions_count = 3)
|
9
|
+
Random.sample(CAT_ACTIONS.dup, count: actions_count).join(', ').capitalize + '.'
|
10
10
|
end
|
11
11
|
|
12
12
|
alias phrase sentence
|
13
13
|
|
14
|
-
def sentences(
|
15
|
-
(1..
|
14
|
+
def sentences(sentences_count = 5)
|
15
|
+
(1..sentences_count).map { sentence }
|
16
16
|
end
|
17
17
|
|
18
18
|
alias phrases sentences
|
19
19
|
|
20
|
-
def paragraph
|
21
|
-
sentences.join('
|
20
|
+
def paragraph(sentences_count = 5)
|
21
|
+
sentences(sentences_count).join(' ')
|
22
22
|
end
|
23
23
|
|
24
|
-
def paragraphs(
|
25
|
-
(1..
|
24
|
+
def paragraphs(paragraphs_count = 5)
|
25
|
+
(1..paragraphs_count).map { paragraph }
|
26
26
|
end
|
27
27
|
end
|
data/lib/cat_ipsum/random.rb
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
module CatIpsum
|
2
2
|
class Random
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
class << self
|
4
|
+
def seed
|
5
|
+
@seed ||= ::Random.new_seed
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def seed=(value)
|
9
|
+
@seed = value
|
10
|
+
reset!
|
11
|
+
value
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
def reset!
|
15
|
+
@randomizer = randomize
|
16
|
+
true
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def randomizer
|
20
|
+
@randomizer ||= randomize
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
def randomize
|
24
|
+
::Random.new(seed)
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
def sample(array, count: 3)
|
28
|
+
array.shuffle(random: randomizer).take(count)
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
data/lib/cat_ipsum/version.rb
CHANGED