hamster 0.2.0 → 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.
@@ -1,3 +1,7 @@
1
+ === 0.2.1 / 2010-01-15
2
+
3
+ * Fix bug: List#empty? would cause a stack overflow on very large streams.
4
+
1
5
  === 0.2.0 / 2010-01-14
2
6
 
3
7
  * List methods that return lists are now all lazy. Not sure what, if any, negative impact this will have but the positives have so far been well worth it.
@@ -122,7 +122,7 @@ The following code will only call <tt>prime?</tt> as many times as necessary to
122
122
 
123
123
  Compare that to the conventional equivalent which needs to calculate all possible values in the range before taking the first 3:
124
124
 
125
- (10000..1000000).select { |i| prime?(i) }[0, 3] # => 10s
125
+ (10000..1000000).select { |i| prime?(i) }.take(3) # => 10s
126
126
 
127
127
  Besides <tt>Hamster.list</tt> there are other ways to construct lists:
128
128
 
@@ -488,10 +488,14 @@ module Hamster
488
488
  end
489
489
 
490
490
  def empty?
491
- target.empty?
491
+ list = target
492
+ while list.is_a?(Stream)
493
+ list = list.target
494
+ end
495
+ list.empty?
492
496
  end
493
497
 
494
- private
498
+ protected
495
499
 
496
500
  def target
497
501
  @mutex.synchronize do
@@ -1,5 +1,5 @@
1
1
  module Hamster
2
2
 
3
- VERSION = "0.2.0".freeze
3
+ VERSION = "0.2.1".freeze
4
4
 
5
5
  end
@@ -8,6 +8,18 @@ describe Hamster::List do
8
8
 
9
9
  describe "##{method}" do
10
10
 
11
+ describe "on a really big list" do
12
+
13
+ before do
14
+ @list = Hamster.interval(0, STACK_OVERFLOW_DEPTH)
15
+ end
16
+
17
+ it "doesn't run out of stack" do
18
+ lambda { @list.filter(&:nil?).empty? }.should_not raise_error
19
+ end
20
+
21
+ end
22
+
11
23
  [
12
24
  [[], true],
13
25
  [["A"], false],
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamster
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
  - Simon Harris
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-14 00:00:00 +11:00
12
+ date: 2010-01-15 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency