typed_set 1.1.0 → 2.1.0
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.
- data/README.rdoc +3 -1
- data/VERSION +1 -1
- data/lib/typed_set.rb +4 -12
- data/spec/typed_set_spec.rb +4 -9
- data/typed_set.gemspec +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -8,7 +8,9 @@ This gem purpose is to reduce the for loop in your code. Something like
|
|
8
8
|
|
9
9
|
can be written as:
|
10
10
|
|
11
|
-
students.
|
11
|
+
all(students).enrol(class)
|
12
|
+
|
13
|
+
all is extend to the Kernel module, thus available globally.
|
12
14
|
|
13
15
|
:) not sure how really useful, or harmful it is. Use with care
|
14
16
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0
|
data/lib/typed_set.rb
CHANGED
@@ -1,18 +1,10 @@
|
|
1
|
-
module
|
2
|
-
def all
|
3
|
-
|
1
|
+
module Kernel
|
2
|
+
def all set
|
3
|
+
TypedSet.new(set)
|
4
4
|
end
|
5
5
|
end
|
6
6
|
|
7
|
-
class
|
8
|
-
include TypedSet
|
9
|
-
end
|
10
|
-
|
11
|
-
class Set
|
12
|
-
include TypedSet
|
13
|
-
end
|
14
|
-
|
15
|
-
class TypedSetWrapper
|
7
|
+
class TypedSet
|
16
8
|
|
17
9
|
def initialize set
|
18
10
|
@set = set
|
data/spec/typed_set_spec.rb
CHANGED
@@ -1,15 +1,10 @@
|
|
1
1
|
require 'lib/typed_set'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Kernel do
|
4
4
|
|
5
|
-
it "should
|
5
|
+
it "'all' should be available as global function" do
|
6
6
|
array = Array.new
|
7
|
-
array
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should monkey patch the set class" do
|
11
|
-
set = Set.new
|
12
|
-
set.respond_to?('all').should be_true
|
7
|
+
lambda {all(array)}.should_not raise_error
|
13
8
|
end
|
14
9
|
|
15
10
|
it "should call the method on each element of the set" do
|
@@ -20,6 +15,6 @@ describe TypedSet do
|
|
20
15
|
printer_two.should_receive(:print_name).and_return('Two')
|
21
16
|
printers = [printer_one, printer_two]
|
22
17
|
|
23
|
-
printers.
|
18
|
+
all(printers).print_name.should == ['One', 'Two']
|
24
19
|
end
|
25
20
|
end
|
data/typed_set.gemspec
CHANGED
metadata
CHANGED