rwdtorrent 0.01

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. data/Readme.txt +146 -0
  2. data/bin/rwdtorrent +19 -0
  3. data/code/01rwdcore/01rwdcore.rb +22 -0
  4. data/code/01rwdcore/02helptexthashbegin.rb +4 -0
  5. data/code/01rwdcore/03helptexthash.rb +31 -0
  6. data/code/01rwdcore/04helptextend.rb +6 -0
  7. data/code/01rwdcore/openhelpwindow.rb +31 -0
  8. data/code/01rwdcore/returntomain.rb +10 -0
  9. data/code/01rwdcore/rwdtinkerversion.rb +15 -0
  10. data/code/01rwdcore/rwdwindowreturn.rb +11 -0
  11. data/code/01rwdcore/test_cases.rb +126 -0
  12. data/code/01rwdcore/test_harness.rb +15 -0
  13. data/code/01rwdcore/uploadreturns.rb +62 -0
  14. data/code/superant.com.rwdtinkerbackwindow/controlclient.rb +99 -0
  15. data/code/superant.com.rwdtinkerbackwindow/diagnostictab.rb +25 -0
  16. data/code/superant.com.rwdtinkerbackwindow/helptexthashtinkerwin2.rb +61 -0
  17. data/code/superant.com.rwdtinkerbackwindow/installapplet.rb +24 -0
  18. data/code/superant.com.rwdtinkerbackwindow/installgemapplet.rb +20 -0
  19. data/code/superant.com.rwdtinkerbackwindow/installremotegem.rb +19 -0
  20. data/code/superant.com.rwdtinkerbackwindow/listgemdirs.rb +12 -0
  21. data/code/superant.com.rwdtinkerbackwindow/listgemzips.rb +54 -0
  22. data/code/superant.com.rwdtinkerbackwindow/listinstalledfiles.rb +11 -0
  23. data/code/superant.com.rwdtinkerbackwindow/listzips.rb +31 -0
  24. data/code/superant.com.rwdtinkerbackwindow/loadconfigurationrecord.rb +32 -0
  25. data/code/superant.com.rwdtinkerbackwindow/loadconfigurationvariables.rb +13 -0
  26. data/code/superant.com.rwdtinkerbackwindow/network.rb +87 -0
  27. data/code/superant.com.rwdtinkerbackwindow/openappletname.rb +18 -0
  28. data/code/superant.com.rwdtinkerbackwindow/openhelpwindowtinkerwin2.rb +42 -0
  29. data/code/superant.com.rwdtinkerbackwindow/remotegemlist.rb +24 -0
  30. data/code/superant.com.rwdtinkerbackwindow/removeapplet.rb +32 -0
  31. data/code/superant.com.rwdtinkerbackwindow/runrwdtinkerbackwindow.rb +12 -0
  32. data/code/superant.com.rwdtinkerbackwindow/rwdtinkerwin2version.rb +14 -0
  33. data/code/superant.com.rwdtinkerbackwindow/saveconfigurationrecord.rb +18 -0
  34. data/code/superant.com.rwdtinkerbackwindow/viewappletcontents.rb +21 -0
  35. data/code/superant.com.rwdtinkerbackwindow/viewgemappletcontents.rb +21 -0
  36. data/code/superant.com.rwdtorrent/helptesthashrwdtorrent.rb +55 -0
  37. data/code/superant.com.rwdtorrent/listnamerecord.rb +15 -0
  38. data/code/superant.com.rwdtorrent/loadconfigurationrecord.rb +36 -0
  39. data/code/superant.com.rwdtorrent/loadconfigurationvariables.rb +13 -0
  40. data/code/superant.com.rwdtorrent/openhelpwindowtorrent.rb +32 -0
  41. data/code/superant.com.rwdtorrent/returntomain.rb +10 -0
  42. data/code/superant.com.rwdtorrent/runtorrentwindow.rb +57 -0
  43. data/code/superant.com.rwdtorrent/rwdtorrenthelpabout.rb +14 -0
  44. data/code/superant.com.rwdtorrent/saveconfigurationrecord.rb +18 -0
  45. data/code/superant.com.rwdtorrent/stoptorrentdownload.rb +12 -0
  46. data/code/superant.com.rwdtorrent/viewtorrentlist.rb +20 -0
  47. data/code/superant.com.rwdtorrent/viewtorrentmetafile.rb +36 -0
  48. data/code/zz0applicationend/zz0end.rb +4 -0
  49. data/configuration/language.dist +7 -0
  50. data/configuration/rwdapplicationidentity.dist +3 -0
  51. data/configuration/rwdtinker.dist +15 -0
  52. data/configuration/rwdtorrent.dist +11 -0
  53. data/configuration/tinkerwin2variables.dist +17 -0
  54. data/downloads/nodownloads.txt +1 -0
  55. data/ev/browser.rb +109 -0
  56. data/ev/ftools.rb +170 -0
  57. data/ev/net.rb +750 -0
  58. data/ev/ruby.rb +819 -0
  59. data/ev/rwd.rb +1849 -0
  60. data/ev/sgml.rb +236 -0
  61. data/ev/thread.rb +63 -0
  62. data/ev/tree.rb +343 -0
  63. data/ev/xml.rb +4 -0
  64. data/extras/aversa.rb +261 -0
  65. data/extras/rconftool.rb +380 -0
  66. data/extras/rubytorrent.rb +94 -0
  67. data/extras/rubytorrent/bencoding.rb +174 -0
  68. data/extras/rubytorrent/controller.rb +610 -0
  69. data/extras/rubytorrent/message.rb +128 -0
  70. data/extras/rubytorrent/metainfo.rb +214 -0
  71. data/extras/rubytorrent/package.rb +600 -0
  72. data/extras/rubytorrent/peer.rb +536 -0
  73. data/extras/rubytorrent/server.rb +166 -0
  74. data/extras/rubytorrent/tracker.rb +225 -0
  75. data/extras/rubytorrent/typedstruct.rb +132 -0
  76. data/extras/rubytorrent/util.rb +186 -0
  77. data/extras/zip/ioextras.rb +114 -0
  78. data/extras/zip/stdrubyext.rb +111 -0
  79. data/extras/zip/tempfile_bugfixed.rb +195 -0
  80. data/extras/zip/zip.rb +1377 -0
  81. data/extras/zip/zipfilesystem.rb +558 -0
  82. data/extras/zip/ziprequire.rb +61 -0
  83. data/gui/00coreguibegin/applicationguitop.rwd +4 -0
  84. data/gui/frontwindow0/10viewnote.rwd +32 -0
  85. data/gui/frontwindow0/30viewtorrent.rwd +13 -0
  86. data/gui/frontwindow0/40rwdtorrentrefresh.rwd +28 -0
  87. data/gui/frontwindow0/67viewconfiguration.rwd +38 -0
  88. data/gui/frontwindowselectionbegin/selectiontabbegin/selectiontabbegin.rwd +16 -0
  89. data/gui/frontwindowselections/superant.com.rwdtinkerwin2selectiontab/rwdwin2selectiontab.rwd +12 -0
  90. data/gui/frontwindowselectionzend/viewselectionzend/viewselectionend.rwd +3 -0
  91. data/gui/frontwindowtdocumentbegin/superant.com.documentsbegin/tt0documentbegin.rwd +6 -0
  92. data/gui/frontwindowtdocuments/superant.com.documents/uu5documents.rwd +15 -0
  93. data/gui/frontwindowtdocuments/superant.com.tinkerwin2documents/uu5documents.rwd +6 -0
  94. data/gui/frontwindowtdocuments/superant.com.torrentdocument/doctorrent.rwd +6 -0
  95. data/gui/frontwindowtdocumentzend/superant.com.documentsend/ww0documentend.rwd +12 -0
  96. data/gui/frontwindowz1end/frontwindowend/xx0rwdfirsttab.rwd +6 -0
  97. data/gui/helpaboutbegin/superant.com.helpaboutbegin/ya0helpscreenstart.rwd +3 -0
  98. data/gui/helpaboutinstalled/superant.com.tinkerhelpabout/1appname.rwd +4 -0
  99. data/gui/helpaboutinstalled/superant.com.tinkerhelpabout/3copyright.rwd +3 -0
  100. data/gui/helpaboutinstalled/superant.com.tinkerhelpabout/5version.rwd +10 -0
  101. data/gui/helpaboutinstalled/superant.com.torrenthelpabout/1appname.rwd +4 -0
  102. data/gui/helpaboutinstalled/superant.com.torrenthelpabout/3copyright.rwd +3 -0
  103. data/gui/helpaboutinstalled/superant.com.torrenthelpabout/5version.rwd +9 -0
  104. data/gui/helpaboutzend/superant.com.helpaboutend/helpscreenend.rwd +3 -0
  105. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/1appname.rwd +5 -0
  106. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/40rwdlistzips.rwd +42 -0
  107. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/45installremotezip.rwd +44 -0
  108. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/50rwdlistapplets.rwd +44 -0
  109. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/60editconfiguration.rwd +38 -0
  110. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/70rwddiagnostics.rwd +29 -0
  111. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/75rwdcontrol.rwd +33 -0
  112. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/80tab1.rwd +11 -0
  113. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/9backend.rwd +6 -0
  114. data/gui/tinkerbackwindows/superant.com.tinkerhelpwindow/1appname.rwd +31 -0
  115. data/gui/tinkerbackwindows/superant.com.tinkerhelpwindow/9end.rwd +4 -0
  116. data/gui/tinkerbackwindows/superant.com.torrentdisplay/torrentdisplaywindow.rwd +31 -0
  117. data/gui/tinkerbackwindows/superant.com.versionwindow/1appname.rwd +19 -0
  118. data/gui/zzcoreguiend/tinkerapplicationguiend/yy9rwdend.rwd +4 -0
  119. data/init.rb +277 -0
  120. data/installed/rwdviewlogo-0.4.inf +4 -0
  121. data/lang/en/rwdcore/languagefile.rb +16 -0
  122. data/lang/es/rwdcore/languagefile-es.rb +14 -0
  123. data/lang/jp/rwdcore/languagefile.rb +9 -0
  124. data/lang/nl/rwdcore/languagefile.rb +19 -0
  125. data/lib/temp.rb +1 -0
  126. data/rwd_files/HowTo_Tinker.txt +405 -0
  127. data/rwd_files/HowTo_TinkerWin2.txt +202 -0
  128. data/rwd_files/HowTo_Torrent.txt +146 -0
  129. data/rwd_files/Readme.txt +57 -0
  130. data/rwd_files/favicon.ico +0 -0
  131. data/rwd_files/rdoc-style.css +175 -0
  132. data/rwd_files/rwdapplications.html +54 -0
  133. data/rwd_files/rwdindex.html +6 -0
  134. data/rwd_files/tinker.png +0 -0
  135. data/rwdconfig.dist +10 -0
  136. data/tests/checkdepends.sh +4 -0
  137. data/tests/cleancnf.sh +5 -0
  138. data/tests/makedist.rb +44 -0
  139. data/tests/rdep.rb +354 -0
  140. data/tests/rwdtinkertestEN.rb +163 -0
  141. data/tests/test.result +32 -0
  142. data/tests/totranslate.lang +93 -0
  143. data/torrentfiles/freeculture-audiobook.zip.torrent +0 -0
  144. data/torrentfiles/freeculture.zip.torrent +0 -0
  145. data/zips/rwdahelloworld-0.5.zip +0 -0
  146. metadata +199 -0
