facets 2.9.0 → 2.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. data/HISTORY.rdoc +34 -0
  2. data/{meta/profile → PROFILE} +15 -1
  3. data/README.rdoc +11 -17
  4. data/Rakefile +74 -31
  5. data/VERSION +1 -0
  6. data/lib/core-uncommon/facets/array/median.rb +17 -0
  7. data/lib/core-uncommon/facets/array/op_pow.rb +9 -0
  8. data/lib/{tour → core-uncommon}/facets/array/percentile.rb +3 -0
  9. data/lib/{tour → core-uncommon}/facets/class/preallocate.rb +3 -0
  10. data/lib/core-uncommon/facets/enumerable/has.rb +22 -0
  11. data/lib/core-uncommon/facets/enumerable/have.rb +1 -0
  12. data/lib/{tour → core-uncommon}/facets/integer/roman.rb +9 -0
  13. data/lib/{tour → core-uncommon}/facets/kernel/demo.rb +3 -0
  14. data/lib/{tour → core-uncommon}/facets/kernel/eigenclass.rb +3 -0
  15. data/lib/{tour → core-uncommon}/facets/kernel/instance_exec.rb +6 -0
  16. data/lib/{tour → core-uncommon}/facets/kernel/memo.rb +3 -0
  17. data/lib/{tour → core-uncommon}/facets/kernel/trap_chain.rb +3 -0
  18. data/lib/{tour → core-uncommon}/facets/kernel/y.rb +3 -0
  19. data/lib/{tour → core-uncommon}/facets/method/memoize.rb +3 -0
  20. data/lib/{tour → core-uncommon}/facets/module/attr_class_accessor.rb +6 -0
  21. data/lib/{tour → core-uncommon}/facets/module/attr_inheritor.rb +2 -0
  22. data/lib/{tour → core-uncommon}/facets/module/attr_tester.rb +8 -0
  23. data/lib/{tour → core-uncommon}/facets/module/attr_validator.rb +6 -0
  24. data/lib/{tour → core-uncommon}/facets/module/cattr.rb +24 -0
  25. data/lib/core-uncommon/facets/module/class_accessor.rb +33 -0
  26. data/lib/{tour → core-uncommon}/facets/module/class_extend.rb +3 -0
  27. data/lib/{tour → core-uncommon}/facets/module/class_inheritor.rb +3 -0
  28. data/lib/{tour → core-uncommon}/facets/module/copy_inheritor.rb +3 -0
  29. data/lib/{tour → core-uncommon}/facets/module/enclosure.rb +6 -0
  30. data/lib/{tour → core-uncommon}/facets/module/enclosures.rb +0 -0
  31. data/lib/{tour → core-uncommon}/facets/module/include_as.rb +0 -0
  32. data/lib/{tour → core-uncommon}/facets/module/instance_function.rb +2 -0
  33. data/lib/{tour → core-uncommon}/facets/module/memoize.rb +0 -0
  34. data/lib/{tour → core-uncommon}/facets/module/method_space.rb +5 -0
  35. data/lib/{tour → core-uncommon}/facets/module/module_load.rb +6 -0
  36. data/lib/{tour → core-uncommon}/facets/module/preextend.rb +3 -0
  37. data/lib/{tour → core-uncommon}/facets/module/prepend.rb +3 -0
  38. data/lib/{tour → core-uncommon}/facets/regexp/op_or.rb +2 -0
  39. data/lib/{tour → core-uncommon}/facets/string/crypt.rb +3 -0
  40. data/lib/{tour → core-uncommon}/facets/string/roman.rb +0 -0
  41. data/lib/core/facets.rb +19 -0
  42. data/lib/core/facets.yml +1144 -0
  43. data/lib/core/facets/applique/file_helpers.rb +4 -4
  44. data/lib/core/facets/array.rb +0 -1
  45. data/lib/core/facets/binding.rb +1 -1
  46. data/lib/core/facets/class.rb +1 -1
  47. data/lib/core/facets/comparable.rb +1 -1
  48. data/lib/core/facets/dir.rb +1 -1
  49. data/lib/core/facets/dir/recurse.rb +1 -1
  50. data/lib/core/facets/enumerable.rb +1 -1
  51. data/lib/core/facets/exception.rb +1 -1
  52. data/lib/core/facets/file.rb +1 -1
  53. data/lib/core/facets/file/create.rb +1 -1
  54. data/lib/core/facets/file/read_binary.rb +2 -2
  55. data/lib/core/facets/file/rewrite.rb +4 -4
  56. data/lib/core/facets/file/write.rb +1 -1
  57. data/lib/core/facets/file/writelines.rb +1 -1
  58. data/lib/core/facets/filetest.rb +1 -1
  59. data/lib/core/facets/filetest/absolute.rb +1 -0
  60. data/lib/core/facets/filetest/contains.rb +12 -0
  61. data/lib/core/facets/filetest/relative.rb +38 -0
  62. data/lib/core/facets/filetest/safe.rb +20 -0
  63. data/lib/core/facets/filetest/separator_pattern.rb +19 -0
  64. data/lib/core/facets/float.rb +1 -1
  65. data/lib/core/facets/hash.rb +1 -1
  66. data/lib/core/facets/integer.rb +1 -1
  67. data/lib/core/facets/kernel.rb +1 -1
  68. data/lib/core/facets/kernel/no.rb +1 -0
  69. data/lib/core/facets/kernel/object_hexid.rb +3 -1
  70. data/lib/core/facets/kernel/yes.rb +25 -0
  71. data/lib/core/facets/matchdata.rb +1 -1
  72. data/lib/core/facets/method.rb +1 -1
  73. data/lib/core/facets/module.rb +1 -1
  74. data/lib/core/facets/module/redefine_method.rb +4 -4
  75. data/lib/core/facets/nilclass.rb +1 -1
  76. data/lib/core/facets/numeric.rb +1 -1
  77. data/lib/core/facets/object.rb +1 -1
  78. data/lib/core/facets/object/replace.rb +2 -2
  79. data/lib/core/facets/objectspace.rb +1 -1
  80. data/lib/core/facets/proc.rb +1 -1
  81. data/lib/core/facets/process.rb +1 -1
  82. data/lib/core/facets/range.rb +1 -1
  83. data/lib/core/facets/regexp.rb +1 -1
  84. data/lib/core/facets/string.rb +1 -1
  85. data/lib/core/facets/string/file.rb +4 -2
  86. data/lib/core/facets/string/random_binary.rb +10 -0
  87. data/lib/core/facets/string/unquote.rb +1 -1
  88. data/lib/core/facets/struct.rb +1 -1
  89. data/lib/core/facets/symbol.rb +1 -1
  90. data/lib/core/facets/time.rb +1 -1
  91. data/lib/core/facets/unboundmethod.rb +1 -1
  92. data/lib/{more → standard}/facets/basicobject.rb +0 -0
  93. data/lib/{more → standard}/facets/cgi.rb +0 -0
  94. data/lib/{more → standard}/facets/continuation.rb +0 -0
  95. data/lib/{more → standard}/facets/date.rb +0 -0
  96. data/lib/standard/facets/digest.rb +2 -0
  97. data/lib/standard/facets/digest/base64digest.rb +45 -0
  98. data/lib/standard/facets/digest/salted_digest.rb +44 -0
  99. data/lib/{more → standard}/facets/erb.rb +0 -0
  100. data/lib/{more → standard}/facets/fileutils.rb +5 -0
  101. data/lib/standard/facets/fileutils/amass.rb +33 -0
  102. data/lib/{more → standard}/facets/fileutils/cp_rx.rb +3 -1
  103. data/lib/{more → standard}/facets/fileutils/head.rb +0 -0
  104. data/lib/standard/facets/fileutils/ln_r.rb +92 -0
  105. data/lib/standard/facets/fileutils/outofdate.rb +38 -0
  106. data/lib/{more → standard}/facets/fileutils/safe_ln.rb +0 -0
  107. data/lib/{more → standard}/facets/fileutils/slice.rb +14 -12
  108. data/lib/standard/facets/fileutils/stage.rb +66 -0
  109. data/lib/{more → standard}/facets/fileutils/tail.rb +0 -0
  110. data/lib/{more → standard}/facets/fileutils/wc.rb +0 -0
  111. data/lib/{more → standard}/facets/fileutils/whereis.rb +0 -0
  112. data/lib/{more → standard}/facets/fileutils/which.rb +2 -0
  113. data/lib/{more → standard}/facets/find.rb +0 -0
  114. data/lib/{more → standard}/facets/getoptlong.rb +0 -0
  115. data/lib/{more → standard}/facets/math.rb +1 -1
  116. data/lib/{more → standard}/facets/math/abs.rb +0 -0
  117. data/lib/{more → standard}/facets/math/acot.rb +0 -0
  118. data/lib/{more → standard}/facets/math/acoth.rb +0 -0
  119. data/lib/{more → standard}/facets/math/acsc.rb +0 -0
  120. data/lib/{more → standard}/facets/math/acsch.rb +0 -0
  121. data/lib/{more → standard}/facets/math/amd.rb +0 -0
  122. data/lib/{more → standard}/facets/math/approx_equal.rb +1 -1
  123. data/lib/{more → standard}/facets/math/asec.rb +0 -0
  124. data/lib/{more → standard}/facets/math/asech.rb +0 -0
  125. data/lib/{more → standard}/facets/math/atkinson_index.rb +0 -0
  126. data/lib/{more → standard}/facets/math/beta.rb +0 -0
  127. data/lib/{more → standard}/facets/math/cdf.rb +0 -0
  128. data/lib/{more → standard}/facets/math/ceil.rb +0 -0
  129. data/lib/{more → standard}/facets/math/cot.rb +0 -0
  130. data/lib/{more → standard}/facets/math/coth.rb +0 -0
  131. data/lib/{more → standard}/facets/math/csc.rb +0 -0
  132. data/lib/{more → standard}/facets/math/csch.rb +0 -0
  133. data/lib/{more → standard}/facets/math/delta.rb +2 -1
  134. data/lib/{more → standard}/facets/math/epsilon.rb +0 -0
  135. data/lib/{more → standard}/facets/math/exp10.rb +0 -0
  136. data/lib/{more → standard}/facets/math/exp2.rb +0 -0
  137. data/lib/{more → standard}/facets/math/factorial.rb +0 -0
  138. data/lib/{more → standard}/facets/math/floor.rb +0 -0
  139. data/lib/{more → standard}/facets/math/gamma.rb +0 -0
  140. data/lib/{more → standard}/facets/math/gcd.rb +0 -0
  141. data/lib/{more → standard}/facets/math/gini_coefficient.rb +0 -0
  142. data/lib/{more → standard}/facets/math/kldivergence.rb +0 -0
  143. data/lib/{more → standard}/facets/math/lcm.rb +0 -0
  144. data/lib/{more → standard}/facets/math/lgamma.rb +0 -0
  145. data/lib/{more → standard}/facets/math/linsolve.rb +0 -0
  146. data/lib/{more → standard}/facets/math/log2.rb +0 -0
  147. data/lib/{more → standard}/facets/math/max.rb +0 -0
  148. data/lib/{more → standard}/facets/math/mean.rb +0 -0
  149. data/lib/{more → standard}/facets/math/median.rb +0 -0
  150. data/lib/{more → standard}/facets/math/min.rb +0 -0
  151. data/lib/{more → standard}/facets/math/pow.rb +0 -0
  152. data/lib/{more → standard}/facets/math/pstd.rb +0 -0
  153. data/lib/{more → standard}/facets/math/pvariance.rb +0 -0
  154. data/lib/{more → standard}/facets/math/rmd.rb +0 -0
  155. data/lib/{more → standard}/facets/math/root.rb +0 -0
  156. data/lib/{more → standard}/facets/math/sec.rb +0 -0
  157. data/lib/{more → standard}/facets/math/sech.rb +0 -0
  158. data/lib/{more → standard}/facets/math/sign.rb +0 -0
  159. data/lib/{more → standard}/facets/math/sinc.rb +0 -0
  160. data/lib/{more → standard}/facets/math/sqr.rb +0 -0
  161. data/lib/{more → standard}/facets/math/sqsolve.rb +0 -0
  162. data/lib/{more → standard}/facets/math/std.rb +0 -0
  163. data/lib/{more → standard}/facets/math/stderr.rb +0 -0
  164. data/lib/{more → standard}/facets/math/sum.rb +0 -0
  165. data/lib/{more → standard}/facets/math/summed_sqdevs.rb +0 -0
  166. data/lib/{more → standard}/facets/math/theil_index.rb +0 -0
  167. data/lib/{more → standard}/facets/math/variance.rb +0 -0
  168. data/lib/standard/facets/net/http.rb +32 -0
  169. data/lib/{more → standard}/facets/ostruct.rb +0 -0
  170. data/lib/{more → standard}/facets/pathname.rb +1 -0
  171. data/lib/{more → standard}/facets/random.rb +2 -2
  172. data/lib/standard/facets/rbconfig.rb +78 -0
  173. data/lib/{more → standard}/facets/set.rb +0 -0
  174. data/lib/{more → standard}/facets/shellwords.rb +2 -0
  175. data/lib/standard/facets/strscan.rb +16 -0
  176. data/lib/{more → standard}/facets/thread.rb +0 -0
  177. data/lib/{more → standard}/facets/uri.rb +0 -0
  178. data/lib/{more → standard}/facets/yaml.rb +0 -0
  179. data/lib/{more → standard}/facets/zlib.rb +0 -0
  180. data/lib/{more → supplemental}/facets/argvector.rb +0 -0
  181. data/lib/{more → supplemental}/facets/atomicfile.rb +0 -0
  182. data/lib/{more → supplemental}/facets/interval.rb +0 -0
  183. data/lib/{more → supplemental}/facets/main.rb +0 -0
  184. data/lib/{more → supplemental}/facets/memoizable.rb +0 -0
  185. data/lib/{more → supplemental}/facets/metaid.rb +0 -0
  186. data/lib/{more → supplemental}/facets/multipliers.rb +0 -0
  187. data/lib/{more → supplemental}/facets/multiton.rb +0 -0
  188. data/lib/{more → supplemental}/facets/nullclass.rb +0 -0
  189. data/lib/{more → supplemental}/facets/opesc.rb +0 -0
  190. data/lib/{more → supplemental}/facets/platform.rb +156 -5
  191. data/lib/{more → supplemental}/facets/reference.rb +0 -0
  192. data/lib/{more → supplemental}/facets/timer.rb +0 -0
  193. data/lib/{more → supplemental}/facets/tuple.rb +0 -0
  194. data/qed/applique/file_helpers.rb +10 -0
  195. data/qed/{tour → core-uncommon}/module/cattr.rdoc +0 -0
  196. data/qed/{tour → core-uncommon}/module/class_extend.rdoc +0 -0
  197. data/qed/{tour → core-uncommon}/module/class_inheritor.rdoc +0 -0
  198. data/qed/{tour → core-uncommon}/module/copy_inheritor.rdoc +0 -0
  199. data/qed/{tour → core-uncommon}/module/method_space.rdoc +0 -0
  200. data/qed/{more → standard}/basic_object.rdoc +0 -0
  201. data/qed/{more → supplemental}/memoizable.rdoc +0 -0
  202. data/qed/{more → supplemental}/mulititon.rdoc +0 -0
  203. data/test/{tour → core-uncommon}/array/test_median.rb +0 -0
  204. data/test/{tour → core-uncommon}/array/test_percentile.rb +0 -0
  205. data/test/{tour → core-uncommon}/class/test_preallocate.rb +0 -0
  206. data/test/{tour → core-uncommon}/module/test_cattr.rb +0 -0
  207. data/test/{tour → core-uncommon}/module/test_class_extend.rb +0 -0
  208. data/test/{tour → core-uncommon}/module/test_class_inheritor.rb +0 -0
  209. data/test/{tour → core-uncommon}/module/test_copy_inheritor.rb +0 -0
  210. data/test/{tour → core-uncommon}/module/test_enclosure.rb +0 -0
  211. data/test/{tour → core-uncommon}/module/test_instance_function.rb +0 -0
  212. data/test/{tour → core-uncommon}/module/test_memoize.rb +0 -0
  213. data/test/{tour → core-uncommon}/module/test_method_space.rb +0 -0
  214. data/test/{tour → core-uncommon}/module/test_module_load.rb +0 -0
  215. data/test/{tour → core-uncommon}/module/test_preextend.rb +0 -0
  216. data/test/{tour → core-uncommon}/module/test_prepend.rb +0 -0
  217. data/test/core/dir/test_each_child.rb +1 -1
  218. data/test/core/dir/test_multiglob.rb +2 -2
  219. data/test/core/hash/test_zip.rb +12 -0
  220. data/test/core/{kernel → object}/test_dup.rb +51 -1
  221. data/test/core/{kernel → object}/test_object_state.rb +1 -1
  222. data/test/core/{kernel → object}/test_replace.rb +12 -12
  223. data/test/core/{kernel → object}/test_try_dup.rb +2 -2
  224. data/test/{more → standard}/test_date.rb +0 -0
  225. data/test/{more → standard}/test_ostruct.rb +0 -0
  226. data/test/{more → standard}/test_random.rb +0 -0
  227. data/test/{more → standard}/test_shellwords.rb +0 -0
  228. data/test/{more → standard}/test_thread.rb +0 -0
  229. data/test/{more → standard}/test_timer.rb +0 -0
  230. data/test/{more → standard}/test_uri.rb +0 -0
  231. data/test/{more → supplemental}/test_argvector.rb +0 -0
  232. data/test/{more → supplemental}/test_memoizable.rb +0 -0
  233. data/test/{more → supplemental}/test_multipliers.rb +0 -0
  234. data/test/{more → supplemental}/test_tuple.rb +0 -0
  235. metadata +224 -204
  236. data/lib/more/facets/rbconfig.rb +0 -150
  237. data/lib/tour/facets/array/median.rb +0 -14
  238. data/lib/tour/facets/array/op_pow.rb +0 -5
  239. data/lib/tour/facets/module/class_accessor.rb +0 -27
  240. data/meta/data.rb +0 -29
  241. data/meta/package +0 -10
  242. data/test/core/hash/test_zipnew.rb +0 -12
