vcs 0.1 → 0.2.148
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +17 -3
- data/bin/vcs +57 -34
- data/doc/jamis.rb +564 -0
- data/ruby_ex/abstract.rb +254 -0
- data/ruby_ex/abstract_node.rb +85 -0
- data/ruby_ex/algorithms/simulated_annealing.rb +140 -0
- data/ruby_ex/array_each_pair.rb +18 -0
- data/ruby_ex/ask.rb +101 -0
- data/ruby_ex/attributed_class.rb +302 -0
- data/ruby_ex/cache.rb +373 -0
- data/ruby_ex/checkout.rb +12 -0
- data/ruby_ex/choose.rb +271 -0
- data/ruby_ex/commands.rb +18 -0
- data/ruby_ex/commands/command.rb +401 -0
- data/ruby_ex/commands/datas.rb +16 -0
- data/ruby_ex/commands/datas/data.rb +33 -0
- data/ruby_ex/commands/datas/factory.rb +66 -0
- data/ruby_ex/commands/factory.rb +66 -0
- data/ruby_ex/commands/helpers.rb +67 -0
- data/ruby_ex/commands/pipe.rb +64 -0
- data/ruby_ex/commands/runners.rb +17 -0
- data/ruby_ex/commands/runners/exec.rb +49 -0
- data/ruby_ex/commands/runners/fork.rb +97 -0
- data/ruby_ex/commands/runners/runner.rb +107 -0
- data/ruby_ex/commands/seq.rb +27 -0
- data/ruby_ex/config_file.rb +96 -0
- data/ruby_ex/const_regexp.rb +59 -0
- data/ruby_ex/daemon.rb +134 -0
- data/ruby_ex/diff.rb +667 -0
- data/ruby_ex/dlogger.rb +62 -0
- data/ruby_ex/drb/dispatcher.rb +252 -0
- data/ruby_ex/drb/dispatcher_server_test.rb +29 -0
- data/ruby_ex/drb/drb_observable.rb +97 -0
- data/ruby_ex/drb/drb_observable_pool.rb +27 -0
- data/ruby_ex/drb/drb_service.rb +43 -0
- data/ruby_ex/drb/drb_undumped_attributes.rb +55 -0
- data/ruby_ex/drb/drb_undumped_indexed_object.rb +54 -0
- data/ruby_ex/drb/insecure_protected_methods.rb +103 -0
- data/ruby_ex/drb/session_client_test.rb +40 -0
- data/ruby_ex/drb/session_manager.rb +246 -0
- data/ruby_ex/drb/session_server.rb +53 -0
- data/ruby_ex/dtime.rb +143 -0
- data/ruby_ex/dumpable_proc.rb +63 -0
- data/ruby_ex/exception.rb +32 -0
- data/ruby_ex/filetype.rb +229 -0
- data/ruby_ex/fileutils_ex.rb +44 -0
- data/ruby_ex/fold.rb +58 -0
- data/ruby_ex/generate_id.rb +44 -0
- data/ruby_ex/hookable.rb +262 -0
- data/ruby_ex/hooker.rb +54 -0
- data/ruby_ex/inactive_timeout.rb +137 -0
- data/ruby_ex/indexed_node.rb +66 -0
- data/ruby_ex/io_marshal.rb +100 -0
- data/ruby_ex/ioo.rb +194 -0
- data/ruby_ex/labeled_node.rb +63 -0
- data/ruby_ex/logger_observer.rb +23 -0
- data/ruby_ex/md5sum.rb +66 -0
- data/ruby_ex/mktemp.rb +208 -0
- data/ruby_ex/module/attr_once.rb +36 -0
- data/ruby_ex/module/autoload_tree.rb +75 -0
- data/ruby_ex/module/hierarchy.rb +335 -0
- data/ruby_ex/module/instance_method_visibility.rb +73 -0
- data/ruby_ex/module_ex.rb +11 -0
- data/ruby_ex/node.rb +80 -0
- data/ruby_ex/object_monitor.rb +145 -0
- data/ruby_ex/object_monitor_activity.rb +33 -0
- data/ruby_ex/observable.rb +140 -0
- data/ruby_ex/observable_pool.rb +293 -0
- data/ruby_ex/orderedhash.rb +252 -0
- data/ruby_ex/pathname_ex.rb +152 -0
- data/ruby_ex/pp_hierarchy.rb +29 -0
- data/ruby_ex/pseudo_cache.rb +190 -0
- data/ruby_ex/queue.rb +56 -0
- data/ruby_ex/random_generators.rb +25 -0
- data/ruby_ex/random_generators/random_generator.rb +31 -0
- data/ruby_ex/random_generators/ruby.rb +23 -0
- data/ruby_ex/safe_eval.rb +348 -0
- data/ruby_ex/sendmail.rb +215 -0
- data/ruby_ex/service_manager.rb +121 -0
- data/ruby_ex/session/administrable.rb +120 -0
- data/ruby_ex/session/client.rb +153 -0
- data/ruby_ex/session/const.rb +18 -0
- data/ruby_ex/session/dispatcher.rb +184 -0
- data/ruby_ex/session/error.rb +21 -0
- data/ruby_ex/session/fetchable.rb +57 -0
- data/ruby_ex/session/fetcher.rb +62 -0
- data/ruby_ex/session/hookable.rb +26 -0
- data/ruby_ex/session/profile.rb +110 -0
- data/ruby_ex/session/server.rb +582 -0
- data/ruby_ex/session/test/administrable_test.rb +337 -0
- data/ruby_ex/session/test/basic_test.rb +523 -0
- data/ruby_ex/session/test/dispatcher_test.rb +409 -0
- data/ruby_ex/session/test/fetchable_test.rb +119 -0
- data/ruby_ex/session/test/sub_server_test.rb +188 -0
- data/ruby_ex/shuffle.rb +30 -0
- data/ruby_ex/spring.rb +136 -0
- data/ruby_ex/spring_set.rb +137 -0
- data/ruby_ex/string_ex.rb +28 -0
- data/ruby_ex/symtbl.rb +106 -0
- data/ruby_ex/synflow.rb +474 -0
- data/ruby_ex/test/unit/ui/yaml/testrunner.rb +164 -0
- data/ruby_ex/thread_mutex.rb +10 -0
- data/ruby_ex/timeout_ex.rb +81 -0
- data/ruby_ex/top_down.rb +73 -0
- data/ruby_ex/trace.rb +26 -0
- data/ruby_ex/uri/druby.rb +81 -0
- data/ruby_ex/uri/file.rb +65 -0
- data/ruby_ex/uri/ftp_ex.rb +37 -0
- data/ruby_ex/uri/http_ex.rb +43 -0
- data/ruby_ex/uri/ssh.rb +92 -0
- data/ruby_ex/uri/svn.rb +118 -0
- data/ruby_ex/uri_ex.rb +45 -0
- data/ruby_ex/verbose_object.rb +30 -0
- data/ruby_ex/version.rb +66 -0
- data/ruby_ex/yaml/basenode_ext.rb +63 -0
- data/ruby_ex/yaml/chop_header.rb +23 -0
- data/ruby_ex/yaml/transform.rb +449 -0
- data/ruby_ex/yaml/yregexpath.rb +76 -0
- data/src/changelog.rb +28 -18
- data/src/conflict.rb +20 -0
- data/src/diff.rb +18 -0
- data/src/diffstat.rb +9 -3
- data/src/last_changed_date.rb +18 -0
- data/src/mail.rb +33 -65
- data/src/message.rb +15 -9
- data/src/mycommit.rb +29 -14
- data/src/news.rb +24 -3
- data/src/status.rb +17 -0
- data/src/svn.rb +2 -2
- data/src/vcs.rb +24 -3
- metadata +124 -5
- data/lrdetools.rb +0 -12
@@ -0,0 +1,37 @@
|
|
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: polrop $
|
6
|
+
# $Id: ftp_ex.rb 159 2005-02-18 12:07:23Z polrop $
|
7
|
+
|
8
|
+
require 'uri_ex'
|
9
|
+
require 'uri/ftp'
|
10
|
+
require 'net/ftp'
|
11
|
+
require 'mktemp'
|
12
|
+
|
13
|
+
module URI
|
14
|
+
|
15
|
+
class FTP
|
16
|
+
|
17
|
+
def checkout
|
18
|
+
tmp = TempPath.new('checkout', pathname.basename.to_s)
|
19
|
+
|
20
|
+
begin
|
21
|
+
Net::FTP.open(host) do |ftp|
|
22
|
+
ftp.login
|
23
|
+
ftp.passive = true
|
24
|
+
ftp.getbinaryfile(path, tmp)
|
25
|
+
end
|
26
|
+
|
27
|
+
rescue Exception => ex
|
28
|
+
tmp.unlink if tmp.exist?
|
29
|
+
raise CheckoutError, "Cannot checkout #{to_s} (error: #{ex.short_pp})"
|
30
|
+
end
|
31
|
+
|
32
|
+
tmp
|
33
|
+
end
|
34
|
+
|
35
|
+
end # class FTP
|
36
|
+
|
37
|
+
end # module URI
|
@@ -0,0 +1,43 @@
|
|
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: polrop $
|
6
|
+
# $Id: http_ex.rb 159 2005-02-18 12:07:23Z polrop $
|
7
|
+
|
8
|
+
require 'exception'
|
9
|
+
require 'uri_ex'
|
10
|
+
require 'uri/http'
|
11
|
+
require 'net/http'
|
12
|
+
require 'mktemp'
|
13
|
+
|
14
|
+
module URI
|
15
|
+
|
16
|
+
class HTTP
|
17
|
+
|
18
|
+
def checkout
|
19
|
+
tmp = TempPath.new('checkout', pathname.basename.to_s)
|
20
|
+
|
21
|
+
begin
|
22
|
+
uri = URI.parse(ENV['http_proxy'] || '')
|
23
|
+
proxy_auth = [uri.host, uri.port, uri.user, uri.password]
|
24
|
+
|
25
|
+
Net::HTTP::Proxy(*proxy_auth).start(host) do |http|
|
26
|
+
tmp.open('w') do |out|
|
27
|
+
http.get(path) do |str|
|
28
|
+
out.print str
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
rescue Exception => ex
|
34
|
+
tmp.unlink if tmp.exist?
|
35
|
+
raise CheckoutError, "Cannot checkout #{to_s} (error: #{ex.short_pp})"
|
36
|
+
end
|
37
|
+
|
38
|
+
tmp
|
39
|
+
end
|
40
|
+
|
41
|
+
end # class HTTP
|
42
|
+
|
43
|
+
end # module URI
|
data/ruby_ex/uri/ssh.rb
ADDED
@@ -0,0 +1,92 @@
|
|
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$
|
5
|
+
|
6
|
+
require 'uri_ex'
|
7
|
+
|
8
|
+
module URI
|
9
|
+
|
10
|
+
class Ssh < Generic
|
11
|
+
|
12
|
+
SCHEME = 'ssh'.freeze
|
13
|
+
DEFAULT_HOST = 'localhost'.freeze
|
14
|
+
DEFAULT_PORT = 22
|
15
|
+
DEFAULT_QUERY = ''.freeze
|
16
|
+
|
17
|
+
COMPONENT = [
|
18
|
+
:scheme,
|
19
|
+
:userinfo,
|
20
|
+
:host,
|
21
|
+
:path,
|
22
|
+
:query
|
23
|
+
].freeze
|
24
|
+
|
25
|
+
def self.build ( args )
|
26
|
+
tmp = Util::make_components_hash(self, args)
|
27
|
+
return super(tmp)
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_opts
|
31
|
+
opts = []
|
32
|
+
opts << '-q' << '-P' << @port
|
33
|
+
return opts if @query.nil?
|
34
|
+
@query.split(/,/).map do |x|
|
35
|
+
k, v = x.split(/=/)
|
36
|
+
if k.size == 1
|
37
|
+
opts << "-#{k}"
|
38
|
+
else
|
39
|
+
opts << "--#{k}"
|
40
|
+
end
|
41
|
+
opts << v unless v.nil?
|
42
|
+
end
|
43
|
+
opts
|
44
|
+
end
|
45
|
+
|
46
|
+
def mk_opts
|
47
|
+
get_opts.join(' ')
|
48
|
+
end
|
49
|
+
|
50
|
+
def mk_arg
|
51
|
+
"#@user@#@host:#{@path.gsub(/^\//, '')}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def checkout
|
55
|
+
out = TempPath.new('checkout', pathname.basename.to_s)
|
56
|
+
cmd = "scp #{mk_opts} #{mk_arg} #{out}"
|
57
|
+
puts cmd
|
58
|
+
raise CheckoutError, to_s unless system cmd
|
59
|
+
out
|
60
|
+
end
|
61
|
+
|
62
|
+
def save
|
63
|
+
checkout.save
|
64
|
+
end
|
65
|
+
|
66
|
+
def commit ( aPath )
|
67
|
+
cmd = "scp #{mk_opts} #{aPath} #{mk_arg}"
|
68
|
+
puts cmd
|
69
|
+
raise CommitError, to_s unless system cmd
|
70
|
+
end
|
71
|
+
|
72
|
+
end # class Ssh
|
73
|
+
|
74
|
+
@@schemes[Ssh::SCHEME.upcase] = Ssh
|
75
|
+
|
76
|
+
if $0 == __FILE__
|
77
|
+
require 'test/unit'
|
78
|
+
class SshTest < Test::Unit::TestCase
|
79
|
+
def test_basic
|
80
|
+
assert_nothing_raised { @uri = URI.parse('ssh://foo@bar') }
|
81
|
+
assert_equal('-q -P 22', @uri.mk_opts)
|
82
|
+
end
|
83
|
+
def test_with_query
|
84
|
+
assert_nothing_raised do
|
85
|
+
@uri = URI.parse('ssh://foo@bar/qux?a=b,c,d=e,f,ghi,jkl=mno')
|
86
|
+
end
|
87
|
+
assert_equal('-q -P 22 -a b -c -d e -f --ghi --jkl mno', @uri.mk_opts)
|
88
|
+
end
|
89
|
+
end # class SshTest
|
90
|
+
end
|
91
|
+
|
92
|
+
end # module URI
|
data/ruby_ex/uri/svn.rb
ADDED
@@ -0,0 +1,118 @@
|
|
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: svn.rb 201 2005-04-23 00:31:12Z ertai $
|
7
|
+
|
8
|
+
require 'uri_ex'
|
9
|
+
require 'abstract'
|
10
|
+
|
11
|
+
module URI
|
12
|
+
|
13
|
+
class Svn < Generic
|
14
|
+
|
15
|
+
COMPONENT = [
|
16
|
+
:scheme,
|
17
|
+
:host,
|
18
|
+
:path
|
19
|
+
].freeze
|
20
|
+
|
21
|
+
def self.build ( args )
|
22
|
+
tmp = Util::make_components_hash(self, args)
|
23
|
+
return super(tmp)
|
24
|
+
end
|
25
|
+
|
26
|
+
def checkout
|
27
|
+
# klass = SvnSchemes.guess(scheme)
|
28
|
+
# klass.new
|
29
|
+
tmp = TempPath.new('svn-checkout')
|
30
|
+
out = TempPath.new('svn-checkout-out')
|
31
|
+
err = TempPath.new('svn-checkout-err')
|
32
|
+
tmp.mkpath
|
33
|
+
target = to_s.sub(/^svn\./, '')
|
34
|
+
tmp += pathname.basename
|
35
|
+
unless system "svn checkout #{target} #{tmp} > #{out} 2> #{err}"
|
36
|
+
raise CheckoutError, to_s
|
37
|
+
end
|
38
|
+
[tmp, out, err]
|
39
|
+
end
|
40
|
+
|
41
|
+
def save
|
42
|
+
raise SaveError unless scheme.downcase == 'svn.file'
|
43
|
+
repos = pathname
|
44
|
+
raise SaveError unless (repos + 'format').exist?
|
45
|
+
out = TempPath.new('save', "#{repos.basename}.svndump")
|
46
|
+
cmd = "svnadmin dump #{repos} --incremental --quiet > #{out}"
|
47
|
+
unless system cmd
|
48
|
+
raise SaveError, "command failed: `#{cmd}' => #{$?}"
|
49
|
+
end
|
50
|
+
out
|
51
|
+
end
|
52
|
+
|
53
|
+
end # class Svn
|
54
|
+
|
55
|
+
module SvnSchemes
|
56
|
+
|
57
|
+
def self.guess ( aScheme )
|
58
|
+
init
|
59
|
+
@@svn_schemes[aScheme]
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.init
|
63
|
+
return if defined? @@svn_schemes
|
64
|
+
@@svn_schemes = {}
|
65
|
+
constants.each do |const|
|
66
|
+
klass = const_get(const)
|
67
|
+
next if klass.abstract?
|
68
|
+
@@svn_schemes[klass.scheme] = klass
|
69
|
+
end
|
70
|
+
@@svn_schemes.freeze
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.svn_schemes
|
74
|
+
init
|
75
|
+
@@svn_schemes
|
76
|
+
end
|
77
|
+
|
78
|
+
class AbstractSvnScheme
|
79
|
+
include Abstract
|
80
|
+
|
81
|
+
def self.scheme
|
82
|
+
const_get(:SCHEME)
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
class SvnScheme < AbstractSvnScheme
|
88
|
+
include Concrete
|
89
|
+
SCHEME = 'SVN'
|
90
|
+
end
|
91
|
+
|
92
|
+
class SvnSshScheme < AbstractSvnScheme
|
93
|
+
include Concrete
|
94
|
+
SCHEME = 'SVN+SSH'
|
95
|
+
end
|
96
|
+
|
97
|
+
class SvnHttpScheme < AbstractSvnScheme
|
98
|
+
include Concrete
|
99
|
+
SCHEME = 'SVN.HTTP'
|
100
|
+
end
|
101
|
+
|
102
|
+
class SvnHttpsScheme < AbstractSvnScheme
|
103
|
+
include Concrete
|
104
|
+
SCHEME = 'SVN.HTTPS'
|
105
|
+
end
|
106
|
+
|
107
|
+
class SvnFileScheme < AbstractSvnScheme
|
108
|
+
include Concrete
|
109
|
+
SCHEME = 'SVN.FILE'
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
SvnSchemes.svn_schemes.each_key do |name|
|
115
|
+
@@schemes[name] = Svn
|
116
|
+
end
|
117
|
+
|
118
|
+
end # module URI
|
data/ruby_ex/uri_ex.rb
ADDED
@@ -0,0 +1,45 @@
|
|
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: uri_ex.rb 201 2005-04-23 00:31:12Z ertai $
|
7
|
+
|
8
|
+
require 'uri'
|
9
|
+
|
10
|
+
module URI
|
11
|
+
|
12
|
+
class CheckoutError < Exception
|
13
|
+
end
|
14
|
+
|
15
|
+
class CommitError < Exception
|
16
|
+
end
|
17
|
+
|
18
|
+
class SaveError < Exception
|
19
|
+
end
|
20
|
+
|
21
|
+
class Generic
|
22
|
+
|
23
|
+
def pathname
|
24
|
+
Pathname.new(path)
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_yaml_type
|
28
|
+
'!uri'
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_yaml ( opts={} )
|
32
|
+
"!uri #{to_s}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def checkout
|
36
|
+
raise CheckoutError, "Can't checkout a #{self.class}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def save
|
40
|
+
raise SaveError, "Can't save a #{self.class}"
|
41
|
+
end
|
42
|
+
|
43
|
+
end # module Generic
|
44
|
+
|
45
|
+
end # module URI
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
|
+
# License:: GNU General Public License (GPL).
|
4
|
+
# Revision:: $Id: verbose_object.rb 222 2005-05-09 12:44:32Z ertai $
|
5
|
+
|
6
|
+
class VerboseObject
|
7
|
+
|
8
|
+
def initialize ( anObject )
|
9
|
+
@obj = anObject
|
10
|
+
end
|
11
|
+
|
12
|
+
instance_methods.each do |meth|
|
13
|
+
next if meth =~ /__.*__/
|
14
|
+
module_eval %Q{
|
15
|
+
def #{meth} ( *a, &b )
|
16
|
+
log(:#{meth}, *a)
|
17
|
+
@obj.__send__(:#{meth}, *a, &b)
|
18
|
+
end
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def log ( *a )
|
23
|
+
STDERR.puts "LOG: #{a.inspect}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def method_missing ( *a, &b )
|
27
|
+
log(*a)
|
28
|
+
end
|
29
|
+
|
30
|
+
end # class VerboseObject
|
data/ruby_ex/version.rb
ADDED
@@ -0,0 +1,66 @@
|
|
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: polrop $
|
6
|
+
# $Id: version.rb 101 2005-01-15 07:58:58Z polrop $
|
7
|
+
|
8
|
+
|
9
|
+
class Version
|
10
|
+
include Comparable
|
11
|
+
|
12
|
+
attr_accessor :major, :minor, :revision
|
13
|
+
|
14
|
+
def initialize(major, minor, revision)
|
15
|
+
@major = major
|
16
|
+
@minor = minor
|
17
|
+
@revision = revision
|
18
|
+
end
|
19
|
+
|
20
|
+
def <=>(other)
|
21
|
+
if @major == other.major
|
22
|
+
if @minor == other.minor
|
23
|
+
@revision <=> other.revision
|
24
|
+
else
|
25
|
+
@minor <=> other.minor
|
26
|
+
end
|
27
|
+
else
|
28
|
+
@major <=> other.major
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_s
|
33
|
+
"#@major.#@minor.#@revision"
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_a
|
37
|
+
[ @major, @minor, @revision ]
|
38
|
+
end
|
39
|
+
|
40
|
+
end # class Version
|
41
|
+
|
42
|
+
|
43
|
+
if defined? TEST_MODE or __FILE__ == $0
|
44
|
+
|
45
|
+
|
46
|
+
require 'test/unit/ui/yaml/testrunner'
|
47
|
+
|
48
|
+
|
49
|
+
class VersionTest < Test::Unit::TestCase
|
50
|
+
|
51
|
+
def test_simple
|
52
|
+
assert(Version.new(1, 2, 3) < Version.new(1, 2, 4))
|
53
|
+
assert(Version.new(1, 2, 4) > Version.new(1, 2, 3))
|
54
|
+
assert(Version.new(1, 2, 3) == Version.new(1, 2, 3))
|
55
|
+
assert(Version.new(1, 3, 3) > Version.new(1, 2, 3))
|
56
|
+
assert(Version.new(1, 2, 3) < Version.new(1, 3, 3))
|
57
|
+
assert(Version.new(2, 2, 3) > Version.new(1, 2, 3))
|
58
|
+
assert(Version.new(1, 2, 3) < Version.new(2, 2, 3))
|
59
|
+
end
|
60
|
+
|
61
|
+
end # class VersionTest
|
62
|
+
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
|
@@ -0,0 +1,63 @@
|
|
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 53 2004-12-02 22:24:03Z ertai $
|
7
|
+
|
8
|
+
require 'yaml'
|
9
|
+
require 'yaml/basenode'
|
10
|
+
|
11
|
+
module YAML
|
12
|
+
|
13
|
+
module BaseNode
|
14
|
+
|
15
|
+
def ordered_children_with_index
|
16
|
+
arr = children_with_index
|
17
|
+
arr.sort! { |a,b| b[0].object_id <=> a[0].object_id } unless arr.nil?
|
18
|
+
arr
|
19
|
+
end
|
20
|
+
|
21
|
+
def ordered_children_indexes
|
22
|
+
arr = ordered_children_with_index
|
23
|
+
arr.map! { |x| x[1] } unless arr.nil?
|
24
|
+
arr
|
25
|
+
end
|
26
|
+
|
27
|
+
def ordered_children
|
28
|
+
arr = children
|
29
|
+
arr.map! { |x| x[0] } unless arr.nil?
|
30
|
+
arr
|
31
|
+
end
|
32
|
+
|
33
|
+
end # module BaseNode
|
34
|
+
|
35
|
+
end # module YAML
|
36
|
+
|
37
|
+
|
38
|
+
if defined? TEST_MODE or $0 == __FILE__
|
39
|
+
|
40
|
+
require 'test/unit'
|
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
|