@@ -0,0 +1,54 @@
1
+ <html>
2
+ <head>
3
+ <title>
4
+ rwdapplications information
5
+ </title>
6
+ </head>
7
+ <body>
8
+ <h1>
9
+ rwdapplications information (rwdshell)
10
+ </h1>
11
+ <br>
12
+ <h2>
13
+
14
+ Some additional programs in this series
15
+ </h2>
16
+ <h3>
17
+ <br><blockquote>
18
+ rwdaddresses a little address book
19
+ <br><br>
20
+ rwdmovies a database for tracking your dvds and vhs movie collection
21
+ <br><br>
22
+
23
+ you can find these on rubyforge.org
24
+
25
+ </blockquote>
26
+ <br>
27
+
28
+ <br><blockquote>
29
+ Also look for a program called redpimp on rubyforge.org
30
+
31
+ <br><br>
32
+ It is planned to be a pim using RubyWebDialogs
33
+ <br><br>
34
+
35
+ you can find this at http://redpimp.rubyforge.org
36
+
37
+ </blockquote>
38
+ <br>
39
+
40
+
41
+ <br><br>
42
+ For more information see:<br>
43
+ <a href=http://rwdapplications.rubyforge.org/wiki/wiki.pl>http://rwdapplications.rubyforge.org/wiki/wiki.pl</a>
44
+ <br>
45
+ <br>
46
+ For more information about RubyWebDialogs see:<br>
47
+ <a href=http://www.erikveen.dds.nl/rubywebdialogs/index.html>http://www.erikveen.dds.nl/rubywebdialogs/index.html</a>
48
+ <br><br>
49
+ Thanks, Steven Gibson
50
+
51
+
52
+
53
+ </body>
54
+ </html>
@@ -0,0 +1,6 @@
1
+ <HTML>
2
+ <META http-equiv="refresh" content="0; url=http://www.erikveen.dds.nl/rubywebdialogs/index.html">
3
+ <SCRIPT language="javascript1.0">
4
+ location.href="http://www.erikveen.dds.nl/rubywebdialogs/index.html";
5
+ </SCRIPT>
6
+ </HTML>
Binary file
data/rwdconfig.dist ADDED
@@ -0,0 +1,10 @@
1
+ ##VERSION:1.61
2
+ # rwdtinker core configuration file
3
+ ##NAME: ConfigLocation:0
4
+ ConfigLocation=""
5
+ ##NAME: ZipsLocation:0
6
+ ZipsLocation=""
7
+ ##NAME:$testharnessarray:0
8
+ $testharnessarray = ["rwdtinker_all_tests"]
9
+ ##NAME:TestNow:0
10
+ TestNow=false
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ ruby rdep.rb ../*.rb
3
+ echo "checking installapplet.rb"
4
+ ruby rdep.rb ../code/superant.com.rwdtinkerbackwindow/installapplet.rb
data/tests/cleancnf.sh ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+ rm *.cnf
3
+ rm *.bak
4
+ rm configuration/*.cnf
5
+ rm configuration/*.bak
data/tests/makedist.rb ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/ruby -w
2
+ #***********************************************************************
3
+ #* Rwd/torrent -- A Ruby program for the RudyWebDialog.
4
+ #* Copyright (c) 2004, 2005 by Steven Gibson. All Rights Reserved.
5
+ #* at "steven@superant.com".
6
+ #***********************************************************************/
7
+
8
+ require 'fileutils'
9
+ load 'configuration/rwdtorrent.dist'
10
+
11
+ $progdir = File::expand_path( File.dirname(__FILE__))
12
+ results = " "
13
+ puts "creating rwdtorrent distribution files version #{RwdTorrentVersion}"
14
+ puts "cleaning conf files"
15
+ `tests/cleancnf.sh`
16
+ puts "moving up one directory"
17
+ Dir.chdir("..")
18
+
19
+ zipcreatecmd = "zip -r rwdtorrent-#{RwdTorrentVersion}.zip rwdtorrent"
20
+ puts "#{zipcreatecmd}"
21
+ `#{zipcreatecmd}`
22
+ tarcreatecmd = "tar --gzip -cf rwdtorrent-#{RwdTorrentVersion}.tar.gz rwdtorrent"
23
+ puts "#{tarcreatecmd}"
24
+ `#{tarcreatecmd}`
25
+ tarcreatecmd2 = "tar --bzip2 -cf rwdtorrent-#{RwdTorrentVersion}.tar.bz2 rwdtorrent"
26
+ puts "#{tarcreatecmd2}"
27
+ `#{tarcreatecmd2}`
28
+
29
+ gemspecfilename = "rwdtorrent-#{RwdTorrentVersion}.gemspec"
30
+ tobject = Time.now
31
+ year = tobject.year.to_s
32
+ month = tobject.mon.to_s
33
+ daydate = tobject.day.to_s
34
+
35
+ fd = File.open(gemspecfilename,"w")
36
+ fd.print("Gem::Specification.new do |s|\n")
37
+ fd.print(" s.name = %q{rwdtorrent}\n")
38
+ fd.print(" s.version = \"#{RwdTorrentVersion}\"\n")
39
+ fd.print(" s.date = %q{#{year}-#{month}-#{daydate}}")
40
+ load 'rwdtorrent/tests/gemspec'
41
+ fd.print($gemspecvar)
42
+ fd.close
43
+
44
+ print Dir["rwdtorrent*.{gz,bz2,deb,gem}"]
data/tests/rdep.rb ADDED
@@ -0,0 +1,354 @@
1
+ =begin
2
+
3
+ rdep - The Ruby Dependency Tool
4
+ Version 1.4
5
+
6
+ Hal E. Fulton
7
+ 2 November 2002
8
+ Ruby's license
9
+
10
+ Purpose
11
+
12
+ Determine the library files on which a specified Ruby file is dependent
13
+ (and their location and availability).
14
+
15
+ Usage notes
16
+
17
+ Usage: ruby rdep.rb sourcefile
18
+
19
+ The sourcefile may or may not have a .rb extension.
20
+
21
+ The directories in the $: array (which includes the RUBYLIB environment
22
+ variable) are searched first. File extensions are currently searched for
23
+ in this order: no extension, .rb, .o, .so, .dll (this may not be correct).
24
+
25
+ If there are no detected dependencies, the program will give the
26
+ message, "No dependencies found."
27
+
28
+ If the program finds [auto]load and require statements that it can
29
+ understand, it searches for the specified files. Any recognized Ruby
30
+ source files (*.rb) are processed recursively in the same way. No attempt
31
+ is made to open the files that appear to be binary.
32
+
33
+ The program will print up to four lists (any or all may be omitted):
34
+ 1. A list of files it found by going through RUBYLIB.;
35
+ 2. A list of files found under the searchroot (or under '.');
36
+ 3. A list of directories under searchroot which should perhaps be
37
+ added to RUBYLIB; and
38
+ 4. A list of files (without extensions) which could not be found.
39
+
40
+ If there were unparseable [auto]load or require statements, a warning
41
+ will be issued.
42
+
43
+ Between lists 3 and 4, the program will give an opinion about the overall
44
+ situation. The worst case is that files were not found; the uncertain
45
+ case is when there were unparseable statements; and the best case is
46
+ when all files could be found (lists 1 and 2).
47
+
48
+ Exit codes
49
+
50
+ 0 - Usage or successful execution
51
+ 1 - Nonexistent sourcefile specified
52
+ 2 - Improper sourcefile (pipe, special file, ...)
53
+ 3 - Some kind of problem reading a file
54
+
55
+ Limitations
56
+
57
+ Requires Ruby 1.6.0 or higher
58
+ No recursion on binaries
59
+ Can't look at dynamically built names
60
+ Can't detect "tested" requires (e.g.: flag = require "foo.rb")
61
+ [auto]load/require can be preceded only by whitespace on the line
62
+ Only recognizes simple strings ("file" or 'file')
63
+ Does not recognized named constants (e.g.: require MyFile)
64
+ Assumes every directory entry is either a file or subdirectory
65
+ Does not handle the Windows variable RUBYLIB_PREFIX
66
+ May be SLOW if a directory structure is deep (especially
67
+ on Windows with 1.6.x)
68
+
69
+ Known bugs:
70
+
71
+ Logic may be incorrect in terms of search order, file extensions, etc.
72
+ Injected a bug in 1.3: In rare cases will recurse until stack overflow
73
+
74
+ Revision history
75
+
76
+ Version 1.0 - 13 October 2000 - Initial release
77
+ Version 1.1 - 10 July 2001 - Bug fixes
78
+ Version 1.2 - 15 August 2002 - Works correctly on Win98
79
+ Version 1.3 - 21 October 2002 - Removed globals; removed search root;
80
+ added $: instead of RUBYLIB; etc.
81
+ Version 1.4 - 2 November 2002 - Fixed autoload recursion bug
82
+
83
+ To-do list
84
+
85
+ Possibly change extension search order?
86
+ Possibly add extensions to list?
87
+ Are explicit extensions allowed other than .rb?
88
+ Is a null extension really legal?
89
+ Additional tests/safeguards? (file permissions, non-empty files,...)
90
+ Change inconsistent expansion of tilde, dot, etc.?
91
+ Make it smarter somehow??
92
+
93
+ =end
94
+
95
+ #
96
+ # File.doc_skip - iterator to skip embedded docs in Ruby input file
97
+ #
98
+
99
+ class File
100
+
101
+ def doc_skip
102
+ loop do
103
+ str = gets
104
+ break if not str
105
+ if str =~ /^=begin([ \t]|$)/
106
+ loop do
107
+ str = gets
108
+ break if not str
109
+ break if str =~ /^=end([ \t]|$)/
110
+ end
111
+ else
112
+ yield str
113
+ end
114
+ end
115
+ end
116
+
117
+ end
118
+
119
+ class Dependency
120
+
121
+ #
122
+ # unquote - Find the value of a string. Called from scan.
123
+ #
124
+
125
+ def unquote(str)
126
+ # Still more kludgy code.
127
+ return nil if str == nil
128
+ if [?', ?"].include? str[0] # ' Unconfuse gvim
129
+ str = str[1..-2]
130
+ else
131
+ ""
132
+ end
133
+ end
134
+
135
+ #
136
+ # scan - Scans a line and returns the filename from a load or require
137
+ # statement. Returns null string if there was a parsing problem.
138
+ # Returns nil if this is not a load or require.
139
+ #
140
+
141
+ def scan(line)
142
+ line.strip!
143
+ if line =~ /^load/ or line =~ /^auto/ or line =~ /^require/
144
+ @has_dep = true # At least one dependency found.
145
+ # Kludge!!
146
+ junk = %w[ require load autoload ( ) , ] + [""]
147
+ temp = line.split(/[ \t\(\),]/) - junk
148
+ if temp[2] and temp[2][0].chr =~ /[#;]/ # Comments, semi...
149
+ temp = temp[0..1]
150
+ end
151
+ if temp[-1] =~ /\#\{/ # #{} means trouble
152
+ str = ""
153
+ else
154
+ str = unquote(temp[-1]) # May return nil.
155
+ end
156
+ str
157
+ else
158
+ nil
159
+ end
160
+ end
161
+
162
+ #
163
+ # find_files - The heart of the program. Search for files using $:
164
+ #
165
+
166
+ def find_files(source)
167
+ # loadable - This file or some variant can be found in one of the
168
+ # directories in $:
169
+ loadable = false
170
+
171
+ files = [] # Save a list of load/require files.
172
+ found = [] # Save a list of files found (.rb only for now)
173
+
174
+ # Open the file, strip embedded docs, and look for load/require statements.
175
+
176
+ begin
177
+ File.open(source).doc_skip {|line| files << scan(line)}
178
+ rescue => err
179
+ puts "Problem processing file #{source}: #{err}"
180
+ caller.each {|x| puts " #{x}"}
181
+ exit 3
182
+ end
183
+
184
+ # If no dependencies, don't bother searching!
185
+ if ! @has_dep
186
+ puts "No dependencies found."
187
+ exit 0
188
+ end
189
+
190
+ files.compact!
191
+ catch(:skip) do
192
+ for file in files
193
+
194
+ if file == "" # Warning
195
+ @warnfiles << source
196
+ next
197
+ end
198
+
199
+ throw :skip if (@inpath.include? file) || (@cantfind.include? file)
200
+
201
+ if file =~ /\.rb$/ then # Don't add suffix to *.rb
202
+ suffixes = [""] # Hmm... .rbw?? Probably not needed.
203
+ else
204
+ suffixes = @suffixes # Use any suffix (extension)
205
+ end
206
+
207
+ # Look through search path (@search_path)
208
+
209
+ for dir in @search_path
210
+
211
+ for suf in suffixes
212
+ filename = dir + file + suf
213
+ loadable = test ?e, filename
214
+ break if loadable
215
+ end
216
+
217
+ if loadable
218
+ @inpath << filename # Files we found in RUBYLIB
219
+ # Add to 'found' if it's a source file (so we can recurse)
220
+ found << filename if filename =~ /\.rb$/
221
+ break
222
+ end
223
+
224
+ end
225
+
226
+ @cantfind << file if !loadable
227
+ end
228
+ end
229
+
230
+ found.uniq!
231
+ found.compact!
232
+ list = found
233
+ found.each {|x| list += find_files(x)}
234
+
235
+ list
236
+ end
237
+
238
+ #
239
+ # print_list - Print a header message followed by a list of files
240
+ # or directories.
241
+ #
242
+
243
+ def print_list(header, list)
244
+ return if list.empty?
245
+ puts header + "\n\n" # Extra newlines
246
+ list.each {|x| puts " #{x}"}
247
+ puts "\n" # Extra newline
248
+ end
249
+
250
+ SEP = File::Separator
251
+ DIRSEP = if SEP=="/" then ":" else ";" end
252
+
253
+ def execute
254
+ @has_dep = false
255
+ @warnfiles = []
256
+ @newdirs = []
257
+ @inpath = []
258
+ @cantfind = []
259
+ @suffixes = [""] + %w[ .rb .o .so .dll ]
260
+ @rdirs = []
261
+ @global_found = []
262
+
263
+ # No parameters? Usage message
264
+
265
+ if not ARGV[0]
266
+ puts "Usage: ruby rdep.rb sourcefile [searchroot]"
267
+ exit 0
268
+ end
269
+
270
+ # Does sourcefile exist?
271
+
272
+ if ! test ?e, ARGV[0]
273
+ puts "#{ARGV[0]} does not exist."
274
+ exit 1
275
+ end
276
+
277
+ # Is sourcefile a "real" file?
278
+
279
+ if ! test ?f, ARGV[0]
280
+ puts "#{ARGV[0]} is not a regular file."
281
+ exit 2
282
+ end
283
+
284
+ # Be sure to search under the dir where the
285
+ # program lives...
286
+
287
+ @proghome = File.dirname(File.expand_path(ARGV[0]))
288
+ if @proghome != File.expand_path(".")
289
+ $: << @proghome
290
+ end
291
+
292
+ # Get list of dirs in $:
293
+
294
+ @search_path = $:
295
+ @search_path.collect! {|x| x[-1] == SEP ? x : x + SEP }
296
+
297
+ # All real work happens here -- big recursive find
298
+
299
+ find_files(ARGV[0])
300
+
301
+ @warnfiles.uniq!
302
+ @cantfind.uniq!
303
+ @newdirs.uniq!
304
+ @inpath.map! {|x| File.expand_path(x)}
305
+ @inpath.uniq!
306
+
307
+ #
308
+ # Now, what are all the results? Report to user.
309
+ #
310
+
311
+ if @inpath[0]
312
+ print_list("Found in search path:", @inpath)
313
+ if ! @cantfind.empty? && @warnfiles.empty?
314
+ puts "This will probably be sufficient.\n"
315
+ end
316
+ end
317
+
318
+ # Did we use any dirs under the "home"?
319
+
320
+ homedirs = @inpath.find_all {|x| x =~ Regexp.new("^"+@proghome)}
321
+ if homedirs[0] # not empty
322
+ homedirs.map! {|x| File.dirname(x) }.uniq!
323
+ puts "Consider adding these directories to RUBYPATH:\n\n"
324
+ homedirs.each {|x| puts " #{x}" }
325
+ puts
326
+ if @warnfiles[0] and homedirs == [] # There are unparseable statements.
327
+ puts "This will probably NOT be sufficient. See below.\n\n"
328
+ end
329
+ end
330
+
331
+ # What's our opinion?
332
+
333
+ if @cantfind[0] # There are unknown files.
334
+ puts "This will probably NOT be sufficient. See below.\n\n"
335
+ elsif @warnfiles[0] and homedirs == [] # There are unparseable statements.
336
+ puts "Files may still be missing. See below.\n\n"
337
+ else # We think everything is OK.
338
+ puts "This will probably be sufficient."
339
+ end
340
+
341
+ # Report unknown files
342
+ print_list("Not located anywhere:", @cantfind)
343
+
344
+ # Print warning about load/require strings we couldn't understand
345
+ print_list("Warning: Unparseable usages of 'load' or 'require' in:",
346
+ @warnfiles)
347
+ end
348
+
349
+ end
350
+
351
+ Dependency.new.execute
352
+
353
+ exit 0
354
+