facets 2.4.0 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/CHANGES +14 -6
  2. data/MANIFEST +35 -18
  3. data/NOTES +5 -15
  4. data/README +1 -11
  5. data/doc/{History.txt → history.rdoc} +0 -0
  6. data/doc/html/api/core/created.rid +1 -1
  7. data/doc/html/api/core/files/CHANGES.html +20 -4
  8. data/doc/html/api/core/files/NOTES.html +44 -15
  9. data/doc/html/api/more/created.rid +1 -1
  10. data/doc/html/api/more/files/CHANGES.html +20 -4
  11. data/doc/html/api/more/files/NOTES.html +46 -15
  12. data/doc/html/changes.html +19 -3
  13. data/doc/html/notes.html +43 -14
  14. data/doc/notes.rdoc +9 -0
  15. data/lib/facets/basex.rb +37 -0
  16. data/lib/facets/basicobject.rb +2 -2
  17. data/lib/facets/date.rb +16 -4
  18. data/lib/facets/exception.rb +1 -0
  19. data/lib/facets/exception/suppress.rb +21 -0
  20. data/lib/facets/hash/argumentize.rb +2 -1
  21. data/lib/facets/kernel.rb +9 -2
  22. data/lib/facets/kernel/__class__.rb +9 -0
  23. data/lib/facets/kernel/__get__.rb +10 -0
  24. data/lib/facets/kernel/__set__.rb +1 -0
  25. data/lib/facets/kernel/instance_assign.rb +41 -0
  26. data/lib/facets/kernel/instance_class.rb +24 -0
  27. data/lib/facets/kernel/instance_send.rb +7 -0
  28. data/lib/facets/kernel/instance_variables.rb +99 -0
  29. data/lib/facets/kernel/object_class.rb +10 -0
  30. data/lib/facets/kernel/object_hexid.rb +12 -0
  31. data/lib/facets/kernel/{object.rb → object_send.rb} +0 -21
  32. data/lib/facets/kernel/silence.rb +25 -19
  33. data/lib/facets/kernel/suppress.rb +18 -0
  34. data/lib/facets/module.rb +3 -0
  35. data/lib/facets/module/basename.rb +31 -0
  36. data/lib/facets/module/modspace.rb +22 -0
  37. data/lib/facets/module/nesting.rb +0 -66
  38. data/lib/facets/module/spacename.rb +25 -0
  39. data/lib/facets/net/smtp_tls.rb +5 -8
  40. data/lib/facets/openhash.rb +1 -0
  41. data/lib/facets/openobject.rb +2 -1
  42. data/lib/facets/paramix.rb +187 -0
  43. data/lib/facets/platform.rb +192 -0
  44. data/lib/facets/recorder.rb +1 -1
  45. data/lib/facets/string.rb +12 -0
  46. data/lib/facets/string/to_time.rb +1 -23
  47. data/lib/facets/style.rb +145 -64
  48. data/lib/facets/time.rb +5 -0
  49. data/lib/facets/time/to_time.rb +14 -0
  50. data/log/{Changelog-0.txt → changelog-0.rdoc} +0 -0
  51. data/log/{Changelog-1.txt → changelog-1.rdoc} +0 -0
  52. data/log/{Changelog.txt → changelog.rdoc} +18 -0
  53. data/log/{Fixme.txt → fixme.rdoc} +3 -3
  54. data/log/testlog.txt +645 -0
  55. data/log/{Todo.txt → todo.rdoc} +80 -89
  56. data/meta/project.yaml +14 -10
  57. data/meta/version +1 -1
  58. data/script/conflicts +28 -3
  59. data/script/methods +32 -43
  60. data/test/kernel/{test_instance.rb → test_instance_assign.rb} +2 -10
  61. data/test/kernel/test_instance_class.rb +12 -0
  62. data/test/kernel/{test_object.rb → test_object_class.rb} +2 -9
  63. data/test/kernel/test_object_hexid.rb +12 -0
  64. data/test/module/test_basename.rb +11 -0
  65. data/test/module/test_modspace.rb +13 -0
  66. data/test/module/test_nesting.rb +0 -17
  67. data/test/module/test_spacename.rb +14 -0
  68. data/test/test_date.rb +12 -0
  69. data/test/test_style.rb +1 -1
  70. data/test/{string → time}/test_to_time.rb +1 -9
  71. metadata +46 -26
  72. data/lib/facets/behavior.rb +0 -104
  73. data/lib/facets/kernel/instance.rb +0 -73
  74. data/lib/facets/string/stylize.rb +0 -73
  75. data/lib/facets/string/underscore.rb +0 -28
  76. data/log/Testlog.txt +0 -205
  77. data/meta/corelibs +0 -49
  78. data/test/string/test_stylize.rb +0 -52
  79. data/test/string/test_underscore.rb +0 -13
