platypus 1.0.1 → 1.0.2

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/.ruby CHANGED
@@ -1,4 +1,6 @@
1
1
  ---
2
+ source:
3
+ - Profile
2
4
  authors:
3
5
  - name: Thomas Sawyer
4
6
  - name: Jonas Pfenniger
@@ -7,7 +9,7 @@ copyrights:
7
9
  year: '2004'
8
10
  license: BSD-2-Clause
9
11
  replacements: []
10
- conflicts: []
12
+ alternatives: []
11
13
  requirements:
12
14
  - name: detroit
13
15
  groups:
@@ -18,6 +20,7 @@ requirements:
18
20
  - test
19
21
  development: true
20
22
  dependencies: []
23
+ conflicts: []
21
24
  repositories:
22
25
  - uri: http://rubyworks.github.com/platypus.git
23
26
  scm: git
@@ -26,14 +29,11 @@ resources:
26
29
  home: http://rubyworks.github.com/platypus
27
30
  code: http://github.com/rubyworks/platypus
28
31
  mail: http://googlegroups/group/rubyworks-mailinglist
32
+ extra: {}
29
33
  load_path:
30
34
  - lib
31
- extra: {}
32
- source:
33
- - Profile
34
- alternatives: []
35
35
  revision: 0
36
- version: 1.0.1
36
+ version: 1.0.2
37
37
  name: platypus
38
38
  title: Platypus
39
39
  summary: Riding on Types with Ruby
@@ -41,4 +41,4 @@ created: '2004-01-01'
41
41
  description: Provides a complete double-dispatch type conversion system, method overloadability
42
42
  and psuedo-classes.
43
43
  organization: RubyWorks
44
- date: '2011-10-20'
44
+ date: '2011-10-22'
@@ -0,0 +1,5 @@
1
+ --private
2
+ --readme README.rdoc
3
+ lib
4
+ -
5
+ [A-Z]*.*
@@ -0,0 +1,31 @@
1
+ = COPYRIGHT NOTICES
2
+
3
+ == TPlatypus
4
+
5
+ Copyright:: (c) 2004 Thomas Sawyer, Rubyworks
6
+ License:: BSD-2-Clause
7
+ Website:: http://rubyworks.github.com/platypus
8
+
9
+ Copyright 2011 Thomas Sawyer. All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice,
15
+ this list of conditions and the following disclaimer.
16
+
17
+ 2. Redistributions in binary form must reproduce the above copyright
18
+ notice, this list of conditions and the following disclaimer in the
19
+ documentation and/or other materials provided with the distribution.
20
+
21
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
+ COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
28
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+
@@ -1,5 +1,13 @@
1
1
  = Release History
2
2
 
3
+ == 1.0.2 / 2011-10-22
4
+
5
+ This release fixes a bug that preventd Kernel#case? from being defined.
6
+
7
+ Changes:
8
+
9
+ * Remove Kernel#case? def condition [bug].
10
+
3
11
 
4
12
  == 1.0.1 / 2011-10-19
5
13
 
@@ -1,3 +1,70 @@
1
+ = Platypus
2
+
3
+
4
+ == Type Casting
5
+
6
+ Require the casting library.
7
+
8
+ require 'platypus/typecast'
9
+
10
+ Define a couple of typecasts.
11
+
12
+ class ::String
13
+ typecast ::Regexp do |string|
14
+ /#{string}/
15
+ end
16
+ typecast ::Regexp, :multiline do |string|
17
+ /#{string}/m
18
+ end
19
+ end
20
+
21
+ ::String.typecast ::Integer do |string|
22
+ Integer(string)
23
+ end
24
+
25
+ See that they work.
26
+
27
+ ::Regexp.from("ABC").assert == /ABC/
28
+
29
+ And again.
30
+
31
+ "123".to(::Integer).assert == 123
32
+
33
+
34
+ == Pseudo-Types
35
+
36
+ Require the library.
37
+
38
+ require 'platypus/type'
39
+
40
+ Now we can create types which are psuedo-classes.
41
+
42
+ class KiloType < Type
43
+ condition do |x|
44
+ x.case? Integer
45
+ x.kind_of?(Integer)
46
+ x.respond_to?(:succ)
47
+ x > 1000
48
+ end
49
+ end
50
+
51
+ KiloType.assert === 2000
52
+ KiloType.refute === 999
53
+
54
+ Using the convenience #x method.
55
+
56
+ class MegaType < Type
57
+ x.case? Integer
58
+ x.kind_of?(Integer)
59
+ x.respond_to?(:succ)
60
+ x > 1000000
61
+ end
62
+
63
+ MegaType.refute === 999999
64
+ MegaType.assert === 20000000
65
+
66
+
67
+
1
68
  == Overloadable
