b-lazy 0.1.2 → 0.1.3

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,7 +1,7 @@
1
1
 
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'b-lazy'
4
- s.version = '0.1.2'
4
+ s.version = '0.1.3'
5
5
  s.date = '2011-02-04'
6
6
  s.summary = "Why work hard for lazy-evaluation?"
7
7
  s.description = "Extends core Ruby objects to provide inherent support for lazy-evaluation."
@@ -370,5 +370,6 @@ module BLazy
370
370
  values.each{|v| out.yield v}
371
371
  end
372
372
  end
373
+ module_function :when_needed
373
374
 
374
375
  end
@@ -0,0 +1,32 @@
1
+
2
+ require 'b-lazy'
3
+
4
+
5
+ describe BLazy do
6
+
7
+ context "#when_needed" do
8
+
9
+ it "will not execute the block when no enumeration is performed" do
10
+ BLazy.when_needed{fail; [1, 2, 3]}
11
+ end
12
+
13
+
14
+
15
+ it "executes the block only once" do
16
+ exec_count = 0
17
+ values = BLazy.when_needed{exec_count += 1; [1, 2, 3]}
18
+ exec_count.should == 0
19
+
20
+ values.next.should == 1
21
+ exec_count.should == 1
22
+
23
+ values.next.should == 2
24
+ exec_count.should == 1
25
+ end
26
+
27
+
28
+
29
+ end
30
+
31
+ end
32
+
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Brian Lauber
@@ -27,8 +27,8 @@ extensions: []
27
27
  extra_rdoc_files: []
28
28
 
29
29
  files:
30
+ - specs/b-lazy_spec.rb
30
31
  - specs/enumerable_spec.rb
31
- - specs/blazy_spec.rb
32
32
  - specs/integer_spec.rb
33
33
  - lib/b-lazy.rb
34
34
  - README
File without changes