vcs 0.2.148 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +6 -0
- data/NEWS +9 -0
- data/README +82 -0
- data/Rakefile +7 -72
- data/SPEC.dyn.yml +10 -0
- data/SPEC.gemspec +14 -0
- data/SPEC.yml +39 -0
- data/bin/vcs +18 -16
- data/lib/vcs/changelog.rb +164 -0
- data/lib/vcs/conflict.rb +21 -0
- data/{src → lib/vcs}/cvs.rb +1 -1
- data/{src → lib/vcs}/diff.rb +2 -2
- data/lib/vcs/diffstat.rb +28 -0
- data/lib/vcs/edit.rb +16 -0
- data/{src → lib/vcs}/last_changed_date.rb +3 -5
- data/{src → lib/vcs}/mail.rb +4 -4
- data/lib/vcs/message.rb +79 -0
- data/{src → lib/vcs}/mycommit.rb +15 -15
- data/{src → lib/vcs}/news.rb +6 -6
- data/{src → lib/vcs}/prcs.rb +1 -1
- data/{src → lib/vcs}/revision.rb +3 -4
- data/lib/vcs/script.rb +19 -0
- data/{src → lib/vcs}/status.rb +1 -1
- data/{src → lib/vcs}/svn.rb +3 -5
- data/lib/vcs/url.rb +16 -0
- data/lib/vcs/vcs.rb +279 -0
- metadata +52 -150
- data/TODO +0 -19
- data/doc/jamis.rb +0 -564
- data/ruby_ex/abstract.rb +0 -254
- data/ruby_ex/abstract_node.rb +0 -85
- data/ruby_ex/algorithms/simulated_annealing.rb +0 -140
- data/ruby_ex/array_each_pair.rb +0 -18
- data/ruby_ex/ask.rb +0 -101
- data/ruby_ex/attributed_class.rb +0 -302
- data/ruby_ex/cache.rb +0 -373
- data/ruby_ex/checkout.rb +0 -12
- data/ruby_ex/choose.rb +0 -271
- data/ruby_ex/commands.rb +0 -18
- data/ruby_ex/commands/command.rb +0 -401
- data/ruby_ex/commands/datas.rb +0 -16
- data/ruby_ex/commands/datas/data.rb +0 -33
- data/ruby_ex/commands/datas/factory.rb +0 -66
- data/ruby_ex/commands/factory.rb +0 -66
- data/ruby_ex/commands/helpers.rb +0 -67
- data/ruby_ex/commands/pipe.rb +0 -64
- data/ruby_ex/commands/runners.rb +0 -17
- data/ruby_ex/commands/runners/exec.rb +0 -49
- data/ruby_ex/commands/runners/fork.rb +0 -97
- data/ruby_ex/commands/runners/runner.rb +0 -107
- data/ruby_ex/commands/seq.rb +0 -27
- data/ruby_ex/config_file.rb +0 -96
- data/ruby_ex/const_regexp.rb +0 -59
- data/ruby_ex/daemon.rb +0 -134
- data/ruby_ex/diff.rb +0 -667
- data/ruby_ex/dlogger.rb +0 -62
- data/ruby_ex/drb/dispatcher.rb +0 -252
- data/ruby_ex/drb/dispatcher_server_test.rb +0 -29
- data/ruby_ex/drb/drb_observable.rb +0 -97
- data/ruby_ex/drb/drb_observable_pool.rb +0 -27
- data/ruby_ex/drb/drb_service.rb +0 -43
- data/ruby_ex/drb/drb_undumped_attributes.rb +0 -55
- data/ruby_ex/drb/drb_undumped_indexed_object.rb +0 -54
- data/ruby_ex/drb/insecure_protected_methods.rb +0 -103
- data/ruby_ex/drb/session_client_test.rb +0 -40
- data/ruby_ex/drb/session_manager.rb +0 -246
- data/ruby_ex/drb/session_server.rb +0 -53
- data/ruby_ex/dtime.rb +0 -143
- data/ruby_ex/dumpable_proc.rb +0 -63
- data/ruby_ex/exception.rb +0 -32
- data/ruby_ex/filetype.rb +0 -229
- data/ruby_ex/fileutils_ex.rb +0 -44
- data/ruby_ex/fold.rb +0 -58
- data/ruby_ex/generate_id.rb +0 -44
- data/ruby_ex/hookable.rb +0 -262
- data/ruby_ex/hooker.rb +0 -54
- data/ruby_ex/inactive_timeout.rb +0 -137
- data/ruby_ex/indexed_node.rb +0 -66
- data/ruby_ex/io_marshal.rb +0 -100
- data/ruby_ex/ioo.rb +0 -194
- data/ruby_ex/labeled_node.rb +0 -63
- data/ruby_ex/logger_observer.rb +0 -23
- data/ruby_ex/md5sum.rb +0 -66
- data/ruby_ex/mktemp.rb +0 -208
- data/ruby_ex/module/attr_once.rb +0 -36
- data/ruby_ex/module/autoload_tree.rb +0 -75
- data/ruby_ex/module/hierarchy.rb +0 -335
- data/ruby_ex/module/instance_method_visibility.rb +0 -73
- data/ruby_ex/module_ex.rb +0 -11
- data/ruby_ex/node.rb +0 -80
- data/ruby_ex/object_monitor.rb +0 -145
- data/ruby_ex/object_monitor_activity.rb +0 -33
- data/ruby_ex/observable.rb +0 -140
- data/ruby_ex/observable_pool.rb +0 -293
- data/ruby_ex/orderedhash.rb +0 -252
- data/ruby_ex/pathname_ex.rb +0 -152
- data/ruby_ex/pp_hierarchy.rb +0 -29
- data/ruby_ex/pseudo_cache.rb +0 -190
- data/ruby_ex/queue.rb +0 -56
- data/ruby_ex/random_generators.rb +0 -25
- data/ruby_ex/random_generators/random_generator.rb +0 -31
- data/ruby_ex/random_generators/ruby.rb +0 -23
- data/ruby_ex/safe_eval.rb +0 -348
- data/ruby_ex/sendmail.rb +0 -215
- data/ruby_ex/service_manager.rb +0 -121
- data/ruby_ex/session/administrable.rb +0 -120
- data/ruby_ex/session/client.rb +0 -153
- data/ruby_ex/session/const.rb +0 -18
- data/ruby_ex/session/dispatcher.rb +0 -184
- data/ruby_ex/session/error.rb +0 -21
- data/ruby_ex/session/fetchable.rb +0 -57
- data/ruby_ex/session/fetcher.rb +0 -62
- data/ruby_ex/session/hookable.rb +0 -26
- data/ruby_ex/session/profile.rb +0 -110
- data/ruby_ex/session/server.rb +0 -582
- data/ruby_ex/session/test/administrable_test.rb +0 -337
- data/ruby_ex/session/test/basic_test.rb +0 -523
- data/ruby_ex/session/test/dispatcher_test.rb +0 -409
- data/ruby_ex/session/test/fetchable_test.rb +0 -119
- data/ruby_ex/session/test/sub_server_test.rb +0 -188
- data/ruby_ex/shuffle.rb +0 -30
- data/ruby_ex/spring.rb +0 -136
- data/ruby_ex/spring_set.rb +0 -137
- data/ruby_ex/string_ex.rb +0 -28
- data/ruby_ex/symtbl.rb +0 -106
- data/ruby_ex/synflow.rb +0 -474
- data/ruby_ex/test/unit/ui/yaml/testrunner.rb +0 -164
- data/ruby_ex/thread_mutex.rb +0 -10
- data/ruby_ex/timeout_ex.rb +0 -81
- data/ruby_ex/top_down.rb +0 -73
- data/ruby_ex/trace.rb +0 -26
- data/ruby_ex/uri/druby.rb +0 -81
- data/ruby_ex/uri/file.rb +0 -65
- data/ruby_ex/uri/ftp_ex.rb +0 -37
- data/ruby_ex/uri/http_ex.rb +0 -43
- data/ruby_ex/uri/ssh.rb +0 -92
- data/ruby_ex/uri/svn.rb +0 -118
- data/ruby_ex/uri_ex.rb +0 -45
- data/ruby_ex/verbose_object.rb +0 -30
- data/ruby_ex/version.rb +0 -66
- data/ruby_ex/yaml/basenode_ext.rb +0 -63
- data/ruby_ex/yaml/chop_header.rb +0 -23
- data/ruby_ex/yaml/transform.rb +0 -449
- data/ruby_ex/yaml/yregexpath.rb +0 -76
- data/src/ask.rb +0 -101
- data/src/changelog.rb +0 -117
- data/src/conflict.rb +0 -20
- data/src/diffstat.rb +0 -42
- data/src/message.rb +0 -64
- data/src/reply-mail.rb +0 -14
- data/src/tools.rb +0 -22
- data/src/vcs.rb +0 -176
data/ruby_ex/uri/ftp_ex.rb
DELETED
@@ -1,37 +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: 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
|
data/ruby_ex/uri/http_ex.rb
DELETED
@@ -1,43 +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: 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
DELETED
@@ -1,92 +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$
|
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
DELETED
@@ -1,118 +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: 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
DELETED
@@ -1,45 +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: 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
|
data/ruby_ex/verbose_object.rb
DELETED
@@ -1,30 +0,0 @@
|
|
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
DELETED
@@ -1,66 +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: 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
|
-
|
@@ -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 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
|