circular_queue 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/circular_queue.gemspec +2 -2
- data/lib/circular_queue.rb +4 -1
- data/spec/circular_queue_spec.rb +11 -0
- metadata +6 -6
data/.gitignore
CHANGED
data/circular_queue.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "circular_queue"
|
6
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.5"
|
7
7
|
s.authors = ["Andy Lindeman"]
|
8
8
|
s.email = ["alindeman@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/alindeman/circular_queue"
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
-
s.add_development_dependency "rspec", "~>2.
|
20
|
+
s.add_development_dependency "rspec", "~>2.11.0"
|
21
21
|
s.add_development_dependency "rake"
|
22
22
|
s.add_development_dependency "yard"
|
23
23
|
end
|
data/lib/circular_queue.rb
CHANGED
@@ -138,7 +138,10 @@ class CircularQueue
|
|
138
138
|
# Allows for easy iteration of queue from front to back
|
139
139
|
def data
|
140
140
|
@mutex.synchronize do
|
141
|
-
@data.clone.
|
141
|
+
@data.clone.tap do |data|
|
142
|
+
data.rotate!(@front)
|
143
|
+
data.slice!(@size..-1)
|
144
|
+
end
|
142
145
|
end
|
143
146
|
end
|
144
147
|
|
data/spec/circular_queue_spec.rb
CHANGED
@@ -120,4 +120,15 @@ describe CircularQueue do
|
|
120
120
|
subject.size.should be_zero
|
121
121
|
end
|
122
122
|
end
|
123
|
+
|
124
|
+
describe "data" do
|
125
|
+
it "allows taking a snapshot of the data in the queue" do
|
126
|
+
subject.enq(1)
|
127
|
+
subject.enq(2)
|
128
|
+
subject.enq(3)
|
129
|
+
subject.deq
|
130
|
+
|
131
|
+
subject.data.should == [2, 3]
|
132
|
+
end
|
133
|
+
end
|
123
134
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: circular_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.
|
21
|
+
version: 2.11.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.
|
29
|
+
version: 2.11.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rake
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
segments:
|
93
93
|
- 0
|
94
|
-
hash: -
|
94
|
+
hash: -1552142011722040456
|
95
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
96
|
none: false
|
97
97
|
requirements:
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
segments:
|
102
102
|
- 0
|
103
|
-
hash: -
|
103
|
+
hash: -1552142011722040456
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project: circular_queue
|
106
106
|
rubygems_version: 1.8.24
|