@@ -63,7 +63,7 @@
63
63
  </tr>
64
64
  <tr>
65
65
  <td>Modified:</td>
66
- <td>Tue Mar 18 09:42:14 -0400 2008</td>
66
+ <td>Mon Mar 24 19:07:26 -0400 2008</td>
67
67
  </tr>
68
68
  </table>
69
69
  </td></tr>
@@ -77,34 +77,65 @@
77
77
 
78
78
  <div class="description"><h1>Release Notes</h1>
79
79
  <p>
80
- Facets 2.3 makes some nice internal reorganization, rather then just the
81
- split between core/ and more/, we have added class/ and mixin/. This helps
82
- a great deal in working with the library. If does not effect the end-user
83
- in anyway however &#8212;even so we felt it enough to warrent a minor
84
- version bump rather than just a tiny.
80
+ Facets 2.4 is a major step forward for Facets. <a
81
+ href="../classes/It.html">It</a> is perhaps the release that 2.0 should
82
+ have been, but of course it took the actual 2.0 release to make 2.4
83
+ possible. Some annoyances you may have encountered in updating your code to
84
+ 2.0 are now fixed. And from 2.4 on, Facets will now be settling down into
85
+ simple refinement release cycles.
85
86
  </p>
86
87
  <p>
87
- Amoung other changes with this release, cloneable.rb is now a true deep
88
- dup/clone mixin; tracepoint.rb returns to the library; and &#8230;
88
+ The main change under the hood is to bring everything up to the top
89
+ lib/facets/ directory. No longer are the libraries sorted by category. I
90
+ had done so for a long time to make it easier to track the various libs,
91
+ but in the end it was only making it more diffcult to deal with build tools
92
+ and packaging.
89
93
  </p>
90
94
  <p>
91
- As of 2.2.1:
95
+ For the end-user, the largest change is a new emphisis on:
92
96
  </p>
97
+ <pre>
98
+ require 'facets'
99
+ </pre>
93
100
  <p>
94
- This release get rid of the underlying methods subdir. All method redirects
95
- are now in core, to ensure there are no more name clashes.
101
+ This is better than cherry-picking methods. <a
102
+ href="../classes/It.html">It</a> may seem counter- intuitive, but it
103
+ actually proves more advantantages to do this for the sake of
104
+ interoperability than the practice of cherry-picking. The reason is simply
105
+ because others may have cherry-picked different methods, and those
106
+ distinctions go unaccounted and untested.
107
+ </p>
108
+ <p>
109
+ Also with this release, to bolster the use of require &#8216;facets&#8217;,
110
+ some lack-luster extensions have been deprecated and namespace usage has
111
+ been improved. In addition, we are getting very close to full
112
+ ActiveSupport, and Ruby 1.9, interoperability. Expect this to be complete
113
+ in the next minor release or two.
114
+ </p>
115
+ <p>
116
+ This is still a bit of an early release. There remain a few libraries to
117
+ adjust for the new design considerations, but I wanted to get this new
118
+ design out as soon as possible so others could adjust their code sooner
119
+ rather than later. I&#8216;ll be catching up on the CHANGES list over the
120
+ next few minor release.
96
121
  </p>
