cat_ipsum 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81ba3d9e4617f1b55cca3651f877cee50e4c62311ce878a92f3f3213058fd25f
4
- data.tar.gz: 3c42b4485d7f3cd3b38130f56f01e5541d2f5b90dd24d21a00371de6d233d367
3
+ metadata.gz: ecdb29735ddb74f486cc3a1cc4a1248ead45fd1fabe80687738a1171ff1f246f
4
+ data.tar.gz: 8de53b0fbb61e1b8b58b6e1df8983b1295ee7f8a686bfb0bd78bd1117592d653
5
5
  SHA512:
6
- metadata.gz: ffa0b95efb2e3389027a75bdb5696cec03629f47a82096aabdc9f01ec51ab3ef4af66a5f4d7efb5ff29ddea68ff9c93cf5154c420c1fc89ab6c05427d0ad3cdb
7
- data.tar.gz: 39129860d8991e0a0dd5792e89c57706d9877575e65fbeb0611d21d7b23e973cfa98adae7e8707f135b3b0cbcc425b4d3cee71bc2a57b61569f2ecefba89d3cc
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cat_ipsum (0.2.0)
4
+ cat_ipsum (0.2.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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(sentence_count = 5)
15
- (1..sentence_count).map { sentence }
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(paragraph_count = 5)
25
- (1..paragraph_count).map { paragraph }
24
+ def paragraphs(paragraphs_count = 5)
25
+ (1..paragraphs_count).map { paragraph }
26
26
  end
27
27
  end
@@ -1,30 +1,32 @@
1
1
  module CatIpsum
2
2
  class Random
3
- def self.seed
4
- @seed ||= ::Random.new_seed
5
- end
3
+ class << self
4
+ def seed
5
+ @seed ||= ::Random.new_seed
6
+ end
6
7
 
7
- def self.seed=(value)
8
- @seed = value
9
- reset!
10
- value
11
- end
8
+ def seed=(value)
9
+ @seed = value
10
+ reset!
11
+ value
12
+ end
12
13
 
13
- def self.reset!
14
- @randomizer = randomize
15
- true
16
- end
14
+ def reset!
15
+ @randomizer = randomize
16
+ true
17
+ end
17
18
 
18
- def self.randomizer
19
- @randomizer ||= randomize
20
- end
19
+ def randomizer
20
+ @randomizer ||= randomize
21
+ end
21
22
 
22
- def self.randomize
23
- ::Random.new(seed)
24
- end
23
+ def randomize
24
+ ::Random.new(seed)
25
+ end
25
26
 
26
- def self.sample(array)
27
- array.shuffle(random: randomizer).take(3)
27
+ def sample(array, count: 3)
28
+ array.shuffle(random: randomizer).take(count)
29
+ end
28
30
  end
29
31
  end
30
32
  end
@@ -1,3 +1,3 @@
1
1
  module CatIpsum
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cat_ipsum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vsevolod Voloshyn