ruby_ex 0.4.6.2 → 0.5.5.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.
Files changed (57) hide show
  1. data/NEWS +17 -0
  2. data/README +1 -0
  3. data/SPEC.gemspec +14 -0
  4. data/SPEC.yml +10 -6
  5. data/lib/abstract.rb +3 -4
  6. data/lib/d_logger.rb +3 -3
  7. data/lib/drb/observable_pool.rb +5 -2
  8. data/lib/drb_ex.rb +1 -6
  9. data/lib/exp_mod.rb +48 -0
  10. data/lib/file_type.rb +82 -97
  11. data/lib/kill_all.rb +3 -3
  12. data/lib/{module → module_extensions}/autoload_tree.rb +5 -10
  13. data/lib/{module → module_extensions}/hierarchy.rb +11 -5
  14. data/lib/{module → module_extensions}/instance_method_visibility.rb +7 -5
  15. data/lib/{ordered_hash.rb → o_hash.rb} +8 -13
  16. data/lib/probability_distributions/gaussian_distribution.rb +34 -0
  17. data/lib/probability_distributions/probability_distribution.rb +16 -0
  18. data/lib/probability_distributions/uniform_distribution.rb +12 -0
  19. data/lib/random_generators.rb +1 -3
  20. data/lib/ruby_ex.rb +4 -4
  21. data/lib/sendmail.rb +7 -4
  22. data/lib/sym_tbl_gsub.rb +48 -17
  23. data/lib/uri/file.rb +5 -10
  24. data/lib/uri/ftp_ex.rb +4 -4
  25. data/lib/uri/generic_ex.rb +11 -7
  26. data/lib/uri/http_ex.rb +4 -4
  27. data/lib/uri/mysql.rb +3 -5
  28. data/lib/uri/pgsql.rb +3 -5
  29. data/lib/uri/rsync.rb +2 -4
  30. data/lib/uri/ssh.rb +3 -6
  31. data/lib/uri/svn.rb +10 -12
  32. data/lib/{yaml → yaml_extensions}/chop_header.rb +3 -3
  33. data/lib/{yaml → yaml_extensions}/transform.rb +4 -4
  34. data/lib/{yaml → yaml_extensions}/yregexpath.rb +3 -3
  35. metadata +89 -105
  36. data/lib/commands.rb +0 -27
  37. data/lib/commands/command.rb +0 -545
  38. data/lib/commands/datas.rb +0 -11
  39. data/lib/commands/datas/composite.rb +0 -55
  40. data/lib/commands/datas/data.rb +0 -160
  41. data/lib/commands/datas/factory.rb +0 -74
  42. data/lib/commands/datas/pipe.rb +0 -52
  43. data/lib/commands/datas/temp.rb +0 -24
  44. data/lib/commands/factory.rb +0 -65
  45. data/lib/commands/helpers.rb +0 -76
  46. data/lib/commands/pipe.rb +0 -114
  47. data/lib/commands/runners.rb +0 -11
  48. data/lib/commands/runners/exec.rb +0 -46
  49. data/lib/commands/runners/fork.rb +0 -104
  50. data/lib/commands/runners/mockable.rb +0 -63
  51. data/lib/commands/runners/no_run.rb +0 -44
  52. data/lib/commands/runners/popen.rb +0 -49
  53. data/lib/commands/runners/runner.rb +0 -177
  54. data/lib/commands/runners/system.rb +0 -54
  55. data/lib/commands/seq.rb +0 -31
  56. data/lib/hookable.rb +0 -294
  57. data/lib/hooker.rb +0 -52