122
+ <h2>As of 2.3</h2>
97
123
  <p>
98
- As of 2.2.0:
124
+ Amoung other changes with this release, cloneable.rb is now a true deep
125
+ dup/clone mixin; tracepoint.rb returns to the library.
99
126
  </p>
127
+ <h2>As of 2.2.1:</h2>
128
+ <p>
129
+ This release get rid of the underlying methods subdir. All method redirects
130
+ are now in core, to ensure there are no more name clashes.
131
+ </p>
132
+ <h2>As of 2.2.0:</h2>
100
133
  <p>
101
134
  This release provides improved rdocs and prepares facets for use with RUby
102
135
  1.9. <a href="../classes/It.html">It</a> also adds Matthew Harris&#8217;
103
136
  duration.rb library. Bug thanks to Matthew!
104
137
  </p>
105
- <p>
106
- As of 2.1.0:
107
- </p>
138
+ <h2>As of 2.1.0:</h2>
108
139
  <p>
109
140
  Major changes include a new and much-improved command.rb, a new <a
110
141
  href="../classes/BiCrypt.html">BiCrypt</a> class for simple two-way
@@ -8,10 +8,22 @@
8
8
  <div class="content">
9
9
  <div class="main">
10
10
  <h1>Change History</h1>
11
- <h2>2.4.0 / 2008-02-27</h2>
11
+ <h2>2.4.0 / 2008-03-24</h2>
12
12
  <ul>
13
- <li>threaded.rb, map_send, et al, block is passed to send instead of yiedling
14
- on result.
13
+ <li>The Console name space is being deprecated. command.rb and arguments.rb now
14
+ use CLI naemspace.
15
+
16
+ </li>
17
+ <li>#compare_on and #equate_on are now &quot;mixin methods&quot; Comparable()
18
+ and Equateable().
19
+
20
+ </li>
21
+ <li>Enumerable#product, #combintations and #permutations have change to be Ruby
22
+ 1.9 compatible.
23
+
24
+ </li>
25
+ <li>thread.rb, map_send, et al, block is passed to send instead of yiedling on
26
+ result.
15
27
 
16
28
  </li>
17
29
  <li>namespace.rb has been renamed to methodspace.rb.
@@ -34,6 +46,10 @@ application&quot;.
34
46
  <li>Brought back a few web related libs htmlfilter.rb and cssfilter.rb in
35
47
  particular.
36
48
 
49
+ </li>
50
+ <li>This was a fairly large and fast-paced update, so not all changes are
51
+ listed. See RDocs to more information.
52
+
37
53
  </li>
38
54
  </ul>
39
55
  <h2>2.3.0 / 2008-02-01</h2>
@@ -9,34 +9,63 @@
9
9
  <div class="main">
10
10
  <h1>Release Notes</h1>
11
11
  <p>
12
- Facets 2.3 makes some nice internal reorganization, rather then just the
13
- split between core/ and more/, we have added class/ and mixin/. This helps
14
- a great deal in working with the library. If does not effect the end-user
15
- in anyway however &#8212;even so we felt it enough to warrent a minor
16
- version bump rather than just a tiny.
12
+ Facets 2.4 is a major step forward for Facets. It is perhaps the release
13
+ that 2.0 should have been, but of course it took the actual 2.0 release to
14
+ make 2.4 possible. Some annoyances you may have encountered in updating
15
+ your code to 2.0 are now fixed. And from 2.4 on, Facets will now be
16
+ settling down into simple refinement release cycles.
17
17
  </p>
18
18
  <p>
