coordinator 0.0.11 → 0.0.12

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: 3a50fe82e05aa838a2e83128cdae98480b8affd6
4
- data.tar.gz: 9b206dde729cc0b783f02ab160f4c684b8191355
3
+ metadata.gz: f57530d2f47e8f82ab96f074dfcc9f7f2a08409b
4
+ data.tar.gz: bf2be6add48183ecd18bc27a84f2a8f6ce2762ba
5
5
  SHA512:
6
- metadata.gz: cf60ae757af09e7ae69be4b042a4359f1fa43afb0cd99e7f73c15e9febfb1f69d005e19a0bec81b8db0bf181cc18edfc1782dc30659374c9642692f6761636b1
7
- data.tar.gz: ccc63e3039946241838f5cb8e93a3672a8ad85740018ddc46236c751f3d5e11a1f423399fa318f15a38e27c2c0edfb3f9c687fde49ca86ab588b21886cf725d5
6
+ metadata.gz: 8fc9c5ae89732c5b00a7908f9b1cd049bf73b2a900bb52f60d1fdbfe9a45a0a84045f07d24463aba820d40c206b2a0c437eeceaa3790367fcccb9047a6c9d26f
7
+ data.tar.gz: 17da52136062072f28cdb1cbe2af22bb947599ae8a8a00a1ec799672eef28bbde600fcbcec135bbf0c76e5e613e50e9b673a5109ccb41b4b1cc10bf4154a4790
@@ -36,10 +36,19 @@ module Coordinator
36
36
  queue_for_skill(skill).details
37
37
  end
38
38
 
39
+ def position(skill, task)
40
+ index = queue_for_skill(skill).items.index(task)
41
+ index ? index + 1 : -1
42
+ end
43
+
39
44
  def length_all
40
45
  @queues.inject(0) { |sum, queue| sum + queue.length }
41
46
  end
42
47
 
48
+ def length(skill)
49
+ queue_for_skill(skill).length
50
+ end
51
+
43
52
  def peek_all
44
53
  @queues.map(&:peek).compact
45
54
  end
@@ -1,3 +1,3 @@
1
1
  module Coordinator
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -80,6 +80,21 @@ describe 'Coordinator::Base' do
80
80
  end
81
81
  end
82
82
 
83
+ describe 'length' do
84
+ it 'returns the total amount of tasks for a particular queue' do
85
+ @coordinator.add_task("medium", 1)
86
+ @coordinator.add_task("medium", 2)
87
+ @coordinator.add_task("low", 3)
88
+
89
+ assert_equal 2, @coordinator.length("medium")
90
+ assert_equal 1, @coordinator.length("low")
91
+ end
92
+
93
+ it 'returns 0 for no tasks enqueued' do
94
+ assert_equal 0, @coordinator.length_all
95
+ end
96
+ end
97
+
83
98
  describe 'peek_all' do
84
99
  it 'returns the top item from each queue' do
85
100
  @coordinator.add_task("medium", 1)
@@ -94,4 +109,22 @@ describe 'Coordinator::Base' do
94
109
  assert_equal [], @coordinator.peek_all
95
110
  end
96
111
  end
112
+
113
+ describe 'position' do
114
+ it 'returns the position in the queue' do
115
+ @coordinator.add_task("medium", 1)
116
+ @coordinator.add_task("medium", 2)
117
+ @coordinator.add_task("low", 3)
118
+ @coordinator.add_task("high", 4)
119
+
120
+ assert_equal 1, @coordinator.position("medium", 1)
121
+ assert_equal 2, @coordinator.position("medium", 2)
122
+ assert_equal 1, @coordinator.position("low", 3)
123
+ assert_equal 1, @coordinator.position("high", 4)
124
+ end
125
+
126
+ it 'returns -1 if the task is not in the queue' do
127
+ assert_equal -1, @coordinator.position("medium", 999)
128
+ end
129
+ end
97
130
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coordinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Mercier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-13 00:00:00.000000000 Z
11
+ date: 2014-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http