fake_go_up 0.2.0 → 0.2.1

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: a0de6d5060c4acaaab92fc40d85d5ab8759f3344
4
- data.tar.gz: 89ef88ceadbd74001589cce7c50335967e6aa50f
3
+ metadata.gz: 8abfd9b0f85dd9abf41d8027f25307a97ebd294f
4
+ data.tar.gz: f35e2d685e67d2b205ca3b72c73cc5f523d34504
5
5
  SHA512:
6
- metadata.gz: d05d52cbfb65624269c33bfbfb5c58566c86a833f97da14391418f63cc0c404e540f6bd424a1819d63c36b24c29c3ac88428a00c41cc3dfb68da2ef6c748e968
7
- data.tar.gz: 9464ee40a1b5d6152c49d5cfbb28f08584f5513e05c1ca78e021052cef1de480fc8eaf634efd2d1a9926b3a819c4a1d6a83490c8b4c8669269c87ee9c8435c47
6
+ metadata.gz: 8a2edb9edbf3defef8f41a8979306a708a1ae88928632a9e3d6fc0907e1d5925013cd985d218d329d3e9dd23bf702ce3bf5585cd549a5968eaeb9b5fbc0017f9
7
+ data.tar.gz: e999f3460f3fee43400f7d522c59b6c978795ae37d8b9ce20f73589769b9425103a633980990739b90c76bcb205a8675085942c5e3e9afba10167f447ba52d8b
@@ -4,8 +4,8 @@ module FakeGoUp
4
4
  attr_reader :cur_step
5
5
 
6
6
  MAX_INTERVAL = 24 * 60 * 60
7
- @@max_fake_count = 20
8
- @@interval = 1
7
+ @max_fake_count = 20
8
+ @interval = 1
9
9
  @@subclass = []
10
10
 
11
11
  def initialize
@@ -21,7 +21,7 @@ module FakeGoUp
21
21
  end
22
22
 
23
23
  def go_up
24
- return unless self.cur_step % self.interval == 0
24
+ return unless self.cur_step % self.class.interval == 0
25
25
  FakeGoUp.redis.hkeys(self.class.hash_key).each do |field|
26
26
  go_up_one_field(field)
27
27
  end
@@ -30,7 +30,7 @@ module FakeGoUp
30
30
 
31
31
  def go_up_one_field(field)
32
32
  remain_count = FakeGoUp.redis.hget(self.class.hash_key, field).to_i
33
- fake_count = rand(@@max_fake_count)
33
+ fake_count = rand(self.class.max_fake_count)
34
34
  if remain_count < fake_count
35
35
  fake_count = remain_count
36
36
  FakeGoUp.redis.hdel(self.class.hash_key, field)
@@ -48,23 +48,11 @@ module FakeGoUp
48
48
  end
49
49
  end
50
50
 
51
- def interval
52
- @@interval
53
- end
54
-
55
51
  def next_step
56
52
  @cur_step = (@cur_step + 1) % MAX_INTERVAL
57
53
  end
58
54
 
59
55
  class << self
60
- def interval(i)
61
- @@interval = i
62
- end
63
-
64
- def max_fake_count(count)
65
- @@max_fake_count = count
66
- end
67
-
68
56
  def queue_up(item, count)
69
57
  field = item_to_field(item)
70
58
  FakeGoUp.redis.hset(self.hash_key, field, count)
@@ -75,6 +63,14 @@ module FakeGoUp
75
63
  FakeGoUp.redis.hget(self.hash_key, field).to_i
76
64
  end
77
65
 
66
+ def interval
67
+ @interval
68
+ end
69
+
70
+ def max_fake_count
71
+ @max_fake_count
72
+ end
73
+
78
74
  def running?(item)
79
75
  field = item_to_field(item)
80
76
  FakeGoUp.redis.hkeys(self.hash_key).include?(field)
@@ -1,3 +1,3 @@
1
1
  module FakeGoUp
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - xuxiangyang