vcs 0.1 → 0.2.148

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/Rakefile +17 -3
  2. data/bin/vcs +57 -34
  3. data/doc/jamis.rb +564 -0
  4. data/ruby_ex/abstract.rb +254 -0
  5. data/ruby_ex/abstract_node.rb +85 -0
  6. data/ruby_ex/algorithms/simulated_annealing.rb +140 -0
  7. data/ruby_ex/array_each_pair.rb +18 -0
  8. data/ruby_ex/ask.rb +101 -0
  9. data/ruby_ex/attributed_class.rb +302 -0
  10. data/ruby_ex/cache.rb +373 -0
  11. data/ruby_ex/checkout.rb +12 -0
  12. data/ruby_ex/choose.rb +271 -0
  13. data/ruby_ex/commands.rb +18 -0
  14. data/ruby_ex/commands/command.rb +401 -0
  15. data/ruby_ex/commands/datas.rb +16 -0
  16. data/ruby_ex/commands/datas/data.rb +33 -0
  17. data/ruby_ex/commands/datas/factory.rb +66 -0
  18. data/ruby_ex/commands/factory.rb +66 -0
  19. data/ruby_ex/commands/helpers.rb +67 -0
  20. data/ruby_ex/commands/pipe.rb +64 -0
  21. data/ruby_ex/commands/runners.rb +17 -0
  22. data/ruby_ex/commands/runners/exec.rb +49 -0
  23. data/ruby_ex/commands/runners/fork.rb +97 -0
  24. data/ruby_ex/commands/runners/runner.rb +107 -0
  25. data/ruby_ex/commands/seq.rb +27 -0
  26. data/ruby_ex/config_file.rb +96 -0
  27. data/ruby_ex/const_regexp.rb +59 -0
  28. data/ruby_ex/daemon.rb +134 -0
  29. data/ruby_ex/diff.rb +667 -0
  30. data/ruby_ex/dlogger.rb +62 -0
  31. data/ruby_ex/drb/dispatcher.rb +252 -0
  32. data/ruby_ex/drb/dispatcher_server_test.rb +29 -0
  33. data/ruby_ex/drb/drb_observable.rb +97 -0
  34. data/ruby_ex/drb/drb_observable_pool.rb +27 -0
  35. data/ruby_ex/drb/drb_service.rb +43 -0
  36. data/ruby_ex/drb/drb_undumped_attributes.rb +55 -0
  37. data/ruby_ex/drb/drb_undumped_indexed_object.rb +54 -0
  38. data/ruby_ex/drb/insecure_protected_methods.rb +103 -0
  39. data/ruby_ex/drb/session_client_test.rb +40 -0
  40. data/ruby_ex/drb/session_manager.rb +246 -0
  41. data/ruby_ex/drb/session_server.rb +53 -0
  42. data/ruby_ex/dtime.rb +143 -0
  43. data/ruby_ex/dumpable_proc.rb +63 -0
  44. data/ruby_ex/exception.rb +32 -0
  45. data/ruby_ex/filetype.rb +229 -0
  46. data/ruby_ex/fileutils_ex.rb +44 -0
  47. data/ruby_ex/fold.rb +58 -0
  48. data/ruby_ex/generate_id.rb +44 -0
  49. data/ruby_ex/hookable.rb +262 -0
  50. data/ruby_ex/hooker.rb +54 -0
  51. data/ruby_ex/inactive_timeout.rb +137 -0
  52. data/ruby_ex/indexed_node.rb +66 -0
  53. data/ruby_ex/io_marshal.rb +100 -0
  54. data/ruby_ex/ioo.rb +194 -0
  55. data/ruby_ex/labeled_node.rb +63 -0
  56. data/ruby_ex/logger_observer.rb +23 -0
  57. data/ruby_ex/md5sum.rb +66 -0
  58. data/ruby_ex/mktemp.rb +208 -0
  59. data/ruby_ex/module/attr_once.rb +36 -0
  60. data/ruby_ex/module/autoload_tree.rb +75 -0
  61. data/ruby_ex/module/hierarchy.rb +335 -0
  62. data/ruby_ex/module/instance_method_visibility.rb +73 -0
  63. data/ruby_ex/module_ex.rb +11 -0
  64. data/ruby_ex/node.rb +80 -0
  65. data/ruby_ex/object_monitor.rb +145 -0
  66. data/ruby_ex/object_monitor_activity.rb +33 -0
  67. data/ruby_ex/observable.rb +140 -0
  68. data/ruby_ex/observable_pool.rb +293 -0
  69. data/ruby_ex/orderedhash.rb +252 -0
  70. data/ruby_ex/pathname_ex.rb +152 -0
  71. data/ruby_ex/pp_hierarchy.rb +29 -0
  72. data/ruby_ex/pseudo_cache.rb +190 -0
  73. data/ruby_ex/queue.rb +56 -0
  74. data/ruby_ex/random_generators.rb +25 -0
  75. data/ruby_ex/random_generators/random_generator.rb +31 -0
  76. data/ruby_ex/random_generators/ruby.rb +23 -0
  77. data/ruby_ex/safe_eval.rb +348 -0
  78. data/ruby_ex/sendmail.rb +215 -0
  79. data/ruby_ex/service_manager.rb +121 -0
  80. data/ruby_ex/session/administrable.rb +120 -0
  81. data/ruby_ex/session/client.rb +153 -0
  82. data/ruby_ex/session/const.rb +18 -0
  83. data/ruby_ex/session/dispatcher.rb +184 -0
  84. data/ruby_ex/session/error.rb +21 -0
  85. data/ruby_ex/session/fetchable.rb +57 -0
  86. data/ruby_ex/session/fetcher.rb +62 -0
  87. data/ruby_ex/session/hookable.rb +26 -0
  88. data/ruby_ex/session/profile.rb +110 -0
  89. data/ruby_ex/session/server.rb +582 -0
  90. data/ruby_ex/session/test/administrable_test.rb +337 -0
  91. data/ruby_ex/session/test/basic_test.rb +523 -0
  92. data/ruby_ex/session/test/dispatcher_test.rb +409 -0
  93. data/ruby_ex/session/test/fetchable_test.rb +119 -0
  94. data/ruby_ex/session/test/sub_server_test.rb +188 -0
  95. data/ruby_ex/shuffle.rb +30 -0
  96. data/ruby_ex/spring.rb +136 -0
  97. data/ruby_ex/spring_set.rb +137 -0
  98. data/ruby_ex/string_ex.rb +28 -0
  99. data/ruby_ex/symtbl.rb +106 -0
  100. data/ruby_ex/synflow.rb +474 -0
  101. data/ruby_ex/test/unit/ui/yaml/testrunner.rb +164 -0
  102. data/ruby_ex/thread_mutex.rb +10 -0
  103. data/ruby_ex/timeout_ex.rb +81 -0
  104. data/ruby_ex/top_down.rb +73 -0
  105. data/ruby_ex/trace.rb +26 -0
  106. data/ruby_ex/uri/druby.rb +81 -0
  107. data/ruby_ex/uri/file.rb +65 -0
  108. data/ruby_ex/uri/ftp_ex.rb +37 -0
  109. data/ruby_ex/uri/http_ex.rb +43 -0
  110. data/ruby_ex/uri/ssh.rb +92 -0
  111. data/ruby_ex/uri/svn.rb +118 -0
  112. data/ruby_ex/uri_ex.rb +45 -0
  113. data/ruby_ex/verbose_object.rb +30 -0
  114. data/ruby_ex/version.rb +66 -0
  115. data/ruby_ex/yaml/basenode_ext.rb +63 -0
  116. data/ruby_ex/yaml/chop_header.rb +23 -0
  117. data/ruby_ex/yaml/transform.rb +449 -0
  118. data/ruby_ex/yaml/yregexpath.rb +76 -0
  119. data/src/changelog.rb +28 -18
  120. data/src/conflict.rb +20 -0
  121. data/src/diff.rb +18 -0
  122. data/src/diffstat.rb +9 -3
  123. data/src/last_changed_date.rb +18 -0
  124. data/src/mail.rb +33 -65
  125. data/src/message.rb +15 -9
  126. data/src/mycommit.rb +29 -14
  127. data/src/news.rb +24 -3
  128. data/src/status.rb +17 -0
  129. data/src/svn.rb +2 -2
  130. data/src/vcs.rb +24 -3
  131. metadata +124 -5
  132. data/lrdetools.rb +0 -12
