cat_ipsum 0.1.1 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7174565573059bb5af3d3de858112d82935b208c2d1bfee7347b8daaa7469be
4
- data.tar.gz: ed18689514c8b86f9de4c681467b07c8453d708cbdc59e6be83ff641f7ec05c5
3
+ metadata.gz: 81ba3d9e4617f1b55cca3651f877cee50e4c62311ce878a92f3f3213058fd25f
4
+ data.tar.gz: 3c42b4485d7f3cd3b38130f56f01e5541d2f5b90dd24d21a00371de6d233d367
5
5
  SHA512:
6
- metadata.gz: ef1a49e8275f6d1ec567341c82d299c1e4f802133bb2cec9151c61edf08c93aa45672f8aa25f591607bb7cabd139c18cf9e5772e8970b5892f9aed1e4b9f5ff2
7
- data.tar.gz: aa3264e8be8ae26730192ca7027e450915add70d5371ece585da82cdc240a853356577284ebee939ab5718c1b39ab57b739a421039e5e9dc9fe0dc75920cf303
6
+ metadata.gz: ffa0b95efb2e3389027a75bdb5696cec03629f47a82096aabdc9f01ec51ab3ef4af66a5f4d7efb5ff29ddea68ff9c93cf5154c420c1fc89ab6c05427d0ad3cdb
7
+ data.tar.gz: 39129860d8991e0a0dd5792e89c57706d9877575e65fbeb0611d21d7b23e973cfa98adae7e8707f135b3b0cbcc425b4d3cee71bc2a57b61569f2ecefba89d3cc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cat_ipsum (0.1.0)
4
+ cat_ipsum (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # CatIpsum
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cat_ipsum`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This gem generates fake text based on cats' typical activities. Just use it like another Lorem Ipsum version.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,14 +20,30 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ #### Methods
24
+
25
+ ```ruby
26
+ CatIpsum.sentence
27
+ # => "Swat at dog, inspect anything brought into the house, play time"
26
28
 
27
- ## Development
29
+ CatIpsum.paragraph
30
+ # => "Shake treat bag, chase imaginary bugs, why must they do that. Nap all day, stand in doorway, yawn so much. Play time, chew ipad power cord, ignore the human. Need to chase tail, hide when guests come over, throwup on your pillow. Hate dog, mark territory, go crazy"
31
+ ```
28
32
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+ `CatIpsum.sentences` and `CatIpsum.paragraphs` returns arrays of their original methods.
30
34
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+ `CatIpsum.phrase` and `CatIpsum.phrases` are aliases to `CatIpsum.sentence` and `CatIpsum.sentence`.
32
36
 
33
- ## Contributing
37
+ #### Working with randomizing seeds
34
38
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cat_ipsum.
39
+ You can specify your seed to generate repeatable data. Also, seed can be reseted by `CatIpsum.reset!` method.
40
+ Example:
41
+
42
+ ```ruby
43
+ CatIpsum.sentence
44
+ # => "Leave hair everywhere, shake treat bag, missing until dinner time"
45
+ CatIpsum::Random.reset!
46
+ # => true
47
+ CatIpsum.sentence
48
+ # => "Leave hair everywhere, shake treat bag, missing until dinner time"
49
+ ```
@@ -14,7 +14,7 @@ module CatIpsum
14
14
  'destroy couch',
15
15
  'find something else more interesting',
16
16
  'flop over',
17
- 'give attitude',
17
+ 'get on the high shelf',
18
18
  'go crazy',
19
19
  'hate dog',
20
20
  'hide when guests come over',
@@ -29,7 +29,7 @@ module CatIpsum
29
29
  'mark territory',
30
30
  'missing until dinner time',
31
31
  'nap all day',
32
- 'or need to chase tail',
32
+ 'need to chase tail',
33
33
  'play time',
34
34
  'purr',
35
35
  'rub face on everything',
@@ -39,6 +39,7 @@ module CatIpsum
39
39
  'stand in doorway',
40
40
  'stand in front of the computer screen',
41
41
  'stare at ceiling',
42
+ 'start playing with something lying on the floor',
42
43
  'stick butt in face',
43
44
  'stretch',
44
45
  'sun bathe',
@@ -0,0 +1,30 @@
1
+ module CatIpsum
2
+ class Random
3
+ def self.seed
4
+ @seed ||= ::Random.new_seed
5
+ end
6
+
7
+ def self.seed=(value)
8
+ @seed = value
9
+ reset!
10
+ value
11
+ end
12
+
13
+ def self.reset!
14
+ @randomizer = randomize
15
+ true
16
+ end
17
+
18
+ def self.randomizer
19
+ @randomizer ||= randomize
20
+ end
21
+
22
+ def self.randomize
23
+ ::Random.new(seed)
24
+ end
25
+
26
+ def self.sample(array)
27
+ array.shuffle(random: randomizer).take(3)
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module CatIpsum
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.2.1'.freeze
3
3
  end
data/lib/cat_ipsum.rb CHANGED
@@ -1,15 +1,12 @@
1
1
  require 'cat_ipsum/version'
2
2
  require 'cat_ipsum/cat_actions'
3
+ require 'cat_ipsum/random'
3
4
 
4
5
  module CatIpsum
5
6
  extend self
6
7
 
7
8
  def sentence
8
- result = []
9
- rand(1..5).times do
10
- result << CAT_ACTIONS.sample
11
- end
12
- result.join(', ').capitalize
9
+ Random.sample(CAT_ACTIONS.dup).join(', ').capitalize
13
10
  end
14
11
 
15
12
  alias phrase sentence
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cat_ipsum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vsevolod Voloshyn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-07 00:00:00.000000000 Z
11
+ date: 2019-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,6 +99,7 @@ files:
99
99
  - cat_ipsum.gemspec
100
100
  - lib/cat_ipsum.rb
101
101
  - lib/cat_ipsum/cat_actions.rb
102
+ - lib/cat_ipsum/random.rb
102
103
  - lib/cat_ipsum/version.rb
103
104
  homepage: https://github.com/Volosh1n/cat_ipsum
104
105
  licenses: []