2
69
 
3
70
  The Overloadable mixin provides a means for overloading
@@ -55,3 +122,4 @@ Or it will fallback to a non-signiature definition, if one is defined.
55
122
 
56
123
  x.x("Hello", 200)
57
124
 
125
+
@@ -1,8 +1,9 @@
1
1
  module Kernel
2
2
 
3
+ # Dor all matchers === this object.
3
4
  def case?(*matchers)
4
5
  matchers.all?{ |m| m === self }
5
- end unless method_defined?(:case?)
6
+ end
6
7
 
7
8
  end
8
9
 
@@ -24,7 +24,7 @@ require 'platypus/core_ext'
24
24
  #
25
25
  # While TypeCasts are not actual types in the sense they
26
26
  # are not actual classes. They can be used for conversion
27
- # by defining a "from_{class}" class method. In doing so
27
+ # by defining a "from_<class>" class method. In doing so
28
28
  # you should make sure the result of the conversion conforms
29
29
  # to the typecast. You can use the TypeCast.validate method
30
30
  # to make that a bit easier. For instance:
@@ -1,3 +1,3 @@
1
1
  module Platypus
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.2" #:erb: VERSION = "<%= version %>"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: platypus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-10-20 00:00:00.000000000 Z
13
+ date: 2011-10-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: detroit
17
- requirement: &14563700 !ruby/object:Gem::Requirement
17
+ requirement: &24356020 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *14563700
25
+ version_requirements: *24356020
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: qed
28
- requirement: &14562980 !ruby/object:Gem::Requirement
28
+ requirement: &24385900 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *14562980
36
+ version_requirements: *24385900
37
37
  description: Provides a complete double-dispatch type conversion system, method overloadability
38
38
  and psuedo-classes.
39
39
  email:
@@ -41,24 +41,25 @@ executables: []
41
41
  extensions: []
42
42
  extra_rdoc_files:
43
43
  - HISTORY.rdoc
44
+ - SPEC.rdoc
44
45
  - README.rdoc
45
46
  - NOTES.rdoc
47
+ - COPYING.rdoc
46
48
  files:
47
49
  - .ruby
50
+ - .yardopts
48
51
  - lib/platypus/core_ext.rb
49
52
  - lib/platypus/overload.rb
50
53
  - lib/platypus/type.rb
51
54
  - lib/platypus/typecast.rb
52
55
  - lib/platypus/version.rb
53
56
  - lib/platypus.rb
54
- - qed/01_intro.rdoc
55
- - qed/02_typecast.rdoc
56
- - qed/03_type.rdoc
57
- - qed/04_overload.rdoc
58
57
  - test/test_overload.rb
59
58
  - HISTORY.rdoc
59
+ - SPEC.rdoc
60
60
  - README.rdoc
61
61
  - NOTES.rdoc
62
+ - COPYING.rdoc
62
63
  homepage: http://rubyworks.github.com/platypus
63
64
  licenses: []
64
65
  post_install_message:
@@ -1,2 +0,0 @@
1
- = Platypus
2
-
@@ -1,29 +0,0 @@
1
- == Type Casting
2
-
3
- Require the casting library.
4
-
5
- require 'platypus/typecast'
6
-
7
- Define a couple of typecasts.
8
-
9
- class ::String
10
- typecast ::Regexp do |string|
11
- /#{string}/
12
- end
13
- typecast ::Regexp, :multiline do |string|
14
- /#{string}/m
15
- end
16
- end
17
-
18
- ::String.typecast ::Integer do |string|
19
- Integer(string)
20
- end
21
-
22
- See that they work.
23
-
24
- ::Regexp.from("ABC").assert == /ABC/
25
-
26
- And again.
27
-
28
- "123".to(::Integer).assert == 123
29
-
@@ -1,32 +0,0 @@
1
- == Pseudo-Types
2
-
3
- Require the library.
4
-
5
- require 'platypus/type'
6
-
7
- Now we can create types which are psuedo-classes.
8
-
9
- class KiloType < Type
10
- condition do |x|
11
- x.case? Integer
12
- x.kind_of?(Integer)
13
- x.respond_to?(:succ)
14
- x > 1000
15
- end
16
- end
17
-
18
- KiloType.assert === 2000
19
- KiloType.refute === 999
20
-
21
- Using the convenience #x method.
22
-
23
- class MegaType < Type
24
- x.case? Integer
25
- x.kind_of?(Integer)
26
- x.respond_to?(:succ)
27
- x > 1000000
28
- end
29
-
30
- MegaType.assert === 20000000
31
- MegaType.refute === 999999
32
-