19
- Amoung other changes with this release, cloneable.rb is now a true deep
20
- dup/clone mixin; tracepoint.rb returns to the library; and &#8230;
19
+ The main change under the hood is to bring everything up to the top
20
+ lib/facets/ directory. No longer are the libraries sorted by category. I
21
+ had done so for a long time to make it easier to track the various libs,
22
+ but in the end it was only making it more diffcult to deal with build tools
23
+ and packaging.
21
24
  </p>
22
25
  <p>
23
- As of 2.2.1:
26
+ For the end-user, the largest change is a new emphisis on:
24
27
  </p>
28
+ <pre>
29
+ require 'facets'
30
+ </pre>
25
31
  <p>
26
- This release get rid of the underlying methods subdir. All method redirects
27
- are now in core, to ensure there are no more name clashes.
32
+ This is better than cherry-picking methods. It may seem counter- intuitive,
33
+ but it actually proves more advantantages to do this for the sake of
34
+ interoperability than the practice of cherry-picking. The reason is simply
35
+ because others may have cherry-picked different methods, and those
36
+ distinctions go unaccounted and untested.
37
+ </p>
38
+ <p>
39
+ Also with this release, to bolster the use of require &#8216;facets&#8217;,
40
+ some lack-luster extensions have been deprecated and namespace usage has
41
+ been improved. In addition, we are getting very close to full
42
+ ActiveSupport, and Ruby 1.9, interoperability. Expect this to be complete
43
+ in the next minor release or two.
44
+ </p>
45
+ <p>
46
+ This is still a bit of an early release. There remain a few libraries to
47
+ adjust for the new design considerations, but I wanted to get this new
48
+ design out as soon as possible so others could adjust their code sooner
49
+ rather than later. I&#8217;ll be catching up on the CHANGES list over the
50
+ next few minor release.
28
51
  </p>
52
+ <h2>As of 2.3</h2>
29
53
  <p>
30
- As of 2.2.0:
54
+ Amoung other changes with this release, cloneable.rb is now a true deep
55
+ dup/clone mixin; tracepoint.rb returns to the library.
31
56
  </p>
57
+ <h2>As of 2.2.1:</h2>
58
+ <p>
59
+ This release get rid of the underlying methods subdir. All method redirects
60
+ are now in core, to ensure there are no more name clashes.
61
+ </p>
62
+ <h2>As of 2.2.0:</h2>
32
63
  <p>
33
64
  This release provides improved rdocs and prepares facets for use with RUby
34
65
  1.9. It also adds Matthew Harris&#8217; duration.rb library. Bug thanks to
35
66
  Matthew!
36
67
  </p>
37
- <p>
38
- As of 2.1.0:
39
- </p>
68
+ <h2>As of 2.1.0:</h2>
40
69
  <p>
41
70
  Major changes include a new and much-improved command.rb, a new BiCrypt
42
71
  class for simple two-way crypotgraphy, as well as attr_reader!,
@@ -0,0 +1,9 @@
1
+ == Instance Prefixed Methods
2
+
3
+ Kernel extension prefixed by instance_ which provide
4
+ internal (eg private) access to the object.
5
+ Kernel extension using instance_ prefix which is beneficial
6
+ to separation of metaprogramming from general programming.
7
+ object_ methods, in contrast to the instance_ methods,
8
+ do not access internal state.
9
+
@@ -0,0 +1,37 @@
1
+ class BaseX
2
+
3
+ BASE62 = ["0".."9", "a".."z", "A".."Z"].map { |r| r.to_a }.flatten
4
+
5
+ attr :chars, :base, :values
6
+
7
+ def initialize(chars=BASE62)
8
+ @chars = chars
9
+ @base = @chars.size
10
+ @values = Hash[*(0...@base).map { |i| [ @chars[i], i ] }.flatten]
11
+ end
12
+
13
+ def encode(byte_string)
14
+ convert_base(byte_string.unpack("C*"), 256, @base).map { |d|
15
+ @chars[d]
16
+ }.join('')
17
+ end
18
+
19
+ def decode(encoded)
20
+ convert_base(encoded.split('').map { |c|
21
+ @values[c]
22
+ }, @base, 256).pack("C*")
23
+ end
24
+
25
+ def convert_base(digits, from_base, to_base)
26
+ bignum = 0
27
+ digits.each { |digit| bignum = bignum * from_base + digit }
28
+ converted = []
29
+ until bignum.zero?
30
+ bignum, digit = bignum.divmod to_base
31
+ converted.push digit
32
+ end
33
+ converted.reverse
34
+ end
35
+
36
+ end
37
+
@@ -66,7 +66,7 @@
66
66
  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
