facets 2.8.3 → 2.8.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,27 @@
1
1
  = Facets Release History
2
2
 
3
- == 2.8.3 / 2009-04-10
3
+ == 2.8.4 / 2010-04-27
4
+
5
+ This release primarily fixes a small bug that prevents
6
+ facets.rb from loading correctly, namely reopening
7
+ ObjectSpace as a class rather than a modules.
8
+
9
+ Changes:
10
+
11
+ * 1 Bug Fix
12
+
13
+ * bug: ObjectSpace is a module, not a class
14
+
15
+ * 5 Minor Enhancements
16
+
17
+ * Hash#to_proc takes response argument replacing #to_proc_with_response.
18
+ * Add #respond_to? as BasicObject exception.
19
+ * Global lambda can be used instead of ObjectSpace.reflect.
20
+ * For compatability with 1.9.2, #singleton_class no longer takes a block.
21
+ * Ruby 1.9 is embracing try_ notation, so we will use #try_dup instead of #dup!
22
+
23
+
24
+ == 2.8.3 / 2010-04-10
4
25
 
5
26
  New release which makes a few adjustments in Kernel core extensions,
6
27
  adds a few new extensions and additions, plus other small improvements.
@@ -1,8 +1,8 @@
1
1
  class Hash
2
2
 
3
- # Constructs a Proc object from a hash such
4
- # that the parameter of the Proc is assigned
5
- # the hash keys as attributes.
3
+ # Constructs a Proc object from a hash such that
4
+ # the parameter of the Proc is assigned the hash
5
+ # keys as attributes.
6
6
  #
7
7
  # h = { :a => 1 }
8
8
  # p = h.to_proc
@@ -10,29 +10,26 @@ class Hash
10
10
  # p.call(o)
11
11
  # o.a #=> 1
12
12
  #
13
- # CREDIT: Trans
14
-
15
- def to_proc
16
- lambda do |o|
17
- self.each do |k,v|
18
- ke = "#{k}="
19
- o.__send__(ke, v)
20
- end
21
- end
22
- end
23
-
24
- # A fault-tolerent version of #to_proc.
25
- #
26
- # It works just like #to_proc, but the block will make
27
- # sure the object responds to the assignment.
13
+ # If +response+ is set to +true+, then assignment
14
+ # will only occur if receiver responds_to? the
15
+ # writer method.
28
16
  #
29
17
  # CREDIT: Trans
30
18
 
31
- def to_proc_with_response
32
- lambda do |o|
33
- self.each do |k,v|
34
- ke = "#{k}="
35
- o.__send__(ke, v) if respond_to?(ke)
19
+ def to_proc(response=false)
20
+ if response
21
+ lambda do |o|
22
+ self.each do |k,v|
23
+ ke = "#{k}="
24
+ o.__send__(ke, v) if respond_to?(ke)
25
+ end
26
+ end
27
+ else
28
+ lambda do |o|
29
+ self.each do |k,v|
30
+ ke = "#{k}="
31
+ o.__send__(ke, v)
32
+ end
36
33
  end
37
34
  end
38
35
  end
@@ -1,63 +1 @@
1
- module Kernel
2
- # Override this in a child class if it cannot be dup'ed.
3
- #
4
- # CREDIT: Dan Kubb (extlib)
5
- def dup!
6
- dup
7
- end
8
-
9
- # Original name for dup! as defined by extlib.
10
- # This will eventually be deprecated. Use #dup! instead.
11
- def try_dup
12
- dup!
13
- end
14
- end
15
-
16
- class TrueClass
17
- # Since TrueClass is immutable it cannot be duplicated.
18
- # For this reason #dup! returns +self+.
19
- def dup!
20
- self
21
- end
22
- end
23
-
24
- class FalseClass
25
- # Since FalseClass is immutable it cannot be duplicated.
26
- # For this reason #dup! returns +self+.
27
- def dup!
28
- self
29
- end
30
- end
31
-
32
- class NilClass
33
- # Since NilClass is immutable it cannot be duplicated.
34
- # For this reason #dup! returns +self+.
35
- def dup!
36
- self
37
- end
38
- end
39
-
40
- class Numeric
41
- # Since Numeric is immutable it cannot be duplicated.
42
- # For this reason #dup! returns +self+.
43
- def dup!
44
- self
45
- end
46
- end
47
-
48
- class Symbol
49
- # Since Symbol is immutable it cannot be duplicated.
50
- # For this reason #dup! returns +self+.
51
- def dup!
52
- self
53
- end
54
- end
55
-
56
- #class Module
57
- # # Since Module is immutable it cannot be duplicated.
58
- # # For this reason #dup! returns +self+.
59
- # def dup!
60
- # self
61
- # end
62
- #end
63
-
1
+ require 'facets/kernel/try_dup'
@@ -1,19 +1,20 @@
1
1
  module Kernel
2
2
 
3
- # Easy access to an object's "special" class,
3
+ # Easy access to an object's "special" class.
4
4
  #
5
- # One day these names must be reconciled!
5
+ # <b>This is part of Ruby as of 1.9.2+.</b>
6
+ #
7
+ # NOTE: This used to support a class eval block,
8
+ # but to comply with Ruby 1.9.2's definition
9
+ # it has been removed.
6
10
 
7
11
  def singleton_class(&block)