@@ -1,150 +0,0 @@
1
- require 'facets/platform'
2
-
3
- # An extended rendition of the Ruby's standard RbConfig module.
4
- module RbConfig
5
-
6
- #
7
- def self.inspect
8
- CONFIG.inspect
9
- end
10
-
11
- # Methodized lookup of config.
12
- def self.method_missing(s,*a,&b)
13
- s = s.to_s
14
- if CONFIG.key?(s)
15
- CONFIG[s]
16
- elsif CONFIG.key?(s.upcase)
17
- CONFIG[s.upcase]
18
- else
19
- super(s,*a,&b)
20
- end
21
- end
22
-
23
- # TODO: parse configure_args into methods too?
24
-
25
- # In case rubygems has already defined it.
26
- unless method_defined?(:datadir)
27
- # Return the path to the data directory associated with the
28
- # given library/package name. Normally this is just
29
- #
30
- # "#{Config::CONFIG['datadir']}/#{name}"
31
- #
32
- # but may be modified by tools like RubyGems to handle
33
- # versioned data directories.
34
-
35
- def self.datadir(package_name)
36
- File.join(CONFIG['datadir'], package_name)
37
- end
38
- end
39
-
40
- # Determine byte order of underlying machine.
41
- # Examines the byte order of the underlying machine.
42
- # Returns <code>:big</code> if Big Endian and
43
- # <code>:little</code> if Little Endian.
44
- def self.byte_order
45
- if [0x12345678].pack("L") == "\x12\x34\x56\x78"
46
- :big
47
- else
48
- :little
49
- end
50
- end
51
-
52
- def self.byteorder
53
- byte_order
54
- end
55
-
56
- #
57
- def self.little_endian?
58
- byte_order == :little
59
- end
60
-
61
- #
62
- def self.big_endian?
63
- byte_order == :big
64
- end
65
-
66
- #
67
- def self.platform
68
- Platform.local
69
- end
70
-
71
- #
72
- def self.cpu
73
- platform.cpu
74
- end
75
-
76
- #
77
- def self.os
78
- platform.os
79
- end
80
-
81
- #
82
- def self.java?
83
- !(/java/.match(RUBY_PLATFORM).nil?)
84
- end
85
-
86
- #
87
- def self.jruby?
88
- !! /jruby/.match(arch)
89
- end
90
-
91
- #
92
- def self.windows?
93
- !! /mswin/.match(arch)
94
- end
95
-
96
- #
97
- def self.linux?
98
- !! /linux/.match(arch)
99
- end
100
-
101
- =begin
102
- # platform
103
- def current_platform
104
- arch = Config::CONFIG['arch']
105
- #cpu, os = arch.split '-', 2
106
- return match_platform(arch)
107
- end
108
-
109
- #
110
- def match_platform(arch)
111
- cpu, os = arch.split '-', 2
112
- cpu, os = nil, cpu if os.nil? # java
113
-
114
- cpu = case cpu
115
- when /i\d86/ then 'x86'
116
- else cpu
117
- end
118
-
119
- os = case os
120
- when /cygwin/ then [ 'cygwin', nil ]
121
- when /darwin(\d+)?/ then [ 'darwin', $1 ]
122
- when /freebsd(\d+)/ then [ 'freebsd', $1 ]
123
- when /^java$/ then [ 'java', nil ]
124
- when /^java([\d.]*)/ then [ 'java', $1 ]
125
- when /linux/ then [ 'linux', $1 ]
126
- when /mingw32/ then [ 'mingw32', nil ]
127
- when /mswin32/ then [ 'mswin32', nil ]
128
- when /openbsd(\d+\.\d+)/ then [ 'openbsd', $1 ]
129
- when /solaris(\d+\.\d+)/ then [ 'solaris', $1 ]
130
- else [ 'unknown', nil ]
131
- end
132
-
133
- [cpu, os].flatten.compact.join("-")
134
- end
135
- =end
136
-
137
- end
138
-
139
- # Current CPU's Byte Order
140
- BYTE_ORDER = Config.byte_order
141
-
142
- # Current CPU
143
- CPU = Config.platform.cpu
144
-
145
- # Current Operating System
146
- OS = Config.platform.os
147
-
148
- # Current Operating System Version
149
- OS_VERSION = Config.platform.version
150
-
@@ -1,14 +0,0 @@
1
- require 'facets/array/percentile'
2
-
3
- class Array
4
-
5
- # Returns the median for the array; nil if array is empty
6
- #--
7
- # TODO: Does Array#median belong in a math-oriented library?
8
- #++
9
- def median
10
- percentile(50)
11
- end
12
-
13
- end
14
-
@@ -1,5 +0,0 @@
1
- require 'facets/array/product'
2
-
3
- class Array
4
- alias_method :**, :product
5
- end
@@ -1,27 +0,0 @@
1
- class Module
2
-
3
- #
4
- def class_accessor(name)
5
- class_reader(name)
6
- class_writer(name)
7
- end
8
-
9
- #
10
- def class_reader(name)
11
- module_eval(<<-EOS, __FILE__, __LINE__)
12
- def self.#{name}
13
- @#{name}
14
- end
15
- EOS
16
- end
17
-
18
- #
19
- def class_writer(name)
20
- module_eval(<<-EOS, __FILE__, __LINE__)
21
- def self.#{name}=(x)
22
- @#{name} = x
23
- end
24
- EOS
25
- end
26
-
27
- end
@@ -1,29 +0,0 @@
1
- Object.__send__(:remove_const, :VERSION) if Object.const_defined?(:VERSION) # becuase Ruby 1.8~ gets in the way
2
-
3
- module Facets
4
-
5
- def self.__DIR__
6
- File.dirname(__FILE__)
7
- end
8
-
9
- def self.package
10
- @package ||= (
11
- require 'yaml'
12
- YAML.load(File.new(__DIR__ + '/package'))
13
- )
14
- end
15
-
16
- def self.profile
17
- @profile ||= (
18
- require 'yaml'
19
- YAML.load(File.new(__DIR__ + '/profile'))
20
- )
21
- end
22
-
23
- def self.const_missing(name)
24
- key = name.to_s.downcase
25
- package[key] || profile[key] || super(name)
26
- end
27
-
28
- end
29
-
@@ -1,10 +0,0 @@
1
- name: facets
2
- version: 2.9.0
3
- date: 2010-10-01
4
- path: [lib/core, lib/more, lib/tour]
5
-
6
- requires:
7
- - syckle (build)
8
- - lemon (test)
9
- - qed (test)
10
-
@@ -1,12 +0,0 @@
1
- covers 'facets/hash/zipnew'
2
-
3
- testcase Hash do
4
-
5
- metaunit :zipnew do
6
- a = [1,2,3]
7
- b = [4,5,6]
8
- Hash.zipnew(a,b).assert == {1=>4,2=>5,3=>6}
9
- end
10
-
11
- end
12
-