67
67
  # FOR A PARTICULAR PURPOSE.
68
68
 
69
- require 'facets/kernel/object'
69
+ require 'facets/kernel/object_class'
70
70
  require 'facets/kernel/as'
71
71
 
72
72
  # = BasicObject
@@ -122,7 +122,7 @@ class BasicObject
122
122
  def object_self
123
123
  @__object_self__ ||= As.new(self, ::Object)
124
124
  end
125
- alias :__self__ :object_self # deprecate
125
+ alias :__self__ :object_self
126
126
 
127
127
  #--
128
128
  # The Self class allows one to get access the hidden Object/Kernel methods.
@@ -20,6 +20,7 @@
20
20
  # FOR A PARTICULAR PURPOSE.
21
21
 
22
22
  require 'date'
23
+ require 'parsedate' # needed for String#to_date
23
24
 
24
25
  class Date
25
26
 
@@ -55,9 +56,8 @@ class Date
55
56
  #
56
57
  # Date.new(2004,2).days_in_month #=> 28
57
58
  #
58
- #--
59
- # Credit goes to Ken Kunz.
60
- #++
59
+ # CREDIT: Ken Kunz.
60
+
61
61
  def days_in_month
62
62
  Date.civil(year, month, -1).day
63
63
  end
@@ -68,7 +68,7 @@ class Date
68
68
 
69
69
  # Get the month name for this date object
70
70
  #
71
- # CREDIT Benjamin Oakes
71
+ # CREDIT Benjamin Oakes
72
72
 
73
73
  def month_name
74
74
  MONTHNAMES[self.month]
@@ -76,3 +76,15 @@ class Date
76
76
 
77
77
  end
78
78
 
79
+ class String
80
+
81
+ # Parse data from string.
82
+ #
83
+ # CREDIT: Trans
84
+
85
+ def to_date
86
+ ::Date::civil(*ParseDate.parsedate(self)[0..2])
87
+ end
88
+
89
+ end
90
+
@@ -1 +1,2 @@
1
1
  require 'facets/exception/detail.rb'
2
+ require 'facets/exception/suppress.rb'
@@ -0,0 +1,21 @@
1
+ class Exception
2
+
3
+ # Supress errors while executing a block, with execptions.
4
+ #
5
+ # CREDIT: Trans
6
+ # CREDIT: David Heinemeier Hansson
7
+
8
+ def self.suppress(*exception_classes)
9
+ exception_classes.each do |e|
10
+ unless e < self
11
+ raise ArgumentError, "exception #{e} not a subclass of #{self}"
12
+ end
13
+ end
14
+ begin yield
15
+ rescue Exception => e
16
+ raise unless exception_classes.any? { |cls| e.kind_of?(cls) }
17
+ end
18
+ end
19
+
20
+ end
21
+
@@ -4,7 +4,8 @@ class Hash
4
4
  #
5
5
  # h = { :list => [1,2], :base => "HI" }
6
6
  # h.argumentize #=> [ [], { :list => [1,2], :base => "HI" } ]
7
- # h.argumentize(:list) #=> [ [1,2], { :base => "HI" } ]
7
+ # h.argumentize(:list) #=> [ [1,2], { :base => "HI" } ]
8
+ # h.argumentize(:base) #=> [ ["HI"], { :list => [1,2] } ]
8
9
  #