8
- if block_given?
9
- (class << self; self; end).class_eval(&block)
10
- else
12
+ #if block_given?
13
+ # (class << self; self; end).class_eval(&block)
14
+ #else
11
15
  (class << self; self; end)
12
- end
13
- end
14
-
15
- # Deprecate?
16
- alias_method :singleton, :singleton_class
16
+ #end
17
+ end unless method_defined? :singleton_class
17
18
 
18
19
  end
19
20
 
@@ -1 +1,63 @@
1
- require 'facets/kernel/dup'
1
+ module Kernel
2
+ # Override this in a child class if it cannot be dup'ed.
3
+ #
4
+ # CREDIT: Dan Kubb (extlib)
5
+ def try_dup
6
+ dup
7
+ end
8
+
9
+ # Alternative name for #try_dup.
10
+ # This will eventually be deprecated.
11
+ def dup!
12
+ try_dup
13
+ end
14
+ end
15
+
16
+ class TrueClass
17
+ # Since TrueClass is immutable it cannot be duplicated.
18
+ # For this reason #try_dup returns +self+.
19
+ def try_dup
20
+ self
21
+ end
22
+ end
23
+
24
+ class FalseClass
25
+ # Since FalseClass is immutable it cannot be duplicated.
26
+ # For this reason #try_dup returns +self+.
27
+ def try_dup
28
+ self
29
+ end
30
+ end
31
+
32
+ class NilClass
33
+ # Since NilClass is immutable it cannot be duplicated.
34
+ # For this reason #try_dup returns +self+.
35
+ def try_dup
36
+ self
37
+ end
38
+ end
39
+
40
+ class Numeric
41
+ # Since Numeric is immutable it cannot be duplicated.
42
+ # For this reason #try_dup returns +self+.
43
+ def try_dup
44
+ self
45
+ end
46
+ end
47
+
48
+ class Symbol
49
+ # Since Symbol is immutable it cannot be duplicated.
50
+ # For this reason #try_dup returns +self+.
51
+ def try_dup
52
+ self
53
+ end
54
+ end
55
+
56
+ #class Module
57
+ # # Since Module is immutable it cannot be duplicated.
58
+ # # For this reason #try_dup returns +self+.
59
+ # def try_dup
60
+ # self
61
+ # end
62
+ #end
63
+
@@ -1,6 +1,6 @@
1
1
  require 'facets/functor'
2
2
 
3
- class << ObjectSpace
3
+ module ObjectSpace
4
4
 
5
5
  # Reflection ensures that information about an object
6
6
  # is actual according to Ruby's Kernel definitions, just
@@ -12,7 +12,7 @@ class << ObjectSpace
12
12
  # There is also a global short-cut for this method to ease
13
13
  # meta-programming with it.
14
14
  #
15
- # $ref[obj].id
15
+ # $ref[obj].class
16
16
  #++
17
17
  #
18
18
  # Typically theis method will be used to gather the object's
@@ -30,7 +30,7 @@ class << ObjectSpace
30
30
  # But obviously, in this case there is the risk that #as has
31
31
  # be overridden too.
32
32
  #
33
- def reflect(obj)
33
+ def self.reflect(obj)
34
34
  Functor.new do |meth, *a, &b|
35
35
  Kernel.instance_method(meth).bind(obj).call(*a, &b)
36
36
  end
@@ -38,8 +38,10 @@ class << ObjectSpace
38
38
 
39
39
  end
40
40
 
41
- # TODO: Consider this "Shorcut for +ObjectSpace.reflect+."
42
- #$ref = lambda do |obj|
43
- # ObjectSpace.reflect(obj)
44
- #end
41
+ # Shorcut for +ObjectSpace.reflect+.
42
+ $ref = lambda do |obj|
43
+ Functor.new do |meth, *a, &b|
44
+ Kernel.instance_method(meth).bind(obj).call(*a, &b)
45
+ end
46
+ end
45
47
 
@@ -4,7 +4,7 @@
4
4
  # Copyright 2004 by Jim Weirich (jim@weirichhouse.org).
5
5
  # All rights reserved.
6
6
  #
7
- # Since Ruby 1.9 has a BasicObject class this will of course be
7
+ # Since Ruby 1.9 has a BasicObject class this will of course be
8
8
  # deprecated as 1.9 goes mainstream.
9
9
 
10
10
  unless defined? BasicObject # just in case it already exists!
@@ -27,12 +27,13 @@ unless defined? BasicObject # just in case it already exists!
27
27
  # * #==
28
28
  # * #!
29
29
  # * #!=
30
+ # * respond_to?
30
31
  #
31
32
  # Seems to me it should have #__id__ too.
32
33
  def hide(name)
33
34
  undef_method name if
34
35
  instance_methods.include?(name.to_s) and
35
- name !~ /^(__|instance_eval$|instance_exec$|equal\?$|\=\=$)/
36
+ name !~ /^(__|respond_to\?|instance_eval$|instance_exec$|equal\?$|\=\=$)/
36
37
  end
37
38
  end
38
39
  instance_methods.each { |m| hide(m) }
@@ -1 +1 @@
1
- 2.8.3
1
+ 2.8.4
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 8
8
- - 3
9
- version: 2.8.3
8
+ - 4
9
+ version: 2.8.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Thomas Sawyer <transfire@gmail.com>
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-10 00:00:00 -04:00
17
+ date: 2010-04-27 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies: []
20
20