ruby_ex 0.1.2 → 0.2.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.
- data/ChangeLog +693 -0
- data/NEWS +74 -0
- data/SPEC.dyn.yml +6 -6
- data/SPEC.gemspec +14 -0
- data/SPEC.yml +4 -4
- data/lib/abstract.rb +2 -4
- data/lib/abstract_node.rb +1 -2
- data/lib/algorithms/simulated_annealing.rb +50 -29
- data/lib/attributed_class.rb +50 -21
- data/lib/auto_object.rb +102 -0
- data/lib/blank_slate.rb +102 -0
- data/lib/cache.rb +1 -2
- data/lib/choose.rb +165 -163
- data/lib/commands.rb +2 -3
- data/lib/commands/command.rb +47 -20
- data/lib/commands/datas.rb +1 -1
- data/lib/commands/datas/composite.rb +5 -1
- data/lib/commands/datas/data.rb +102 -5
- data/lib/commands/datas/factory.rb +13 -6
- data/lib/commands/datas/temp.rb +3 -5
- data/lib/commands/factory.rb +1 -1
- data/lib/commands/helpers.rb +1 -1
- data/lib/commands/pipe.rb +10 -1
- data/lib/commands/runners.rb +1 -1
- data/lib/commands/runners/exec.rb +1 -1
- data/lib/commands/runners/fork.rb +3 -16
- data/lib/commands/runners/mock.rb +67 -0
- data/lib/commands/runners/runner.rb +5 -3
- data/lib/commands/runners/system.rb +1 -1
- data/lib/commands/seq.rb +2 -1
- data/lib/config_file.rb +10 -2
- data/lib/const_regexp.rb +1 -2
- data/lib/{dlogger.rb → d_logger.rb} +1 -2
- data/lib/daemon.rb +1 -2
- data/lib/diff.rb +1 -2
- data/lib/drb/drb_observable.rb +1 -2
- data/lib/drb/drb_observable_pool.rb +2 -2
- data/lib/drb/drb_service.rb +1 -2
- data/lib/drb/drb_undumped_attributes.rb +1 -2
- data/lib/drb/drb_undumped_indexed_object.rb +1 -2
- data/lib/drb/insecure_protected_methods.rb +1 -2
- data/lib/drb_ex.rb +2 -2
- data/lib/file_type.rb +466 -0
- data/lib/generate_id.rb +12 -6
- data/lib/genpasswd.rb +22 -0
- data/lib/hash_eval.rb +83 -0
- data/lib/histogram.rb +1 -2
- data/lib/hookable.rb +3 -4
- data/lib/hooker.rb +1 -3
- data/lib/html_encode.rb +191 -0
- data/lib/indexed_node.rb +0 -1
- data/lib/io_marshal.rb +4 -2
- data/lib/ioo.rb +3 -2
- data/lib/kill_all.rb +46 -0
- data/lib/labeled_node.rb +0 -1
- data/lib/logger_observer.rb +8 -4
- data/lib/md5sum.rb +3 -3
- data/lib/meta_factory.rb +99 -0
- data/lib/method_call.rb +87 -0
- data/lib/mocks.rb +12 -0
- data/lib/mocks/assertions.rb +50 -0
- data/lib/mocks/method_logger.rb +40 -0
- data/lib/mocks/mock.rb +64 -0
- data/lib/mocks/object.rb +47 -0
- data/lib/mocks/observer.rb +38 -0
- data/lib/module/autoload_tree.rb +30 -29
- data/lib/module/hierarchy.rb +176 -171
- data/lib/module/instance_method_visibility.rb +39 -38
- data/lib/node.rb +0 -1
- data/lib/object_monitor.rb +1 -2
- data/lib/object_monitor_activity.rb +1 -2
- data/lib/observable.rb +1 -2
- data/lib/observable_pool.rb +1 -2
- data/lib/{orderedhash.rb → ordered_hash.rb} +41 -5
- data/lib/pp_hierarchy.rb +7 -2
- data/lib/r_path.rb +307 -0
- data/lib/random_generators.rb +7 -20
- data/lib/random_generators/random_generator.rb +2 -4
- data/lib/random_generators/ruby.rb +4 -2
- data/lib/regex_path.rb +124 -0
- data/lib/ruby_ex.rb +28 -98
- data/lib/safe_eval.rb +1 -2
- data/lib/sendmail.rb +14 -17
- data/lib/service_manager.rb +1 -2
- data/lib/shuffle.rb +6 -2
- data/lib/spring.rb +1 -2
- data/lib/spring_set.rb +1 -2
- data/lib/{symtbl.rb → sym_tbl.rb} +90 -5
- data/lib/sym_tbl_gsub.rb +227 -0
- data/lib/{synflow.rb → syn_flow.rb} +1 -2
- data/lib/text.rb +218 -0
- data/lib/timeout_ex.rb +1 -2
- data/lib/trace.rb +9 -8
- data/lib/uri/druby.rb +1 -2
- data/lib/uri/file.rb +1 -1
- data/lib/uri/ftp_ex.rb +1 -1
- data/lib/uri/http_ex.rb +1 -1
- data/lib/uri/mysql.rb +121 -0
- data/lib/uri/pgsql.rb +19 -38
- data/lib/uri/svn.rb +1 -2
- data/lib/uri_ex.rb +45 -3
- data/lib/verbose_object.rb +181 -38
- data/lib/yaml/chop_header.rb +19 -11
- data/lib/yaml/transform.rb +17 -11
- data/lib/yaml/yregexpath.rb +11 -5
- data/test/algorithms/simulated_annealing_test.rb +2 -2
- data/test/resources/foo.tar.gz +0 -0
- data/test/resources/tar.gz.log +49 -0
- data/test/sanity-suite.yml +5 -7
- data/test/sanity/multiple-requires.yml +17 -7
- data/test/sanity/single-requires.yml +38 -20
- data/test/stress-tests/threads_and_exceptions.yml +13 -0
- data/test/test-unit-setup.rb +3 -1
- data/test/unit-suite.yml +7 -8
- metadata +42 -31
- data/lib/algorithms.rb +0 -12
- data/lib/ask.rb +0 -100
- data/lib/checkout.rb +0 -12
- data/lib/dumpable_proc.rb +0 -57
- data/lib/filetype.rb +0 -229
- data/lib/thread_mutex.rb +0 -11
- data/lib/yaml/basenode_ext.rb +0 -63
data/lib/algorithms.rb
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
|
2
|
-
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
|
3
|
-
# License:: Gnu General Public License.
|
|
4
|
-
# Revision:: $Id: algorithms.rb 279 2005-06-05 17:46:53Z ertai $
|
|
5
|
-
|
|
6
|
-
require 'module/autoload_tree'
|
|
7
|
-
|
|
8
|
-
module Algorithms
|
|
9
|
-
|
|
10
|
-
autoloaded_module(__FILE__)
|
|
11
|
-
|
|
12
|
-
end # module Algorithms
|
data/lib/ask.rb
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
|
2
|
-
# Copyright:: Copyright (c) 2004, 2005 Nicolas Pouillard. All rights reserved.
|
|
3
|
-
# License:: GNU General Public License (GPL).
|
|
4
|
-
# Revision:: $Id: ask.rb 279 2005-06-05 17:46:53Z ertai $
|
|
5
|
-
|
|
6
|
-
require 'ruby_ex'
|
|
7
|
-
|
|
8
|
-
ANSWERS = [ :y, :n ]
|
|
9
|
-
ANSWER_NOT_VALID = 'Not a valid answer, please answer correctly'
|
|
10
|
-
|
|
11
|
-
# `ask', ask the user to answer, to your question.
|
|
12
|
-
#
|
|
13
|
-
# Example:
|
|
14
|
-
# ask('Commiting, are you sure', :n)
|
|
15
|
-
#
|
|
16
|
-
# produce => Commiting, are you sure (y/N):
|
|
17
|
-
# and wait your answer.
|
|
18
|
-
def ask ( aQuestion, theDefaultAnswer=:y, cin=STDIN, cout=STDOUT, cerr=STDERR )
|
|
19
|
-
|
|
20
|
-
yn = case theDefaultAnswer
|
|
21
|
-
when :y then ' [Y/n]: '
|
|
22
|
-
when :n then ' [y/N]: '
|
|
23
|
-
else raise ArgumentError, "not valid default answer #{theDefaultAnswer}"
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
loop do
|
|
27
|
-
cout.print aQuestion, yn
|
|
28
|
-
cout.flush
|
|
29
|
-
|
|
30
|
-
answer = cin.readline.chomp.downcase
|
|
31
|
-
|
|
32
|
-
return theDefaultAnswer if answer.empty?
|
|
33
|
-
|
|
34
|
-
answer = answer.to_sym
|
|
35
|
-
|
|
36
|
-
return answer if ANSWERS.include? answer
|
|
37
|
-
|
|
38
|
-
cerr.puts ANSWER_NOT_VALID
|
|
39
|
-
cout.puts
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
test_section __FILE__ do
|
|
45
|
-
|
|
46
|
-
class AskTest < Test::Unit::TestCase
|
|
47
|
-
|
|
48
|
-
def ask_checker ( question, default, answer, ref, out, err )
|
|
49
|
-
require 'stringio'
|
|
50
|
-
cin, cout, cerr = StringIO.new, StringIO.new, StringIO.new
|
|
51
|
-
cin.puts answer
|
|
52
|
-
cin.rewind
|
|
53
|
-
res = ask(question, default, cin, cout, cerr)
|
|
54
|
-
cout.rewind
|
|
55
|
-
cerr.rewind
|
|
56
|
-
assert_equal(res, ref, 'bad return value')
|
|
57
|
-
assert_equal(cout.readlines.join, out, 'bad standard output')
|
|
58
|
-
assert_equal(cerr.readlines.join, err, 'bad error output')
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def test_bad_default
|
|
62
|
-
assert_raise(ArgumentError) { ask_checker('Q', :foo, '', :y, [], []) }
|
|
63
|
-
assert_nothing_raised do
|
|
64
|
-
ask_checker('Q', :y, 'y', :y, 'Q [Y/n]: ', '')
|
|
65
|
-
end
|
|
66
|
-
assert_nothing_raised do
|
|
67
|
-
ask_checker('Q', :n, 'y', :y, 'Q [y/N]: ', '')
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def test_valid_default_yes
|
|
72
|
-
ask_checker('Q', :y, 'y', :y, 'Q [Y/n]: ', '')
|
|
73
|
-
ask_checker('Q', :y, 'Y', :y, 'Q [Y/n]: ', '')
|
|
74
|
-
ask_checker('Q', :y, 'n', :n, 'Q [Y/n]: ', '')
|
|
75
|
-
ask_checker('Q', :y, 'N', :n, 'Q [Y/n]: ', '')
|
|
76
|
-
ask_checker('Q', :y, '', :y, 'Q [Y/n]: ', '')
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def test_valid_default_no
|
|
80
|
-
ask_checker('Q', :n, 'y', :y, 'Q [y/N]: ', '')
|
|
81
|
-
ask_checker('Q', :n, 'Y', :y, 'Q [y/N]: ', '')
|
|
82
|
-
ask_checker('Q', :n, 'n', :n, 'Q [y/N]: ', '')
|
|
83
|
-
ask_checker('Q', :n, 'N', :n, 'Q [y/N]: ', '')
|
|
84
|
-
ask_checker('Q', :n, '', :n, 'Q [y/N]: ', '')
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def test_invalid_answer
|
|
88
|
-
ask_checker('Q', :n, "bad\ny", :y,
|
|
89
|
-
"Q [y/N]: \nQ [y/N]: ", ANSWER_NOT_VALID + "\n")
|
|
90
|
-
ask_checker('Q', :y, "ad\n\n", :y,
|
|
91
|
-
"Q [Y/n]: \nQ [Y/n]: ", ANSWER_NOT_VALID + "\n")
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def test_ask1
|
|
95
|
-
ask_checker('Q', :y, 'y', :y, 'Q [Y/n]: ', '')
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
end # class AskTest
|
|
99
|
-
|
|
100
|
-
end
|
data/lib/checkout.rb
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# Copyright: Copyright (c) 2004 Nicolas Despres. All rights reserved.
|
|
2
|
-
# Author: Nicolas Despres <polrop@lrde.epita.fr>.
|
|
3
|
-
# License: Gnu General Public License.
|
|
4
|
-
|
|
5
|
-
# $LastChangedBy: ertai $
|
|
6
|
-
# $Id: checkout.rb 279 2005-06-05 17:46:53Z ertai $
|
|
7
|
-
|
|
8
|
-
require 'uri_ex'
|
|
9
|
-
require 'uri/http_ex'
|
|
10
|
-
require 'uri/ftp_ex'
|
|
11
|
-
require 'uri/file'
|
|
12
|
-
require 'uri/svn'
|
data/lib/dumpable_proc.rb
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# Copyright: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
|
2
|
-
# Author: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
|
3
|
-
# License: Gnu General Public License.
|
|
4
|
-
|
|
5
|
-
# $LastChangedBy: ertai $
|
|
6
|
-
# $Id: dumpable_proc.rb 279 2005-06-05 17:46:53Z ertai $
|
|
7
|
-
|
|
8
|
-
require 'ruby_ex'
|
|
9
|
-
require 'delegate'
|
|
10
|
-
|
|
11
|
-
class DumpableProc < DelegateClass(Proc)
|
|
12
|
-
|
|
13
|
-
def initialize ( str )
|
|
14
|
-
@str = str.freeze
|
|
15
|
-
super(eval("proc { #@str }"))
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def _dump ( depth )
|
|
19
|
-
Marshal.dump([self.class, @str])
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def self._load ( data )
|
|
23
|
-
klass, str = Marshal.load(data)
|
|
24
|
-
klass.new(str)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def to_yaml ( opts={} )
|
|
28
|
-
"#{to_yaml_type} #@str"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def to_s
|
|
32
|
-
@str
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def to_yaml_type
|
|
36
|
-
'!proc'
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
test_section __FILE__ do
|
|
42
|
-
|
|
43
|
-
class DumpableProcTest < Test::Unit::TestCase
|
|
44
|
-
|
|
45
|
-
def test_simple
|
|
46
|
-
p = DumpableProc.new('|x| 3 + x')
|
|
47
|
-
assert_equal(7, p[4])
|
|
48
|
-
str = nil
|
|
49
|
-
assert_nothing_raised { str = Marshal.dump(p) }
|
|
50
|
-
p2 = nil
|
|
51
|
-
assert_nothing_raised { p2 = Marshal.load(str) }
|
|
52
|
-
assert_equal(9, p2[6])
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
end
|
data/lib/filetype.rb
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
require 'ruby_ex'
|
|
2
|
-
require 'abstract'
|
|
3
|
-
|
|
4
|
-
module FileType
|
|
5
|
-
|
|
6
|
-
@@subclasses = []
|
|
7
|
-
|
|
8
|
-
def self.register ( klass )
|
|
9
|
-
@@subclasses << klass
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
class Generic
|
|
13
|
-
include Abstract
|
|
14
|
-
|
|
15
|
-
attr_reader :path, :base, :ext
|
|
16
|
-
|
|
17
|
-
def initialize ( path )
|
|
18
|
-
@path = Pathname.new(path)
|
|
19
|
-
re = self.class.extension
|
|
20
|
-
raise ArgumentError, "bad class #{self.class}" if re.nil?
|
|
21
|
-
unless @path.to_s =~ re
|
|
22
|
-
raise ArgumentError, "#{@path} do not match /#{re.source}/"
|
|
23
|
-
end
|
|
24
|
-
@base, @ext = $`, $&
|
|
25
|
-
if @ext.empty?
|
|
26
|
-
@base = self
|
|
27
|
-
else
|
|
28
|
-
@base = FileType.guess(@base)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def extsplit
|
|
33
|
-
[@base, @ext]
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def self.inherited ( klass )
|
|
37
|
-
FileType.register(klass)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def to_s
|
|
41
|
-
@path.to_s
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def self.extension
|
|
45
|
-
const_get(:EXTENSION)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def self.match_type ( path, max, best )
|
|
49
|
-
ext_re = self.extension
|
|
50
|
-
if path.to_s =~ ext_re and $&.size > max
|
|
51
|
-
return [$&.size, self]
|
|
52
|
-
end
|
|
53
|
-
return [max, best]
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def + ( arg )
|
|
57
|
-
@path + arg.to_s
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
end # class Generic
|
|
61
|
-
|
|
62
|
-
class Unknown < Generic
|
|
63
|
-
include Concrete
|
|
64
|
-
EXTENSION = /(\.[^.\/]+)?$/
|
|
65
|
-
end # class Unknown
|
|
66
|
-
|
|
67
|
-
class ExtractError < Exception
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
module Extractable
|
|
71
|
-
|
|
72
|
-
def self.included ( aClass )
|
|
73
|
-
|
|
74
|
-
aClass.module_eval do
|
|
75
|
-
|
|
76
|
-
def mk_cmd
|
|
77
|
-
base, ext = @base.extsplit
|
|
78
|
-
@tmp = TempPath.new(base.path.basename, ext)
|
|
79
|
-
cmd = self.class.const_get(:EXTRACT_COMMAND).gsub(/%I/, @path.to_s)
|
|
80
|
-
cmd.gsub!(/%O/, @tmp.to_s)
|
|
81
|
-
cmd
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def extract
|
|
85
|
-
cmd = mk_cmd
|
|
86
|
-
unless system(cmd)
|
|
87
|
-
@tmp.rmtree if @tmp.exist?
|
|
88
|
-
err = "
|
|
89
|
-
|Cannot extract a file:
|
|
90
|
-
| path: #{to_s}
|
|
91
|
-
| type: #{self.class}
|
|
92
|
-
| command: #{cmd}
|
|
93
|
-
| exit status: #{$? >> 8}
|
|
94
|
-
"
|
|
95
|
-
raise ExtractError, err.gsub(/^\s*|/, '')
|
|
96
|
-
end
|
|
97
|
-
FileType.guess(@tmp)
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
alias :default :extract
|
|
101
|
-
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
end # module Extractable
|
|
107
|
-
|
|
108
|
-
# FIXME Use the zlib if gzip not available.
|
|
109
|
-
class Gz < Generic
|
|
110
|
-
include Extractable
|
|
111
|
-
include Concrete
|
|
112
|
-
EXTENSION = /(\.(gz|z|Z)|-gz|-z|_z)$/
|
|
113
|
-
EXTRACT_COMMAND = 'gzip -d -c "%I" > "%O"'
|
|
114
|
-
end # class Gz
|
|
115
|
-
|
|
116
|
-
class Bz2 < Generic
|
|
117
|
-
include Extractable
|
|
118
|
-
include Concrete
|
|
119
|
-
EXTENSION = /\.(bz2|bz)$/
|
|
120
|
-
EXTRACT_COMMAND = 'bzip2 -d -c "%I" > "%O"'
|
|
121
|
-
end # class Bz2
|
|
122
|
-
|
|
123
|
-
class Zip < Generic
|
|
124
|
-
include Extractable
|
|
125
|
-
include Concrete
|
|
126
|
-
EXTENSION = /\.zip$/
|
|
127
|
-
EXTRACT_COMMAND = 'unzip -p "%I" > "%O"'
|
|
128
|
-
end # class Zip
|
|
129
|
-
|
|
130
|
-
module ExtractableDir
|
|
131
|
-
|
|
132
|
-
def self.included ( aClass )
|
|
133
|
-
|
|
134
|
-
aClass.module_eval do
|
|
135
|
-
|
|
136
|
-
include Extractable
|
|
137
|
-
|
|
138
|
-
alias :mk_cmd_extractable :mk_cmd
|
|
139
|
-
|
|
140
|
-
def mk_cmd
|
|
141
|
-
cmd = mk_cmd_extractable
|
|
142
|
-
@tmp.mkpath
|
|
143
|
-
@log = TempPath.new
|
|
144
|
-
cmd.gsub!(/%L/, @log.to_s)
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
alias :extract_extractable :extract
|
|
148
|
-
|
|
149
|
-
def extract
|
|
150
|
-
dir = extract_extractable
|
|
151
|
-
# We want the longest common path
|
|
152
|
-
longest = nil
|
|
153
|
-
@log.each_line do |line|
|
|
154
|
-
path = line.split(/\//)
|
|
155
|
-
longest = path if longest.nil?
|
|
156
|
-
longest &= path
|
|
157
|
-
raise CorruptedTarball, self if longest.empty?
|
|
158
|
-
end
|
|
159
|
-
dir.path + longest.join('/')
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
end # module ExtractableDir
|
|
167
|
-
|
|
168
|
-
class Tar < Generic
|
|
169
|
-
include ExtractableDir
|
|
170
|
-
include Concrete
|
|
171
|
-
EXTENSION = /\.tar$/
|
|
172
|
-
EXTRACT_COMMAND = 'tar xvf "%I" -C "%O" > "%L"'
|
|
173
|
-
end # class Tar
|
|
174
|
-
|
|
175
|
-
class TarGz < Generic
|
|
176
|
-
include ExtractableDir
|
|
177
|
-
include Concrete
|
|
178
|
-
EXTENSION = /\.(tar\.gz|tgz)$/
|
|
179
|
-
EXTRACT_COMMAND = 'tar xvzf "%I" -C "%O" > %L'
|
|
180
|
-
end # class TarGz
|
|
181
|
-
|
|
182
|
-
class TarBz2 < Generic
|
|
183
|
-
include ExtractableDir
|
|
184
|
-
include Concrete
|
|
185
|
-
EXTENSION = /\.(tar\.bz2|tbz2|tbz)$/
|
|
186
|
-
EXTRACT_COMMAND = 'bzip2 -c -d %I | tar xvf - -C "%O" > "%L"'
|
|
187
|
-
end # class TarBz2
|
|
188
|
-
|
|
189
|
-
class Directory < Generic
|
|
190
|
-
include Concrete
|
|
191
|
-
|
|
192
|
-
EXTENSION = /()$/
|
|
193
|
-
|
|
194
|
-
def self.match_type ( path, max, best )
|
|
195
|
-
if File.directory? path
|
|
196
|
-
return [path.to_s.size, self]
|
|
197
|
-
end
|
|
198
|
-
return [max, best]
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
end # class Directory
|
|
202
|
-
|
|
203
|
-
def self.guess_class ( path )
|
|
204
|
-
lazy_init
|
|
205
|
-
max = -1
|
|
206
|
-
best = Unknown
|
|
207
|
-
@@subclasses.each do |klass|
|
|
208
|
-
max, best = klass.match_type(path, max, best)
|
|
209
|
-
end
|
|
210
|
-
return best
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
def self.guess ( path )
|
|
214
|
-
guess_class(path).new(path)
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
def self.lazy_init
|
|
218
|
-
return if defined? @@init
|
|
219
|
-
@@init = true
|
|
220
|
-
@@subclasses.delete_if do |klass|
|
|
221
|
-
klass.abstract? or not (klass.is_a? Class) # and constants.include? klass)
|
|
222
|
-
end
|
|
223
|
-
@@subclasses.each do |klass|
|
|
224
|
-
ext = klass.extension
|
|
225
|
-
raise ArgumentError, "Bad extension #{ext}" unless ext.is_a? Regexp
|
|
226
|
-
end
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
end # module FileType
|
data/lib/thread_mutex.rb
DELETED
data/lib/yaml/basenode_ext.rb
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# Copyright: Copyright (c) 2004 Nicolas Pouillard. All rights reserved.
|
|
2
|
-
# Author: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
|
3
|
-
# License: Gnu General Public License.
|
|
4
|
-
|
|
5
|
-
# $LastChangedBy: ertai $
|
|
6
|
-
# $Id: basenode_ext.rb 279 2005-06-05 17:46:53Z ertai $
|
|
7
|
-
|
|
8
|
-
require 'ruby_ex'
|
|
9
|
-
require 'yaml'
|
|
10
|
-
require 'yaml/basenode'
|
|
11
|
-
|
|
12
|
-
module YAML
|
|
13
|
-
|
|
14
|
-
module BaseNode
|
|
15
|
-
|
|
16
|
-
def ordered_children_with_index
|
|
17
|
-
arr = children_with_index
|
|
18
|
-
arr.sort! { |a,b| b[0].object_id <=> a[0].object_id } unless arr.nil?
|
|
19
|
-
arr
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def ordered_children_indexes
|
|
23
|
-
arr = ordered_children_with_index
|
|
24
|
-
arr.map! { |x| x[1] } unless arr.nil?
|
|
25
|
-
arr
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def ordered_children
|
|
29
|
-
arr = children
|
|
30
|
-
arr.map! { |x| x[0] } unless arr.nil?
|
|
31
|
-
arr
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
end # module BaseNode
|
|
35
|
-
|
|
36
|
-
end # module YAML
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
test_section __FILE__ do
|
|
40
|
-
|
|
41
|
-
class BaseNodeExtTest < Test::Unit::TestCase
|
|
42
|
-
|
|
43
|
-
def basenode_checker ( my, ref )
|
|
44
|
-
node = YAML::parse(my)
|
|
45
|
-
assert_equal(node.ordered_children_indexes, ref)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def test_basenode1
|
|
49
|
-
basenode_checker('--- { d: 4, a: 1, b: 2, c: 3 }', ["d", "a", "b", "c"])
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def test_basenode2
|
|
53
|
-
basenode_checker('--- { a: 1, d: 42, b: 2, c: 3 }', ["a", "d", "b", "c"])
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def test_basenode3
|
|
57
|
-
basenode_checker(
|
|
58
|
-
'--- { a: :"1", d: "foo", b: [2,3], c: {} }', ["a", "d", "b", "c"])
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
end # class BaseNodeExtTest
|
|
62
|
-
|
|
63
|
-
end
|