9
10
  def argumentize(args_field=nil)
10
11
  config = dup
@@ -1,6 +1,8 @@
1
1
  require 'facets/ruby'
2
2
 
3
3
  require 'facets/kernel/__dir__.rb'
4
+ require 'facets/kernel/__get__.rb'
5
+ require 'facets/kernel/__set__.rb'
4
6
  require 'facets/kernel/as.rb'
5
7
  require 'facets/kernel/complete.rb'
6
8
  require 'facets/kernel/constant.rb'
@@ -8,15 +10,20 @@ require 'facets/kernel/d.rb'
8
10
  require 'facets/kernel/deep_copy.rb'
9
11
  require 'facets/kernel/ergo.rb'
10
12
  require 'facets/kernel/here.rb'
11
- require 'facets/kernel/instance.rb'
13
+ require 'facets/kernel/instance_assign.rb' # DEPRECATE
14
+ require 'facets/kernel/instance_class.rb'
15
+ require 'facets/kernel/instance_send.rb'
12
16
  require 'facets/kernel/load.rb'
13
17
  require 'facets/kernel/not_nil.rb'
14
- require 'facets/kernel/object.rb'
18
+ require 'facets/kernel/object_class.rb'
19
+ require 'facets/kernel/object_hexid.rb'
20
+ require 'facets/kernel/object_send.rb'
15
21
  require 'facets/kernel/p.rb'
16
22
  require 'facets/kernel/populate.rb'
17
23
  require 'facets/kernel/resc.rb'
18
24
  require 'facets/kernel/respond.rb'
19
25
  require 'facets/kernel/silence.rb'
20
26
  require 'facets/kernel/singleton_class.rb'
27
+ require 'facets/kernel/suppress.rb'
21
28
  require 'facets/kernel/with.rb'
22
29
 
@@ -0,0 +1,9 @@
1
+ module Kernel
2
+
3
+ # Defines core method __class__ as an alias of class.
4
+ # This allows you to use #class as your own method, without
5
+ # loosing the ability to determine the object's class.
6
+
7
+ alias_method :__class__, :class
8
+
9
+ end
@@ -0,0 +1,10 @@
1
+ module Kernel
2
+
3
+ # Shadow method for instance_variable_get.
4
+ alias_method :__get__, :instance_variable_get
5
+
6
+ # Shadow method for instance_variable_set.
7
+ alias_method :__set__, :instance_variable_set
8
+
9
+ end
10
+
@@ -0,0 +1 @@
1
+ require 'facets/kernel/__get__'
@@ -0,0 +1,41 @@
1
+ module Kernel
2
+
3
+ # Return instance variable values in an array.
4
+ #
5
+ # class X
6
+ # def initialize(a,b)
7
+ # @a, @b = a, b
8
+ # end
9
+ # end
10
+ #
11
+ # x = X.new(1,2)
12
+ #
13
+ # x.instance_values #=> { "a"=>1, "b"=>2 }
14
+ #
15
+ # WARNING: #instance_values will be deprecated. Use instance_vars.to_hash instead.
16
+
17
+ def instance_values
18
+ instance_variables.inject({}) do |values, name|
19
+ values[name[1..-1]] = instance_variable_get(name)
20
+ values
21
+ end
22
+ end
23
+
24
+ # Set instance variables using a hash.
25
+ #
26
+ # instance_assign('@a'=>1, '@b'=>2)
27
+ # @a #=> 1
28
+ # @b #=> 2
29
+ #
30
+ # WARNING: #instance_assign will be deprecated. Use instance_vars.update instead.
31
+
32
+ def instance_assign(hash)
33
+ hash.each do |k,v|
34
+ k = "@#{k}" if k !~ /^@/
35
+ instance_variable_set(k, v)
36
+ end
37
+ return self
38
+ end
39
+
40
+ end
41
+