@@ -0,0 +1,215 @@
1
+ #!/usr/bin/env ruby
2
+ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
3
+ # Copyright:: Copyright (c) 2004, 2005 Nicolas Pouillard. All rights reserved.
4
+ # License:: GNU General Public License (GPL).
5
+ # Revision:: $Id: header 98 2004-09-29 12:07:43Z ertai $
6
+
7
+ require 'pathname'
8
+ require 'ostruct'
9
+ require 'optparse'
10
+
11
+
12
+ class Sendmail
13
+
14
+ MAIL_FILE = Pathname.new(',mail')
15
+
16
+ def initialize
17
+ require 'string_ex'
18
+ require 'mktemp'
19
+ require 'yaml/chop_header'
20
+ end
21
+
22
+ def parse_mail_options ( *args )
23
+ email = (defined? EMAIL)? EMAIL : ENV['EMAIL']
24
+ full_name = (defined? FULLNAME)? FULLNAME : ENV['FULLNAME']
25
+ full_email = (defined? FULL_EMAIL)? FULL_EMAIL : "#{full_name} <#{email}>"
26
+ options = OpenStruct.new(
27
+ :from_name => full_email,
28
+ :from => email,
29
+ :to => [],
30
+ :server => ENV['SMTPSERVER'] || 'localhost:25',
31
+ :body => STDIN
32
+ )
33
+ string_args, hash_args = args.partition { |x| x.is_a?(String) }
34
+ hash_args.each do |hash|
35
+ raise ArgumentError, "Bad argument #{hash}" unless hash.is_a?(Hash)
36
+ hash.each do |k,v|
37
+ options.send("#{k}=", v)
38
+ end
39
+ end
40
+ OptionParser.new do |opts|
41
+ opts.separator ''
42
+ opts.on('-b', '--body FILE', 'Choose a file for the mail body') do |aFile|
43
+ options.body = File.open(aFile)
44
+ end
45
+ opts.on('-t', '--mail-to NAME', 'Choose a recipient') do |aString|
46
+ options.to << aString
47
+ end
48
+ opts.on('-s', '--server NAME:PORT', 'Choose a mail server') do |aString|
49
+ options.server, options.port = aString.split(/:/)
50
+ options.port ||= 25
51
+ end
52
+ opts.on('-S', '--subject NAME', 'Choose your mail subject') do |aString|
53
+ options.subject = aString.sub(/\.?$/, '.')
54
+ end
55
+ opts.on('--[no-]sign', 'Sign the message with gpg') do |signed|
56
+ options.signed = signed
57
+ end
58
+ opts.on('--passphrase FILE', 'the passphrase file') do |aFile|
59
+ options.pass = Pathname.new(aFile)
60
+ end
61
+ opts.on('-a', '--[no-]ask', 'Ask a confirmation before sending') do |ask|
62
+ options.ask = ask
63
+ end
64
+ opts.on('--comment STRING', 'Choose a comment for GPG') do |aComment|
65
+ options.comment = aComment
66
+ end
67
+ opts.on('-m', '--[no-]mime', 'Choose the mime protocole') do |mime|
68
+ options.mime = mime
69
+ end
70
+ opts.on_tail('-h', '--help', 'Show this message') do
71
+ puts opts
72
+ exit
73
+ end
74
+ end.parse!(string_args)
75
+ check_mail_options(options)
76
+ options
77
+ end
78
+
79
+
80
+ def check_mail_options ( options )
81
+ raise ArgumentError, 'No recipents' if options.to.empty?
82
+ raise ArgumentError, 'No mail server' if options.server.nil?
83
+ raise ArgumentError, 'No mail subject' if options.subject.nil?
84
+ end
85
+
86
+ #
87
+ # Mail.
88
+ #
89
+ def sendmail ( *args )
90
+
91
+ body, opts = nil, nil
92
+ if MAIL_FILE.exist?
93
+ STDERR.puts "Using the cache file #{MAIL_FILE}"
94
+ MAIL_FILE.open do |mail_file|
95
+ opts = YAML::chop_header(mail_file)
96
+ body = mail_file.read
97
+ end
98
+ else
99
+ opts = parse_mail_options(*args)
100
+ body = (opts.body.nil?)? '' : opts.body.read
101
+ end
102
+ server, port = opts.server.split(/:/)
103
+ port ||= 25
104
+ STDERR.puts "Smtp Server: #{server}"
105
+
106
+ #
107
+ # Ask the user
108
+ #
109
+ if opts.ask
110
+ require 'ask'
111
+ question = %Q[
112
+ |Send a mail, with this subject: #{opts.subject}
113
+ | to #{opts.to.join(', ')}
114
+ | from #{opts.from_name}
115
+ | #{(opts.signed.nil?)? 'not signed !' : 'signed by ' + opts.from}
116
+ |Are you sure?].head_cut!
117
+ raise 'Aborting' if ask(question, :y) == :n
118
+ end
119
+
120
+ require 'net/smtp'
121
+ Net::SMTP.start(server, port) do |smtp|
122
+ smtp.open_message_stream(opts.from, opts.to) do |f|
123
+ f.print %Q[From: #{opts.from_name}
124
+ |Subject: #{opts.subject}
125
+ |To: #{opts.to.join(', ')}\n].head_cut!
126
+ if opts.signed
127
+ TempPath.new do |mail_body|
128
+ mail_body.open('w') do |out|
129
+ if opts.mime
130
+ out.puts '
131
+ |Content-Type: text/plain; charset=ISO-8859-1; format=flowed
132
+ |Content-Transfer-Encoding: 8bit
133
+ |
134
+ |'.head_cut!
135
+ end
136
+ out.print body
137
+ end
138
+ f.print sign_wrap(opts, mail_body)
139
+ end
140
+ else
141
+ f.print "\n" + body
142
+ end
143
+ end
144
+ end
145
+ end
146
+
147
+
148
+ def new_id ( n )
149
+ ([0] * n).map!{ |x| "%X" % rand(15) }.join
150
+ end
151
+ protected :new_id
152
+
153
+
154
+ def sign_wrap ( opts, body )
155
+ id = "===============#{new_id 10}==" if opts.mime
156
+
157
+ TempPath.new do |tmp_name|
158
+ tmp_name.open('w') do |tmp|
159
+ if opts.mime
160
+ tmp.print %Q[
161
+ |MIME-Version: 1.0
162
+ |Content-Type: multipart/signed; micalg=pgp-sha1;
163
+ | protocol="application/pgp-signature";
164
+ | boundary="#{id}"
165
+ |Content-Transfer-Encoding: 8bit
166
+ |
167
+ |This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
168
+ |--#{id}
169
+ |].head_cut!
170
+
171
+ tmp.print body.read
172
+
173
+ tmp.print %Q[
174
+ |
175
+ |--#{id}
176
+ |Content-Type: application/pgp-signature; name="signature.asc"
177
+ |Content-Description: OpenPGP digital signature
178
+ |Content-Disposition: attachment; filename="signature.asc"
179
+ |
180
+ |].head_cut!
181
+ end
182
+
183
+ TempPath.new do |tmp_out|
184
+ pid = fork do
185
+ cmd = %w[ gpg --status-fd 2 --sign --textmode --armor
186
+ --digest-algo sha1 --no-use-agent -u ]
187
+ cmd << "<#{opts.from}>"
188
+ cmd << ((opts.mime)? '--detach-sign' : '--clearsign')
189
+ cmd += [ '--output', tmp_out ]
190
+ if opts.pass
191
+ cmd += [ '--no-tty', '--batch',
192
+ '--passphrase-fd', opts.pass.open.to_i.to_s ]
193
+ end
194
+ cmd += [ '--comment', "'#{opts.comment}'" ] if opts.comment
195
+ STDIN.reopen(body.open)
196
+ exec(*cmd)
197
+ end
198
+ Process.waitpid pid
199
+
200
+ tmp.print tmp_out.read
201
+ tmp.puts "\n--#{id}--" if opts.mime
202
+ end
203
+ end
204
+
205
+ return tmp_name.read
206
+ end
207
+ end
208
+
209
+ end # class Sendmail
210
+
211
+
212
+ if $0 == __FILE__
213
+ $: << Pathname.new(__FILE__).dirname.to_s
214
+ Sendmail.new.sendmail(*ARGV)
215
+ end
@@ -0,0 +1,121 @@
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: service_manager.rb 186 2005-04-03 00:07:45Z ertai $
7
+
8
+
9
+ # A service must implement at least:
10
+ # - start_service(uri, *args, &block)
11
+ # - stop_service
12
+ # - server
13
+ # - thread
14
+ # - uri
15
+ module ServiceManager
16
+
17
+ def start_service(service, uri=nil, *args, &block)
18
+ @services = {} unless defined? @services
19
+ service.start_service(uri, *args, &block)
20
+ @services[service.uri] = service
21
+ end
22
+
23
+ def stop_service(uri)
24
+ if defined? @services
25
+ if service = @services.delete(uri)
26
+ service.stop_service
27
+ end
28
+ end
29
+ end
30
+
31
+ def stop_services
32
+ if defined? @services
33
+ @services.keys.each do |uri|
34
+ stop_service(uri)
35
+ end
36
+ end
37
+ end
38
+
39
+ def count_services
40
+ if defined? @services
41
+ @services.size
42
+ else
43
+ 0
44
+ end
45
+ end
46
+
47
+ def list_services
48
+ if defined? @services
49
+ @services.values
50
+ else
51
+ []
52
+ end
53
+ end
54
+
55
+ def join_services
56
+ if defined? @services
57
+ @services.each { |uri, service| service.thread.join }
58
+ end
59
+ end
60
+
61
+ def each_services(&block)
62
+ if defined? @services
63
+ @services.each { |uri, service| block[uri, service] }
64
+ end
65
+ end
66
+
67
+ def service_server(uri)
68
+ @services[uri].server if defined? @services
69
+ end
70
+
71
+ end # module ServiceManager
72
+
73
+
74
+ if defined? TEST_MODE or __FILE__ == $0
75
+
76
+
77
+ require 'test/unit/ui/yaml/testrunner'
78
+ require 'drb'
79
+
80
+
81
+ class ServiceManagerTest < Test::Unit::TestCase
82
+
83
+ class Foo
84
+ include ServiceManager
85
+
86
+ end
87
+
88
+ module MyService
89
+
90
+ module_function
91
+ def start_service(uri); end
92
+ def stop_service; end
93
+ def uri; 'toto'; end
94
+
95
+ end
96
+
97
+ def test_simple
98
+ f = Foo.new
99
+ f.start_service(DRb)
100
+ assert_equal(1, f.count_services)
101
+ f.start_service(DRb)
102
+ assert_equal(2, f.count_services)
103
+ f.start_service(MyService)
104
+ [ DRb, DRb, MyService ].each do |s|
105
+ assert(f.list_services.include?(s))
106
+ end
107
+ assert_equal(3, f.count_services)
108
+ f.stop_service(MyService.uri)
109
+ assert_equal(2, f.count_services)
110
+ f.start_service(MyService)
111
+ [ DRb, DRb, MyService ].each do |s|
112
+ assert(f.list_services.include?(s))
113
+ end
114
+ f.stop_services
115
+ assert_equal([], f.list_services)
116
+ end
117
+
118
+ end # class ServiceManagerTest
119
+
120
+ end
121
+
@@ -0,0 +1,120 @@
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: administrable.rb 67 2004-12-07 01:00:10Z polrop $
7
+
8
+
9
+ require 'session/server'
10
+
11
+
12
+ module Session
13
+
14
+ module Administrable
15
+
16
+ #
17
+ # Sessions-oriented requests
18
+ #
19
+ protected
20
+ def request_sessions(sid, profile)
21
+ @mutex.synchronize { @sessions }
22
+ end
23
+
24
+ protected
25
+ def request_kick(sid, profile, sid_to_kick)
26
+ prof = nil
27
+ @mutex.synchronize do
28
+ prof = get_profile(sid_to_kick).dup
29
+ if prof[:admin]
30
+ raise(Session::PermissionError,
31
+ "`#{sid_to_kick}' - cannot kick an admin session")
32
+ end
33
+ end
34
+ request(sid_to_kick, :logout)
35
+ end
36
+
37
+ protected
38
+ def request_add_usr(sid, profile, usrname, usrdesc)
39
+ @mutex.synchronize do
40
+ check_usrname(usrname)
41
+ check_usrdesc(usrdesc)
42
+ if @usrdb[usrname].nil?
43
+ @usrdb[usrname] = usrdesc
44
+ else
45
+ raise(Session::UserError, "`#{usrname}' - user already registered")
46
+ end
47
+ usrdesc
48
+ end
49
+ end
50
+
51
+ protected
52
+ def request_del_usr(sid, profile, usrname)
53
+ @mutex.synchronize do
54
+ usrdesc = get_usr_desc(usrname)
55
+ if usrdesc[:admin]
56
+ raise(Session::UserError, "`#{usrname}' - cannot delete admin user")
57
+ end
58
+ @usrdb.delete(usrname)
59
+ end
60
+ end
61
+
62
+ protected
63
+ def request_get_usr_desc(sid, profile, usrname)
64
+ @mutex.synchronize { get_usr_desc(check_usrname(usrname)) }
65
+ end
66
+
67
+ protected
68
+ def request_set_usr_desc(sid, profile, usrname, usrdesc)
69
+ @mutex.synchronize do
70
+ check_usrdesc(usrdesc)
71
+ get_usr_desc(usrname)
72
+ @usrdb[usrname] = usrdesc
73
+ end
74
+ end
75
+
76
+ protected
77
+ def request_set_usrdb(sid, profile, usrdb)
78
+ @mutex.synchronize { @usrdb = check_usrdb(usrdb) }
79
+ end
80
+
81
+ protected
82
+ def request_get_usrdb(sid, profile)
83
+ @mutex.synchronize { @usrdb }
84
+ end
85
+
86
+ protected
87
+ def request_set_max_usr(sid, profile, max_usr)
88
+ @mutex.synchronize { @max_usr = check_max_usr(max_usr) }
89
+ end
90
+
91
+ protected
92
+ def request_get_max_usr(sid, profile)
93
+ @mutex.synchronize { @max_usr }
94
+ end
95
+
96
+ protected
97
+ def request_set_wipeout_delay(sid, profile, wipeout_delay)
98
+ @mutex.synchronize { @wipeout_delay = check_wipeout_delay(wipeout_delay) }
99
+ end
100
+
101
+ protected
102
+ def request_get_wipeout_delay(sid, profile)
103
+ @mutex.synchronize { @wipeout_delay }
104
+ end
105
+
106
+ #
107
+ # Methods
108
+ #
109
+ protected
110
+ def get_usr_desc(usrname)
111
+ usrdesc = @usrdb[usrname]
112
+ if usrdesc.nil?
113
+ raise(Session::UserError, "`#{usrname}' - not a registered user")
114
+ end
115
+ usrdesc
116
+ end
117
+
118
+ end # module Administrable
119
+
120
+ end # module Session