fake_go_up 0.1.1 → 0.1.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
  SHA1:
3
- metadata.gz: cca1ff6ff1accf77506aa08deb0f82bbf79d96ec
4
- data.tar.gz: 32d4c79f084a4363a821312ccc86d2bfc850e4a3
3
+ metadata.gz: e09f267aa34d168abd3e05189699dbb8cef1e882
4
+ data.tar.gz: 05ff1d6d0b87654353df698e737a7a8131568652
5
5
  SHA512:
6
- metadata.gz: 527a08987cde9dfdd43e8c09cc2c67e3c27c4e1710d4a56d3fd6b9e3e1f26b9a0872ce88c25b5ce0abf694ff9eeb7b4df6a3780c1622566cfbe5e921194651b4
7
- data.tar.gz: 337bfda306f64d4c52ab4c7adb4b4658fdc350defb6c91509d10266b56534195eaf5f5949133e9ff28fe13c0752a81e2ac62c75f9829fcb41df64a6068ab1cc0
6
+ metadata.gz: c79c2010a2e6cdbafdcbd7ad25a381e1ebe51a5c248a71d9a98ad9a5d18a1a831a09132e5d65e835851a9530d3e0225cac789a688c567201e202c58e0d3248c4
7
+ data.tar.gz: 66423a74413673a850449fa03ba2fec7013ec45bd77f2d5202c75ac5295dfb4bc070dde068df4e92e85dedc7835232708c8fa0821a09fc62ee0f7195a5962827
data/README.md CHANGED
@@ -1,8 +1,5 @@
1
1
  # FakeGoUp
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/fake_go_up`. 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
2
+ If you need add fake favor's count, you could use this gem。
6
3
 
7
4
  ## Installation
8
5
 
@@ -22,7 +19,42 @@ Or install it yourself as:
22
19
 
23
20
  ## Usage
24
21
 
25
- TODO: Write usage instructions here
22
+ you should init the redis before your app star, like this
23
+ ```ruby
24
+ FakeGoUp.redis = $redis #$redis is your redis instance
25
+ ```
26
+
27
+ then, you should define your own voter under `lib/voters`。such as `test_voter.rb`
28
+ each voter should do things as little as possible. each interval`s unit is at least 1 second.
29
+ it is simple,and it is not parallel !!!
30
+ ```ruby
31
+ #lib/voters/test_voter.rb
32
+ class TestVoter < FakeGoUp
33
+ max_fake_count 20 #max fake count per interval, default is 20
34
+ interval 1 #seconds per interval
35
+ def process(item, fake_count)
36
+ #you should overwrite this func, and item is a active record project
37
+ end
38
+ end
39
+ ```
40
+
41
+ then you should run a rake per 5-10 times, like this
42
+ ```ruby
43
+ #lib/tasks/fake_go_up.rake
44
+ namespace :fake_go_up do
45
+ task :run => :environment do
46
+ FakeGoUp.run
47
+ end
48
+ end
49
+ ```
50
+ `FakeGoUp.run` will never stop until all jobs finish. you should run a rake to check if there is new jobs. if there is a running fake_go_up, if will not star a new fake_go_up.
51
+
52
+ now `TestVoter` provide theses func
53
+ ```
54
+ t = TestVoter.new
55
+ TestVoter.remain(t) # => the t`s remain fake count needs to add
56
+ TestVoter.running?(t) # => if the t`s fake_go_up is running?
57
+ ```
26
58
 
27
59
  ## Development
28
60
 
@@ -1,3 +1,3 @@
1
1
  module FakeGoUp
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/fake_go_up.rb CHANGED
@@ -25,7 +25,17 @@ module FakeGoUp
25
25
 
26
26
  def _run
27
27
  tasks = FakeGoUp::Task.subclasses.map(&:new)
28
- while true
28
+ running = true
29
+
30
+ Signal.trap("TERM") do
31
+ running = false
32
+ end
33
+
34
+ Signal.trap("QUIT") do
35
+ running = false
36
+ end
37
+
38
+ while running
29
39
  all_finish = true
30
40
 
31
41
  tasks.each do |task|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fake_go_up
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - xuxiangyang