rwdmovies 0.90 → 0.91
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.txt +379 -80
- data/code/superant.com.rwdmovies/amazonsearch.rb +2 -2
- data/code/superant.com.rwdtinkerbackwindow/controlclient.rb +25 -26
- data/code/superant.com.rwdtinkerbackwindow/helptexthashtinkerwin2.rb +29 -5
- data/code/superant.com.rwdtinkerbackwindow/installapplet.rb +6 -3
- data/code/superant.com.rwdtinkerbackwindow/installgemapplet.rb +6 -7
- data/code/superant.com.rwdtinkerbackwindow/installremotegem.rb +19 -0
- data/code/superant.com.rwdtinkerbackwindow/listgemdirs.rb +12 -0
- data/code/superant.com.rwdtinkerbackwindow/listgemzips.rb +2 -2
- data/code/superant.com.rwdtinkerbackwindow/listzips.rb +22 -7
- data/code/superant.com.rwdtinkerbackwindow/openhelpwindowtinkerwin2.rb +3 -0
- data/code/superant.com.rwdtinkerbackwindow/remotegemlist.rb +24 -0
- data/code/superant.com.rwdtinkerbackwindow/removeapplet.rb +10 -6
- data/code/superant.com.rwdtinkerbackwindow/saveconfigurationrecord.rb +1 -1
- data/configuration/language.dist +7 -0
- data/configuration/rwdapplicationidentity.dist +3 -0
- data/configuration/{rwdmovies.cnf → rwdmovies.dist} +4 -1
- data/configuration/{rwdtinker.cnf → rwdtinker.dist} +3 -4
- data/configuration/tinkerwin2variables.dist +17 -0
- data/extras/rconftool.rb +380 -0
- data/extras/zip/ioextras.rb +114 -0
- data/extras/zip/stdrubyext.rb +111 -0
- data/extras/zip/tempfile_bugfixed.rb +195 -0
- data/extras/zip/zip.rb +1377 -0
- data/extras/zip/zipfilesystem.rb +558 -0
- data/extras/zip/ziprequire.rb +61 -0
- data/gui/frontwindow0/superant.com.rwdmovies/2openmoviephoto.rwd +6 -4
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/40rwdlistzips.rwd +9 -10
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/45installremotezip.rwd +44 -0
- data/init.rb +42 -37
- data/rwd_files/HowTo_Movies.txt +6 -0
- data/rwd_files/HowTo_Tinker.txt +25 -1
- data/rwd_files/moviestmp.jpg +0 -0
- data/rwdconfig.dist +6 -0
- data/rwdmovies-0.91.gem +0 -0
- data/tests/checkdepends.sh +4 -0
- data/tests/cleancnf.sh +5 -0
- data/tests/makedist.rb +29 -0
- data/tests/rdep.rb +354 -0
- metadata +26 -21
- data/configuration/language.cnf +0 -5
- data/configuration/rwdapplicationidentity.cnf +0 -3
- data/configuration/rwdmoviesversion.cnf +0 -2
- data/configuration/rwdtinkerversion.cnf +0 -2
- data/configuration/tinkerwin2variables.cnf +0 -8
- data/configuration/tinkerwin2version.cnf +0 -3
- data/installed/rwdtinkerwin2-0.5.inf +0 -8
- data/lang/alanguagehashbegin.rb +0 -4
- data/lang/languagehash.rb +0 -4
- data/lang/templangfile.rb +0 -16
- data/lang/vlanguagehashend.rb +0 -6
- data/lang/wlocallangstart.rb +0 -5
- data/lang/xlocallangfile.rb +0 -16
- data/lang/zlocallangend.rb +0 -2
- data/zips/rwdwcalc-0.50.zip +0 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'zip/zip'
|
2
|
+
|
3
|
+
class ZipList
|
4
|
+
def initialize(zipFileList)
|
5
|
+
@zipFileList = zipFileList
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_input_stream(entry, &aProc)
|
9
|
+
@zipFileList.each {
|
10
|
+
|zfName|
|
11
|
+
Zip::ZipFile.open(zfName) {
|
12
|
+
|zf|
|
13
|
+
begin
|
14
|
+
return zf.get_input_stream(entry, &aProc)
|
15
|
+
rescue Errno::ENOENT
|
16
|
+
end
|
17
|
+
}
|
18
|
+
}
|
19
|
+
raise Errno::ENOENT,
|
20
|
+
"No matching entry found in zip files '#{@zipFileList.join(', ')}' "+
|
21
|
+
" for '#{entry}'"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
module Kernel
|
27
|
+
alias :oldRequire :require
|
28
|
+
|
29
|
+
def require(moduleName)
|
30
|
+
zip_require(moduleName) || oldRequire(moduleName)
|
31
|
+
end
|
32
|
+
|
33
|
+
def zip_require(moduleName)
|
34
|
+
return false if already_loaded?(moduleName)
|
35
|
+
get_resource(ensure_rb_extension(moduleName)) {
|
36
|
+
|zis|
|
37
|
+
eval(zis.read); $" << moduleName
|
38
|
+
}
|
39
|
+
return true
|
40
|
+
rescue Errno::ENOENT => ex
|
41
|
+
return false
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_resource(resourceName, &aProc)
|
45
|
+
zl = ZipList.new($:.grep(/\.zip$/))
|
46
|
+
zl.get_input_stream(resourceName, &aProc)
|
47
|
+
end
|
48
|
+
|
49
|
+
def already_loaded?(moduleName)
|
50
|
+
moduleRE = Regexp.new("^"+moduleName+"(\.rb|\.so|\.dll|\.o)?$")
|
51
|
+
$".detect { |e| e =~ moduleRE } != nil
|
52
|
+
end
|
53
|
+
|
54
|
+
def ensure_rb_extension(aString)
|
55
|
+
aString.sub(/(\.rb)?$/i, ".rb")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Copyright (C) 2002 Thomas Sondergaard
|
60
|
+
# rubyzip is free software; you can redistribute it and/or
|
61
|
+
# modify it under the terms of the ruby license.
|
@@ -6,30 +6,29 @@ $rwdguivar=
|
|
6
6
|
<row> <p align=\"right\">File Name:</p> <text size=70 name=\"a_installapplet\"/> </row>
|
7
7
|
|
8
8
|
</table>
|
9
|
-
|
10
|
-
<button caption=\"view applet contents\" action=\"viewappletcontents\"/>
|
11
|
-
<button caption=\"view (GEM Directory) applet contents\" action=\"viewgemappletcontents\"/>
|
12
|
-
</horizontal>
|
13
|
-
<p>%appletcontentstext%</p>
|
9
|
+
|
14
10
|
|
15
11
|
<horizontal>
|
16
12
|
|
17
|
-
|
18
|
-
<button caption=\"install applet\" action=\"
|
19
|
-
<button caption=\"install (Gem Directory) applet\" action=\"installgemapplet\"/>
|
13
|
+
|
14
|
+
<button caption=\"install (rwdtinker) applet\" action=\"installgemapplet\"/>
|
20
15
|
<button caption=\"Help\" action=\"runhelpwindowtinkerwin2\"/>
|
21
16
|
|
22
17
|
</horizontal>
|
23
18
|
<p>%installapplettext%</p>
|
24
19
|
|
25
|
-
|
20
|
+
<horizontal>
|
21
|
+
|
22
|
+
<button caption=\"view (rwdtinker) applet contents\" action=\"viewgemappletcontents\"/>
|
23
|
+
</horizontal>
|
24
|
+
<p>%appletcontentstext%</p>
|
26
25
|
<table>
|
27
26
|
<row> <p align=\"right\">Click below to view the list of zip files </row>
|
28
27
|
|
29
28
|
</table>
|
30
29
|
|
31
30
|
<horizontal>
|
32
|
-
<button caption=\"List applets available for installing\" action=\"listzipfilestoinstall\"/>
|
31
|
+
<button caption=\"List (zip directory) applets available for installing\" action=\"listzipfilestoinstall\"/>
|
33
32
|
|
34
33
|
<button caption=\"List applets (in the GEM Directory) available for installing\" action=\"listgemzips\"/>
|
35
34
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
$rwdguivar=
|
2
|
+
"
|
3
|
+
<tab name=\"superantcomremotezipsinstall\" caption=\"Install Remote Applets\">
|
4
|
+
|
5
|
+
<table>
|
6
|
+
<row> <p align=\"right\">File Name:</p> <text size=70 name=\"superantcominstallremoteappletinput\"/> </row>
|
7
|
+
|
8
|
+
</table>
|
9
|
+
<horizontal>
|
10
|
+
<button caption=\"install remote Gem applet package\" action=\"superantcominstallremotegemapplet\"/>
|
11
|
+
<button caption=\"Help\" action=\"runhelpwindowtinkerwin2\"/>
|
12
|
+
|
13
|
+
</horizontal>
|
14
|
+
<p>%superantcominstallremotegemappletresult%</p>
|
15
|
+
|
16
|
+
<horizontal>
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
<button caption=\"view already installed GEM applets\" action=\"superantcomshowgemfiledirs\"/>
|
21
|
+
</horizontal>
|
22
|
+
<p>%%superantcomshowgemappletdirsresult%%</p>
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
<table>
|
29
|
+
<row> <p align=\"right\">Click below to view the list of zip files </row>
|
30
|
+
|
31
|
+
</table>
|
32
|
+
|
33
|
+
<horizontal>
|
34
|
+
|
35
|
+
<button caption=\"List applets in the Remote GEM Repository available for downloading\" action=\"superantcomremotegemlist\"/>
|
36
|
+
|
37
|
+
</horizontal>
|
38
|
+
<p>%superantcomremotegemappletsfullresult%</p>
|
39
|
+
<p>%%superantcomremotegemappletsresult%%</p>
|
40
|
+
|
41
|
+
</tab>"
|
42
|
+
|
43
|
+
|
44
|
+
|
data/init.rb
CHANGED
@@ -23,6 +23,7 @@
|
|
23
23
|
|
24
24
|
require "ev/rwd"
|
25
25
|
require 'fileutils'
|
26
|
+
require 'extras/rconftool'
|
26
27
|
|
27
28
|
$progdir = File::expand_path( File.dirname(__FILE__))
|
28
29
|
|
@@ -51,15 +52,33 @@ $progdir = File::expand_path( File.dirname(__FILE__))
|
|
51
52
|
if(!test(?d,x))
|
52
53
|
# only rwd files
|
53
54
|
if x =~ /rb|rwd|txt/
|
54
|
-
|
55
|
-
|
55
|
+
|
56
|
+
load x #opens the file thats in fileName and reads it
|
57
|
+
$tempdoc += $rwdguivar # adds the file into the doc string
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
63
|
+
# integrate the new configuration files
|
64
|
+
MAINconfignew = "rwdconfig.cnf"
|
65
|
+
MAINconfigdist = "rwdconfig.dist"
|
66
|
+
Rconftool::install(MAINconfigdist,MAINconfignew)
|
67
|
+
|
68
|
+
Dir.chdir("configuration") #changes the current working directory
|
69
|
+
|
70
|
+
fileList = Dir.new(".").entries.sort.reverse.delete_if { |x| ! (x =~ /dist$/) } #creates an Array separated with \n
|
71
|
+
@doc = ""
|
72
|
+
fileList.length.times{ #opening of a block
|
73
|
+
configdist =fileList.pop #pops the first item out of the Array
|
74
|
+
tempconfigfile = configdist.gsub(/\.dist$/, "")
|
75
|
+
confignew = tempconfigfile + ".cnf"
|
76
|
+
Rconftool::install(configdist,confignew) #integrates new file with old
|
77
|
+
} #closing block
|
78
|
+
# END of configuration integration
|
79
|
+
Dir.chdir($progdir)
|
80
|
+
|
61
81
|
# Read in the configuration files
|
62
|
-
|
63
82
|
Dir.chdir("configuration") #changes the current working directory
|
64
83
|
|
65
84
|
fileList = Dir.new(".").entries.sort.reverse.delete_if { |x| ! (x =~ /cnf$/) } #creates an Array separated with \n
|
@@ -69,10 +88,12 @@ $progdir = File::expand_path( File.dirname(__FILE__))
|
|
69
88
|
load fileName #loads the the config file thats in fileName
|
70
89
|
} #closing block
|
71
90
|
# END of configuration reading
|
72
|
-
|
91
|
+
|
73
92
|
Dir.chdir($progdir) # change back to top program directory
|
74
93
|
|
75
94
|
# build the English Language hash file from the parts
|
95
|
+
languagehashvariable = 'Message = Hash.new { |hh, kk| hh[kk] = "ERROR: Message not found: #{kk.inspect}."; hh[kk] }
|
96
|
+
langmessage = {' + "\n"
|
76
97
|
startlangdir = File.join(LangDir,"en")
|
77
98
|
#get a list of the files and subdirectories on the starting directory only
|
78
99
|
alanghash = Array.new(Dir[startlangdir].entries.sort)
|
@@ -100,10 +121,11 @@ $progdir = File::expand_path( File.dirname(__FILE__))
|
|
100
121
|
end
|
101
122
|
end
|
102
123
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
124
|
+
|
125
|
+
#writes the contents of doc into the languagehashvariable
|
126
|
+
languagehashvariable = languagehashvariable + $tempdoc + "} ; langmessage.each { |kk, vv| Message[kk] = vv }"
|
127
|
+
|
128
|
+
# END of en Lang building
|
107
129
|
$tempdoc = " "
|
108
130
|
Dir.chdir($progdir) # change back to top program directory
|
109
131
|
|
@@ -135,31 +157,16 @@ $progdir = File::expand_path( File.dirname(__FILE__))
|
|
135
157
|
end
|
136
158
|
end
|
137
159
|
|
138
|
-
|
139
|
-
|
140
|
-
|
160
|
+
|
161
|
+
#writes the contents of doc into the variable
|
162
|
+
languagehashvariable = languagehashvariable + " ; Message.update(" + $tempdoc + ' :rwdtinker => "Rwdtinker" ) '
|
163
|
+
|
141
164
|
|
142
165
|
$tempdoc = " "
|
143
166
|
|
144
167
|
Dir.chdir($progdir) # change back to top program directory
|
145
|
-
|
146
|
-
|
147
|
-
#get a list of the files in lang directory only
|
148
|
-
alangfile = Dir.new(LangDir).entries.sort.reverse.delete_if { |x| ! (x =~ /rb$/) }
|
149
|
-
alangfile.length.times{
|
150
|
-
fileName = alangfile.pop
|
151
|
-
Dir.chdir($progdir)
|
152
|
-
Dir.chdir(LangDir)
|
153
|
-
fileLangA=File.open("#{fileName}","r") #opens the file thats in fileName as read only
|
154
|
-
$tempdoc += fileLangA.read #reads the file into the doc string
|
155
|
-
fileLangA.close
|
156
|
-
}
|
157
|
-
|
158
|
-
Dir.chdir($progdir)
|
159
|
-
fileLangB=File.open(LangNameFile,"w") #deletes and opens a the file in fileName
|
160
|
-
fileLangB.write($tempdoc) #writes the contents of doc into the file
|
161
|
-
fileLangB.close
|
162
|
-
load LangNameFile # load the file
|
168
|
+
|
169
|
+
temp = eval( languagehashvariable )
|
163
170
|
|
164
171
|
$tempdoc = " "
|
165
172
|
|
@@ -190,10 +197,9 @@ Dir.chdir($progdir)
|
|
190
197
|
end
|
191
198
|
end
|
192
199
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
require CodeName # load the program file
|
200
|
+
|
201
|
+
# load the program file
|
202
|
+
tempcoderesult = eval( $tempdoc )
|
197
203
|
|
198
204
|
# build the actual GUI from the gui parts
|
199
205
|
$tempdoc = " "
|
@@ -224,9 +230,8 @@ Dir.chdir($progdir)
|
|
224
230
|
end
|
225
231
|
end
|
226
232
|
|
227
|
-
|
228
|
-
|
229
|
-
fileB.close
|
233
|
+
# gui variable is done
|
234
|
+
guiRWD = $tempdoc
|
230
235
|
|
231
236
|
require 'socket' # Network stuff
|
232
237
|
host = "127.0.0.1"
|
@@ -266,4 +271,4 @@ $port = port
|
|
266
271
|
end
|
267
272
|
|
268
273
|
|
269
|
-
RwdTinker.
|
274
|
+
RwdTinker.new( guiRWD).serve(port) # start the main class and program
|
data/rwd_files/HowTo_Movies.txt
CHANGED
@@ -48,6 +48,12 @@ steven@superant.com
|
|
48
48
|
http://rwdapplications.rubyforge.org/wiki/wiki.pl
|
49
49
|
|
50
50
|
== Changelog
|
51
|
+
version 0.91
|
52
|
+
updated for rwdtinker version 1.58
|
53
|
+
added rconftool use to update configuration files
|
54
|
+
changed applets removal to not use external rm
|
55
|
+
removed version number from directory name
|
56
|
+
|
51
57
|
version 0.9
|
52
58
|
added back Amazon search
|
53
59
|
changed width of text fields
|
data/rwd_files/HowTo_Tinker.txt
CHANGED
@@ -226,7 +226,31 @@ http://www.erikveen.dds.nl/rubywebdialogs/index.html
|
|
226
226
|
|
227
227
|
Thanks, Steven Gibson
|
228
228
|
|
229
|
-
== Changelog
|
229
|
+
== Changelog
|
230
|
+
version 1.58
|
231
|
+
check for zlib
|
232
|
+
check for files to delete
|
233
|
+
|
234
|
+
version 1.57
|
235
|
+
added rconftool use to update configuration files
|
236
|
+
changed applets remove to not used external rm
|
237
|
+
|
238
|
+
version 1.56
|
239
|
+
refactored gui files to load without intermediate files
|
240
|
+
refactored code files to load without intermediate files
|
241
|
+
|
242
|
+
version 1.55
|
243
|
+
refactored language files to load without intermediate files
|
244
|
+
refactored language files to load without intermediate files
|
245
|
+
|
246
|
+
version 1.54
|
247
|
+
refactored rwdtinker applet installation tab - remote gem and local installs share menu buttons
|
248
|
+
corrected some program logic errors in remote control code including close socket
|
249
|
+
|
250
|
+
version 1.53
|
251
|
+
added search of Gems repository for rwdtinker gems
|
252
|
+
download and install of Gems
|
253
|
+
|
230
254
|
version 1.52
|
231
255
|
added function to install applets from gem directory
|
232
256
|
|
data/rwd_files/moviestmp.jpg
CHANGED
Binary file
|
data/rwdconfig.dist
ADDED
data/rwdmovies-0.91.gem
ADDED
Binary file
|
data/tests/cleancnf.sh
ADDED
data/tests/makedist.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
#***********************************************************************
|
3
|
+
#* Rwd/Movies -- 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/rwdmovies.dist'
|
10
|
+
|
11
|
+
$progdir = File::expand_path( File.dirname(__FILE__))
|
12
|
+
results = " "
|
13
|
+
puts "creating rwdmovies distribution files version #{RwdMoviesVersion}"
|
14
|
+
puts "cleaning conf files"
|
15
|
+
`tests/cleancnf.sh`
|
16
|
+
puts "moving up one directory"
|
17
|
+
Dir.chdir("..")
|
18
|
+
|
19
|
+
zipcreatecmd = "zip -r rwdmovies-#{RwdMoviesVersion}.zip rwdmovies"
|
20
|
+
puts "#{zipcreatecmd}"
|
21
|
+
`#{zipcreatecmd}`
|
22
|
+
tarcreatecmd = "tar --gzip -cf rwdmovies-#{RwdMoviesVersion}.tar.gz rwdmovies"
|
23
|
+
puts "#{tarcreatecmd}"
|
24
|
+
`#{tarcreatecmd}`
|
25
|
+
tarcreatecmd2 = "tar --bzip2 -cf rwdmovies-#{RwdMoviesVersion}.tar.bz2 rwdmovies"
|
26
|
+
puts "#{tarcreatecmd2}"
|
27
|
+
`#{tarcreatecmd2}`
|
28
|
+
|
29
|
+
print Dir["rwdmovies*.{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
|
+
|