data/NEWS CHANGED
@@ -1,3 +1,20 @@
1
+ = New in 0.5, 2007-01-14:
2
+
3
+ * Hooker, Hookable, Commands:
4
+ Moved to objective_command.
5
+
6
+ * URI extensions and FileType:
7
+ Commands are handled with objective_command.
8
+
9
+ * Symtbl:
10
+ Use JSON to stringify complex objects during substitutions.
11
+
12
+ * Some additions:
13
+ exp_mod, probability_distributions.
14
+
15
+ * Fix some bugs:
16
+ Sendmail and multiple receivers, YAML.load_form_io, TempPath...
17
+
1
18
  = New in 0.4_p2, 2006-03-11:
2
19
 
3
20
  Fix a bug in the pathname substitution inside symbol tables.
data/README CHANGED
@@ -1 +1,2 @@
1
+ RubyEx contains general purpose Ruby extensions.
1
2
  Coming Soon. We hope...
data/SPEC.gemspec ADDED
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{ruby_ex}
3
+ s.version = "0.5.5.0"
4
+ s.date = %q{2007-01-14}
5
+ s.summary = %q{RubyEx contains general purpose Ruby extensions.}
6
+ s.email = ["nicolas.despres@gmail.com", "ertai@feydakins.org"]
7
+ s.homepage = %q{http://api.feydakins.org/ruby_ex}
8
+ s.rubyforge_project = %q{ruby_ex}
9
+ s.description = %q{}
10
+ s.authors = ["Nicolas Despr\350s", "Nicolas Pouillard"]
11
+ s.files = ["lib/abstract.rb", "lib/abstract_node.rb", "lib/attributed_class.rb", "lib/auto_object.rb", "lib/blank_slate.rb", "lib/cache.rb", "lib/choose.rb", "lib/concrete.rb", "lib/config_file.rb", "lib/const_regexp.rb", "lib/d_logger.rb", "lib/daemon.rb", "lib/diff.rb", "lib/diff_tools.rb", "lib/drb_ex.rb", "lib/exp_mod.rb", "lib/file_type.rb", "lib/generate_id.rb", "lib/genpasswd.rb", "lib/hash_eval.rb", "lib/histogram.rb", "lib/html_encode.rb", "lib/indexed_node.rb", "lib/io_marshal.rb", "lib/ioo.rb", "lib/kill_all.rb", "lib/labeled_node.rb", "lib/logger_observer.rb", "lib/md5sum.rb", "lib/meta_factory.rb", "lib/method_call.rb", "lib/mocks.rb", "lib/node.rb", "lib/o_hash.rb", "lib/object_monitor.rb", "lib/object_monitor_activity.rb", "lib/observable.rb", "lib/observable_pool.rb", "lib/pp_hierarchy.rb", "lib/r_path.rb", "lib/random_generators.rb", "lib/regex_list.rb", "lib/regex_path.rb", "lib/ruby_ex.rb", "lib/safe_eval.rb", "lib/sendmail.rb", "lib/service_manager.rb", "lib/shuffle.rb", "lib/spring.rb", "lib/spring_set.rb", "lib/sym_tbl.rb", "lib/sym_tbl_gsub.rb", "lib/syn_flow.rb", "lib/text.rb", "lib/timeout_ex.rb", "lib/trace.rb", "lib/verbose_object.rb", "lib/algorithms/simulated_annealing.rb", "lib/drb/insecure_protected_methods.rb", "lib/drb/observable.rb", "lib/drb/observable_pool.rb", "lib/drb/service.rb", "lib/drb/undumped_attributes.rb", "lib/drb/undumped_indexed_object.rb", "lib/mocks/assertions.rb", "lib/mocks/method_logger.rb", "lib/mocks/mock.rb", "lib/mocks/object.rb", "lib/mocks/observer.rb", "lib/module_extensions/autoload_tree.rb", "lib/module_extensions/hierarchy.rb", "lib/module_extensions/instance_method_visibility.rb", "lib/probability_distributions/gaussian_distribution.rb", "lib/probability_distributions/probability_distribution.rb", "lib/probability_distributions/uniform_distribution.rb", "lib/random_generators/random_generator.rb", "lib/random_generators/ruby.rb", "lib/uri/druby.rb", "lib/uri/file.rb", "lib/uri/ftp_ex.rb", "lib/uri/generic_ex.rb", "lib/uri/http_ex.rb", "lib/uri/mysql.rb", "lib/uri/pgsql.rb", "lib/uri/rsync.rb", "lib/uri/ssh.rb", "lib/uri/svn.rb", "lib/yaml_extensions/chop_header.rb", "lib/yaml_extensions/transform.rb", "lib/yaml_extensions/yregexpath.rb", "test/algorithms", "test/check-pkg-ruby_ex.yml", "test/check-ruby_ex.yml", "test/fixtures", "test/functional", "test/sanity", "test/sanity-suite.yml", "test/stress-tests", "test/unit-suite.yml", "test/algorithms/simulated_annealing_test.rb", "test/fixtures/autoload_tree", "test/fixtures/foo.bz2", "test/fixtures/foo.gz.zip", "test/fixtures/foo.rb.gz", "test/fixtures/foo.tar", "test/fixtures/foo.tar.bz2", "test/fixtures/foo.tar.gz", "test/fixtures/foo.txt", "test/fixtures/my_diff.patch", "test/fixtures/tar.gz.log", "test/fixtures/autoload_tree/A.rb", "test/fixtures/autoload_tree/B.rb", "test/fixtures/autoload_tree/foo", "test/fixtures/autoload_tree/foo/C.rb", "test/sanity/multiple-requires.yml", "test/sanity/single-requires.yml", "test/stress-tests/threads_and_exceptions.yml", "AUTHORS", "ChangeLog", "NEWS", "Rakefile", "README", "SPEC.gemspec", "SPEC.yml"]
12
+ s.add_dependency(%q<highline>, [">= 1.0.1"])
13
+ s.add_dependency(%q<core_ex>, ["~> 0.6.5"])
14
+ end
data/SPEC.yml CHANGED
@@ -1,9 +1,11 @@
1
1
  ---
2
2
  Author: The Uttk Team.
3
3
  License: Ruby License
4
- Revision: '$Id: /w/fey/ruby_ex/trunk/SPEC.yml 22445 2006-03-11T15:56:04.480135Z pouillar $'
4
+ Revision: '$Id: /w/fey/ruby_ex/trunk/SPEC.yml 53944 2007-01-14T12:13:14.937281Z ertai $'
5
5
 
6
- version: !feydakins.org,2006/version dev-ruby/ruby_ex-0.4_p2
6
+ version: !feydakins.org,2006/version dev-ruby/ruby_ex-0.5
7
+
8
+ # See also lib/ruby_ex.rb
7
9
 
8
10
  title: RubyEx -- General purpose Ruby extensions.
9
11
  summary: RubyEx contains general purpose Ruby extensions.
@@ -32,9 +34,11 @@ pkg_files: !filelist
32
34
 
33
35
  dependencies:
34
36
  core_ex:
35
- gem: ~> 0.5.5
36
- tarball: 8875/core_ex-0.5.tar.gz
37
+ gem: ~> 0.6.5
38
+ tarball: http://rubyforge.iasi.roedu.net/files/ttk/core_ex-0.6.tar.gz
37
39
  vcs: svn://svn.feydakins.org/ruby_ex/trunk/core_ex
38
- highline: [~> 1.0.1, 5143/highline-1.0.1.tgz]
40
+ highline:
41
+ - >= 1.0.1
42
+ - http://rubyforge.iasi.roedu.net/files/highline/highline-1.2.1.tgz
39
43
 
40
- uttk_version: ~> 0.3.1
44
+ uttk_version: >= 0.3.6.1
data/lib/abstract.rb CHANGED
@@ -2,13 +2,12 @@
2
2
  # Author: Nicolas Despres <polrop@lrde.epita.fr>.
3
3
  # License: Gnu General Public License.
4
4
 
5
- # $LastChangedBy: pouillar $
6
- # $Id: /w/fey/ruby_ex/trunk/lib/abstract.rb 21950 2006-02-19T19:23:50.312174Z pouillar $
7
-
5
+ # $LastChangedBy: ertai $
6
+ # $Id: /w/fey/ruby_ex/trunk/lib/abstract.rb 53902 2007-01-13T11:33:32.044352Z ertai $
8
7
 
9
8
  #FIXME: find a way to be thread safe.
10
9
 
11
- Module::InstanceMethodVisibility.import!
10
+ ModuleExtensions::InstanceMethodVisibility.import!
12
11
 
13
12
 
14
13
  # When this module is included into a class, this class can't be instantiate
data/lib/d_logger.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # License: Gnu General Public License.
4
4
 
5
5
  # $LastChangedBy: ertai $
6
- # $Id: /w/fey/ruby_ex/trunk/lib/d_logger.rb 7994 2005-10-03T00:46:17.723157Z ertai $
6
+ # $Id: /w/fey/ruby_ex/trunk/lib/d_logger.rb 53906 2007-01-13T16:15:34.543400Z ertai $
7
7
 
8
8
  require 'logger'
9
9
 
@@ -57,8 +57,8 @@ test_section __FILE__ do
57
57
  log.debug3 'You don\'t see me'
58
58
  log.debug2 'You see me'
59
59
  cout.rewind
60
- ref = /D, \[[\d\w: .-]+#\d+\] DEBUG -- : You see me
61
- D, \[[\d\w: .-]+#\d+\] DEBUG2 -- : You see me/
60
+ ref = /D, \[[\d\w: .+-]+#\d+\] DEBUG -- : You see me
61
+ D, \[[\d\w: .+-]+#\d+\] DEBUG2 -- : You see me/
62
62
  assert_match(ref, cout.readlines.join)
63
63
  end
64
64
 
@@ -2,8 +2,8 @@
2
2
  # Author:: Nicolas Despres <polrop@lrde.epita.fr>.
3
3
  # License:: Gnu General Public License.
4
4
 
5
- # $LastChangedBy: pouillar $
6
- # $Id: /w/fey/ruby_ex/trunk/lib/drb/observable_pool.rb 22238 2006-02-24T16:48:40.656342Z pouillar $
5
+ # $LastChangedBy: ertai $
6
+ # $Id: /w/fey/ruby_ex/trunk/lib/drb/observable_pool.rb 53906 2007-01-13T16:15:34.543400Z ertai $
7
7
 
8
8
 
9
9
  module DRb
@@ -17,6 +17,9 @@ module DRb
17
17
 
18
18
  end # class DRbObservable
19
19
 
20
+ class ObservablePool
21
+ end # class ObservablePool
22
+
20
23
  end # module DRb
21
24
 
22
25
 
data/lib/drb_ex.rb CHANGED
@@ -1,14 +1,9 @@
1
1
  # Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
2
2
  # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
3
3
  # License:: Gnu General Public License.
4
- # Revision:: $Id: /w/fey/ruby_ex/trunk/lib/drb_ex.rb 22238 2006-02-24T16:48:40.656342Z pouillar $
5
-
6
- AutoloadTree.import!
4
+ # Revision:: $Id: /w/fey/ruby_ex/trunk/lib/drb_ex.rb 53906 2007-01-13T16:15:34.543400Z ertai $
7
5
 
8
6
  module DRb
9
-
10
- autoloaded_module(__FILE__.sub(/drb_ex\.rb/, 'drb.rb'))
11
-
12
7
  end # module Drb
13
8
 
14
9
  class DrbEx
data/lib/exp_mod.rb ADDED
@@ -0,0 +1,48 @@
1
+ # Author:: Nicolas Pouillard <nicolas.pouillard@gmail.com>.
2
+ # Copyright:: Copyright (c) 2006 Nicolas Pouillard. All rights reserved.
3
+ # License:: GNU General Public License (GPL).
4
+ # Revision:: $Id: /w/fey/ruby_ex/trunk/lib/exp_mod.rb 53899 2007-01-13T11:21:51.227355Z ertai $
5
+
6
+ module ExpMod
7
+
8
+ def exp ( m, p )
9
+ case m
10
+ when 0 then 1
11
+ when 1 then self % p
12
+ else
13
+ q, r = m.divmod(2)
14
+ tmp1 = self.exp(q, p)
15
+ tmp2 = (tmp1 * tmp1) % p
16
+ if r == 0
17
+ tmp2
18
+ else
19
+ (tmp2 * self) % p
20
+ end
21
+ end
22
+ end
23
+
24
+ end # module ExpMod
25
+
26
+ class Integer
27
+
28
+ include ExpMod
29
+
30
+ end # class Integer
31
+
32
+ test_section __FILE__ do
33
+
34
+ class TestExpMod < Test::Unit::TestCase
35
+
36
+ def assert_naive ( x, e, m )
37
+ assert_equal((x ** e) % m, x.exp(e, m), "(#{x} ** #{e}) % #{m}")
38
+ end
39
+
40
+ def test_simple
41
+ assert_equal 0, 2.exp(10, 2)
42
+ assert_equal 0, rand(100).exp(rand(10) + 1, 1)
43
+ assert_naive 48204802, 43, 84082384204
44
+ end
45
+
46
+ end # class TestExpMod
47
+
48
+ end
data/lib/file_type.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
2
2
  # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
3
3
  # License:: Gnu General Public License.
4
- # Revision:: $Id: /w/fey/ruby_ex/trunk/lib/file_type.rb 8048 2005-12-31T15:58:07.059747Z ertai $
4
+ # Revision:: $Id: /w/fey/ruby_ex/trunk/lib/file_type.rb 24383 2006-07-09T16:54:02.725734Z ertai $
5
5
 
6
- Commands.import!
6
+ core_ex_require 'objective_command'
7
7
 
8
8
  module FileType
9
9
 
@@ -14,13 +14,6 @@ module FileType
14
14
  end
15
15
 
16
16
 
17
- GZIP = 'gzip'.to_cmd
18
- BZIP2 = 'bzip2'.to_cmd
19
- UNZIP = 'unzip'.to_cmd
20
- TAR = 'tar'.to_cmd
21
- GEM = 'gem'.to_cmd
22
-
23
-
24
17
  class Generic
25
18
  make Abstract
26
19
 
@@ -33,14 +26,18 @@ module FileType
33
26
  unless @path.to_s =~ re
34
27
  raise ArgumentError, "#{@path} do not match /#{re.source}/"
35
28
  end
36
- @base, @ext = $`, $&
29
+ b, @ext = $`, $&
37
30
  if @ext.empty?
38
31
  @base = self
39
32
  else
40
- @base = FileType.guess(@base)
33
+ @base = FileType.guess(b)
41
34
  end
42
35
  end
43
36
 
37
+ def symtbl_to_s
38
+ to_s
39
+ end
40
+
44
41
  def extsplit
45
42
  [@base, @ext]
46
43
  end
@@ -67,16 +64,6 @@ module FileType
67
64
  @path + arg.to_s
68
65
  end
69
66
 
70
- def self.extractable ( aCommand )
71
- include Extractable
72
- self.extract_command = aCommand
73
- end
74
-
75
- def self.extractable_dir ( aCommand )
76
- include ExtractableDir
77
- self.extract_command = aCommand
78
- end
79
-
80
67
  def extractable?
81
68
  false
82
69
  end
@@ -89,7 +76,7 @@ module FileType
89
76
  class_eval do
90
77
  self.extension = anObject
91
78
  self.priority = priority
92
- concrete
79
+ include Concrete
93
80
  end
94
81
  end
95
82
 
@@ -97,7 +84,18 @@ module FileType
97
84
  class_inheritable_accessor :extension
98
85
  class_inheritable_accessor :priority # 0 .. +inf
99
86
 
100
- self.runner = Commands::Runners::System.new
87
+ self.runner = OCmd::Runners::System.new
88
+
89
+ for i in %w[ gzip bzip2 unzip tar gem ] do
90
+ class_eval "
91
+ def self.#{i} *args
92
+ '#{i}'.to_ocmd[*args]
93
+ end
94
+ def #{i} *args
95
+ '#{i}'.to_ocmd[*args]
96
+ end
97
+ "
98
+ end
101
99
 
102
100
  end # class Generic
103
101
 
@@ -116,44 +114,39 @@ module FileType
116
114
 
117
115
  module Extractable
118
116
 
119
- def self.included ( aClass )
120
-
121
- aClass.class_inheritable_accessor :extract_command
122
-
123
- aClass.module_eval do
124
-
125
- def extractable?
126
- true
127
- end
128
-
129
- def mk_cmd ( out )
130
- extract_command < @path > out
131
- end
132
-
133
- def extract
134
- base, ext = @base.extsplit
135
- @tmp = TempPath.new(base.path.basename, ext)
136
- cmd = mk_cmd(@tmp)
137
- data = cmd.run(self.class.runner)
138
- data.waitpid if data.status.nil?
139
- if data.status != 0
140
- @tmp.rmtree if @tmp.exist?
141
- STDERR.puts data.error.read if data.error and data.error.exist?
142
- raise ExtractError, "Cannot extract a file:
143
- | path: #{to_s}
144
- | type: #{self.class}
145
- | command: #{cmd}
146
- | exit status: #{data.status.exitstatus}".head_cut!
147
- end
148
- FileType.guess(@tmp)
149
- end
117
+ setup do |extract_command|
118
+ class_inheritable_accessor :extract_command
119
+ self.extract_command = extract_command
120
+ end
150
121
 
151
- alias :default :extract
122
+ def extractable?
123
+ true
124
+ end
152
125
 
126
+ def mk_cmd ( out )
127
+ extract_command < @path > out
128
+ end
129
+
130
+ def extract
131
+ base, ext = @base.extsplit
132
+ @tmp = TempPath.new(base.path.basename, ext)
133
+ cmd = mk_cmd(@tmp)
134
+ data = cmd.run(self.class.runner)
135
+ data.waitpid if data.status.nil?
136
+ if data.status != 0
137
+ @tmp.rmtree if @tmp.exist?
138
+ STDERR.puts data.error.read if data.error and data.error.exist?
139
+ raise ExtractError, "Cannot extract a file:
140
+ | path: #{to_s}
141
+ | type: #{self.class}
142
+ | command: #{cmd}
143
+ | exit status: #{data.status.exitstatus}".head_cut!
153
144
  end
154
-
145
+ FileType.guess(@tmp)
155
146
  end
156
147
 
148
+ teardown { alias_method :default, :extract }
149
+
157
150
  end # module Extractable
158
151
 
159
152
 
@@ -161,21 +154,21 @@ module FileType
161
154
  # FIXME Use the zlib if gzip not available.
162
155
  class Gz < Generic
163
156
  filetype_extension(/(\.(gz|z|Z)|-gz|-z|_z)$/)
164
- extractable GZIP + %w[-d -c %i]
157
+ make Extractable, gzip('-d', '-c', '%i')
165
158
  end # class Gz
166
159
 
167
160
 
168
161
 
169
162
  class Bz2 < Generic
170
163
  filetype_extension(/\.bz2?$/)
171
- extractable BZIP2 + %w[-d -c %i]
164
+ make Extractable, bzip2('-d', '-c', '%i')
172
165
  end # class Bz2
173
166
 
174
167
 
175
168
 
176
169
  class Zip < Generic
177
170
  filetype_extension(/\.zip$/)
178
- extractable UNZIP + %w[-p %i]
171
+ make Extractable, unzip('-p', '%i')
179
172
  end # class Zip
180
173
 
181
174
 
@@ -185,30 +178,22 @@ module FileType
185
178
 
186
179
  module ExtractableDir
187
180
 
188
- def self.included ( aClass )
189
-
190
- aClass.module_eval do
191
-
192
- include Extractable
193
-
194
- remove_method :mk_cmd
195
-
196
- def mk_cmd ( out )
197
- @log = TempPath.new('log')
198
- cmd = extract_command[@tmp] < @path > @log
199
- @tmp.mkpath
200
- cmd
201
- end
202
-
203
- alias :extract_extractable :extract
204
-
205
- def extract
206
- dir = extract_extractable
207
- FileType.guess(dir.path + longest_common_path(@log).join('/'))
208
- end
181
+ setup do |extract_command|
182
+ make Extractable, extract_command
183
+ # remove_method :mk_cmd
184
+ alias_method :extract_extractable, :extract
185
+ end
209
186
 
210
- end
187
+ def mk_cmd ( out )
188
+ @log = TempPath.new('log')
189
+ cmd = extract_command[@tmp] < @path > @log
190
+ @tmp.mkpath
191
+ cmd
192
+ end
211
193
 
194
+ def extract
195
+ dir = extract_extractable
196
+ FileType.guess(dir.path + longest_common_path(@log).join('/'))
212
197
  end
213
198
 
214
199
  # We want the longest common path
@@ -233,21 +218,21 @@ module FileType
233
218
 
234
219
  class Tar < Generic
235
220
  filetype_extension(/\.tar$/)
236
- extractable_dir TAR + %w[xvf %i -C]
221
+ make ExtractableDir, tar('xvf', '%i', '-C')
237
222
  end # class Tar
238
223
 
239
224
 
240
225
 
241
226
  class TarGz < Generic
242
227
  filetype_extension(/\.(tar(\.(gz|z|Z)|-gz|-z|_z)|tgz)$/)
243
- extractable_dir TAR + %w[xvzf %i -C]
228
+ make ExtractableDir, tar('xvzf', '%i', '-C')
244
229
  end # class TarGz
245
230
 
246
231
 
247
232
 
248
233
  class TarBz2 < Generic
249
234
  filetype_extension(/\.(tar\.bz2|tbz2|tbz)$/)
250
- extractable_dir((BZIP2 + %w[-c -d %i]) | (TAR + %w[xvf - -C]))
235
+ make(ExtractableDir, bzip2('-c', '-d', '%i') | tar('xvf', '-', '-C'))
251
236
  end # class TarBz2
252
237
 
253
238
 
@@ -271,7 +256,7 @@ module FileType
271
256
  filetype_extension(/\.ya?ml$/)
272
257
 
273
258
  def load
274
- YAML::load(path.read)
259
+ YAML.load(path.read)
275
260
  end
276
261
 
277
262
  end # class Yaml
@@ -286,7 +271,7 @@ module FileType
286
271
  end
287
272
 
288
273
  def install ( install_dir=nil )
289
- cmd = GEM + 'install' + path
274
+ cmd = gem('install', path)
290
275
  cmd << '--install-dir' << install_dir unless install_dir.nil?
291
276
  cmd.run(runner)
292
277
  end
@@ -341,14 +326,14 @@ end # module FileType
341
326
 
342
327
  test_section __FILE__ do
343
328
 
344
- Commands::Runners::Mockable.import!
329
+ OCmd::Runners::Mockable.import!
345
330
 
346
331
  class FileTypeTest < Test::Unit::TestCase
347
332
 
348
333
  def setup
349
334
  @tmp = TempPath.new
350
335
  (@tmp + 'foo').mkpath
351
- @mr = Commands::Runners::System.new
336
+ @mr = OCmd::Runners::System.new
352
337
  @mr.make_mock do
353
338
  puts "#@tmp/foo/bar/baz\n#@tmp/foo\n#@tmp/foo/f/f/foo/baz"
354
339
  end
@@ -375,7 +360,7 @@ test_section __FILE__ do
375
360
  end
376
361
 
377
362
  def assert_real_extract ( type, file )
378
- FileType::Generic.runner = Commands::Runners::System.new
363
+ FileType::Generic.runner = OCmd::Runners::System.new
379
364
  assert_nothing_raised { @inp = FileType.guess(file) }
380
365
  assert(@inp.extractable?, "#@inp not extractable")
381
366
  assert_nothing_raised { @res = @inp.extract }
@@ -429,17 +414,17 @@ test_section __FILE__ do
429
414
  end
430
415
 
431
416
  def test_extract_gz
432
- assert_extract :Ruby, /^"gzip" "-d" "-c" "[^%]*" > "[^%]*"$/, @fixtures/'foo.rb.gz'
417
+ assert_extract :Ruby, /^gzip -d -c [^%]* > [^%]*$/, @fixtures/'foo.rb.gz'
433
418
  end
434
419
  def test_extract_bz2
435
- assert_extract :Unknown, /^"bzip2" "-d" "-c" "[^%]*" > "[^%]*"$/, @fixtures/'foo.bz2'
420
+ assert_extract :Unknown, /^bzip2 -d -c [^%]* > [^%]*$/, @fixtures/'foo.bz2'
436
421
  end
437
422
  def test_extract_zip
438
- assert_extract :Gz, /^"unzip" "-p" "[^%]*" > "[^%]*"$/, @fixtures/'foo.gz.zip'
423
+ assert_extract :Gz, /^unzip -p [^%]* > [^%]*$/, @fixtures/'foo.gz.zip'
439
424
  end
440
425
  def test_extract_tar_bz2
441
426
  assert_extract :Directory,
442
- /^\("bzip2" "-c" "-d" "[^%]*foo.tar.bz2"\) \| \("tar" "xvf" "-" "-C" "[^%]*" > "[^%]*"\)$/,
427
+ /^\(bzip2 -c -d [^%]*foo.tar.bz2\) \| \(tar xvf - -C [^%]* > [^%]*\)$/,
443
428
  @fixtures/'foo.tar.bz2'
444
429
  end
445
430
  def test_real_extract_tar_bz2
@@ -447,17 +432,17 @@ test_section __FILE__ do
447
432
  end
448
433
  def test_extract_tar_gz
449
434
  assert_extract :Directory,
450
- /^"tar" "xvzf" "[^%]*foo.tar.gz" "-C" ".*foo.*" > ".*log.*"$/, @fixtures/'foo.tar.gz'
435
+ /^tar xvzf [^%]*foo.tar.gz -C .*foo.* > .*log.*$/, @fixtures/'foo.tar.gz'
451
436
  assert_real_extract :Directory, @fixtures/'foo.tar.gz'
452
437
  end
453
438
  def test_extract_tar
454
439
  assert_extract :Directory,
455
- /^"tar" "xvf" "[^%]*foo.tar" "-C" "[^%]*" > "[^%]*"$/, @fixtures/'foo.tar'
440
+ /^tar xvf [^%]*foo.tar -C [^%]* > [^%]*$/, @fixtures/'foo.tar'
456
441
  end
457
442
 
458
443
  def test_install_gem
459
- assert_install(/^"gem" "install" "foo.gem"$/, 'foo.gem')
460
- assert_install(/^"gem" "install" "foo.gem" "--install-dir" "\/tmp"$/,
444
+ assert_install(/^gem install foo.gem$/, 'foo.gem')
445
+ assert_install(/^gem install foo.gem --install-dir \/tmp$/,
461
446
  'foo.gem', '/tmp')
462
447
  end
463
448