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 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.all.enrol(class)
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.0
1
+ 2.0
data/lib/typed_set.rb CHANGED
@@ -1,18 +1,10 @@
1
- module TypedSet
2
- def all
3
- TypedSetWrapper.new(self)
1
+ module Kernel
2
+ def all set
3
+ TypedSet.new(set)
4
4
  end
5
5
  end
6
6
 
7
- class Array
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
@@ -1,15 +1,10 @@
1
1
  require 'lib/typed_set'
2
2
 
3
- describe TypedSet do
3
+ describe Kernel do
4
4
 
5
- it "should monkey patch the array class" do
5
+ it "'all' should be available as global function" do
6
6
  array = Array.new
7
- array.respond_to?('all').should be_true
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.all.print_name.should == ['One', 'Two']
18
+ all(printers).print_name.should == ['One', 'Two']
24
19
  end
25
20
  end
data/typed_set.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{typed_set}
8
- s.version = "1.1.0"
8
+ s.version = "2.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Vinh Tran"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typed_set
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
- - 1
7
+ - 2
8
8
  - 1
9
9
  - 0
10
- version: 1.1.0
10
+ version: 2.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Vinh Tran