rwddialogmap 0.01

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. data/Readme.txt +475 -0
  2. data/bin/rwddialogmap +19 -0
  3. data/code/01rwdcore/01rwdcore.rb +29 -0
  4. data/code/01rwdcore/02helptexthashbegin.rb +4 -0
  5. data/code/01rwdcore/03helptexthash.rb +23 -0
  6. data/code/01rwdcore/04helptextend.rb +6 -0
  7. data/code/01rwdcore/jumplinkcommand.rb +26 -0
  8. data/code/01rwdcore/openhelpwindow.rb +31 -0
  9. data/code/01rwdcore/returntomain.rb +10 -0
  10. data/code/01rwdcore/rundocuments.rb +10 -0
  11. data/code/01rwdcore/runeditconfiguration.rb +10 -0
  12. data/code/01rwdcore/runhelpabout.rb +10 -0
  13. data/code/01rwdcore/runopentinkerdocument.rb +7 -0
  14. data/code/01rwdcore/rwdtinkerversion.rb +22 -0
  15. data/code/01rwdcore/rwdwindowreturn.rb +9 -0
  16. data/code/01rwdcore/selectiontab.rb +9 -0
  17. data/code/01rwdcore/setuphelpaboutoptions.rb +13 -0
  18. data/code/01rwdcore/setuptinkerdocuments.rb +6 -0
  19. data/code/01rwdcore/test_cases.rb +109 -0
  20. data/code/01rwdcore/test_harness.rb +13 -0
  21. data/code/01rwdcore/uploadreturns.rb +62 -0
  22. data/code/dd0viewphoto/dd0viewphoto.rb +3 -0
  23. data/code/superant.com.dialogmap/0uninstallapplet.rb +12 -0
  24. data/code/superant.com.dialogmap/changedir.rb +31 -0
  25. data/code/superant.com.dialogmap/clearhypernotescreendisplay.rb +14 -0
  26. data/code/superant.com.dialogmap/clearlinkscreendisplay.rb +13 -0
  27. data/code/superant.com.dialogmap/createnewnote.rb +28 -0
  28. data/code/superant.com.dialogmap/helptexthashrwdhypernote.rb +38 -0
  29. data/code/superant.com.dialogmap/launchurlfile.rb +35 -0
  30. data/code/superant.com.dialogmap/listdirectories.rb +19 -0
  31. data/code/superant.com.dialogmap/listdirectories3.rb +25 -0
  32. data/code/superant.com.dialogmap/listnotedirshtml3.rb +54 -0
  33. data/code/superant.com.dialogmap/loadconfigurationrecord.rb +22 -0
  34. data/code/superant.com.dialogmap/loadconfigurationvariables.rb +14 -0
  35. data/code/superant.com.dialogmap/loadhtmlnoterecord.rb +24 -0
  36. data/code/superant.com.dialogmap/openhelpwindowrwdhyernote.rb +38 -0
  37. data/code/superant.com.dialogmap/runhypernote.rb +10 -0
  38. data/code/superant.com.dialogmap/runwrdhypernotetxtwindow.rb +10 -0
  39. data/code/superant.com.dialogmap/rwdhypernoteresetdir.rb +7 -0
  40. data/code/superant.com.dialogmap/rwdtinkerversion.rb +10 -0
  41. data/code/superant.com.dialogmap/saveconfigurationrecord.rb +20 -0
  42. data/code/superant.com.dialogmap/savelinkrecord.rb +23 -0
  43. data/code/superant.com.dialogmap/viewdialogmaphtml3.rb +66 -0
  44. data/code/superant.com.dialogmap/xmlprettyprint.rb +65 -0
  45. data/code/superant.com.dialogmap/xmlprettyprint2.rb +74 -0
  46. data/code/superant.com.rwdtinkerbackwindow/diagnostictab.rb +19 -0
  47. data/code/superant.com.rwdtinkerbackwindow/helptexthashtinkerwin2.rb +61 -0
  48. data/code/superant.com.rwdtinkerbackwindow/initiateapplets.rb +240 -0
  49. data/code/superant.com.rwdtinkerbackwindow/installgemapplet.rb +34 -0
  50. data/code/superant.com.rwdtinkerbackwindow/installremotegem.rb +20 -0
  51. data/code/superant.com.rwdtinkerbackwindow/listgemdirs.rb +12 -0
  52. data/code/superant.com.rwdtinkerbackwindow/listgemzips.rb +53 -0
  53. data/code/superant.com.rwdtinkerbackwindow/listinstalledfiles.rb +12 -0
  54. data/code/superant.com.rwdtinkerbackwindow/listzips.rb +33 -0
  55. data/code/superant.com.rwdtinkerbackwindow/loadconfigurationrecord.rb +22 -0
  56. data/code/superant.com.rwdtinkerbackwindow/loadconfigurationvariables.rb +14 -0
  57. data/code/superant.com.rwdtinkerbackwindow/network.rb +87 -0
  58. data/code/superant.com.rwdtinkerbackwindow/openappletname.rb +19 -0
  59. data/code/superant.com.rwdtinkerbackwindow/openhelpwindowtinkerwin2.rb +38 -0
  60. data/code/superant.com.rwdtinkerbackwindow/remotegemlist.rb +24 -0
  61. data/code/superant.com.rwdtinkerbackwindow/removeapplet.rb +46 -0
  62. data/code/superant.com.rwdtinkerbackwindow/removeappletvariables.rb +52 -0
  63. data/code/superant.com.rwdtinkerbackwindow/runremoteinstall.rb +11 -0
  64. data/code/superant.com.rwdtinkerbackwindow/runrwdtinkerbackwindow.rb +15 -0
  65. data/code/superant.com.rwdtinkerbackwindow/rwdtinkerwin2version.rb +13 -0
  66. data/code/superant.com.rwdtinkerbackwindow/saveconfigurationrecord.rb +19 -0
  67. data/code/superant.com.rwdtinkerbackwindow/viewappletcontents.rb +22 -0
  68. data/code/superant.com.rwdtinkerbackwindow/viewgemappletcontents.rb +24 -0
  69. data/code/zz0applicationend/zz0end.rb +4 -0
  70. data/configuration/language.dist +8 -0
  71. data/configuration/rwdapplicationidentity.dist +3 -0
  72. data/configuration/rwdtinker.dist +15 -0
  73. data/configuration/rwdwdialogmap-0.01.dist +13 -0
  74. data/configuration/tinkerwin2variables.dist +18 -0
  75. data/gui/00coreguibegin/applicationguitop.rwd +4 -0
  76. data/gui/frontwindow0/cc0openphoto.rwd +22 -0
  77. data/gui/frontwindowselections/00selectiontabbegin.rwd +11 -0
  78. data/gui/frontwindowselections/jumplinkcommands.rwd +15 -0
  79. data/gui/frontwindowselections/wwselectionend.rwd +3 -0
  80. data/gui/frontwindowtdocuments/00documentbegin.rwd +6 -0
  81. data/gui/frontwindowtdocuments/tinkerdocuments.rwd +14 -0
  82. data/gui/frontwindowtdocuments/zzdocumentend.rwd +8 -0
  83. data/gui/helpaboutbegin/zzzrwdlasttab.rwd +6 -0
  84. data/gui/helpaboutbegin/zzzzhelpscreenstart.rwd +3 -0
  85. data/gui/helpaboutbegin/zzzzzzhelpabouttab.rwd +15 -0
  86. data/gui/helpaboutzend/helpscreenend.rwd +3 -0
  87. data/gui/helpaboutzend/zhelpscreenstart2.rwd +3 -0
  88. data/gui/helpaboutzend/zzzzhelpabout2.rwd +15 -0
  89. data/gui/helpaboutzend/zzzzhelpscreen2end.rwd +3 -0
  90. data/gui/tinkerbackwindows/superant.com.dialogmap/10appletbegin.rwd +4 -0
  91. data/gui/tinkerbackwindows/superant.com.dialogmap/12dialogview.rwd +65 -0
  92. data/gui/tinkerbackwindows/superant.com.dialogmap/15aviewxml.rwd +32 -0
  93. data/gui/tinkerbackwindows/superant.com.dialogmap/17aviewxml.rwd +28 -0
  94. data/gui/tinkerbackwindows/superant.com.dialogmap/21editnote.rwd +33 -0
  95. data/gui/tinkerbackwindows/superant.com.dialogmap/67viewconfiguration.rwd +29 -0
  96. data/gui/tinkerbackwindows/superant.com.dialogmap/81jumplinkcommands.rwd +17 -0
  97. data/gui/tinkerbackwindows/superant.com.dialogmap/9end.rwd +6 -0
  98. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/1appname.rwd +5 -0
  99. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/40rwdlistzips.rwd +41 -0
  100. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/45installremotezip.rwd +44 -0
  101. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/50rwdlistapplets.rwd +44 -0
  102. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/60editconfiguration.rwd +30 -0
  103. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/70rwddiagnostics.rwd +29 -0
  104. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/81jumplinkcommands.rwd +17 -0
  105. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/9backend.rwd +6 -0
  106. data/gui/tinkerbackwindows/superant.com.tinkerhelpwindow/1appname.rwd +31 -0
  107. data/gui/tinkerbackwindows/superant.com.tinkerhelpwindow/9end.rwd +4 -0
  108. data/gui/tinkerbackwindows/superant.com.versionwindow/1appname.rwd +19 -0
  109. data/gui/tinkerbackwindows/superant.com.versionwindow/helpaboutwindow.rwd +17 -0
  110. data/gui/zzcoreguiend/yy9rwdend.rwd +4 -0
  111. data/init.rb +277 -0
  112. data/installed/dialogmapdata2.inf +2 -0
  113. data/installed/rwdwdialogmap-0.01.inf +8 -0
  114. data/installed/temp.rb +1 -0
  115. data/lang/en/rwdcore/languagefile.rb +58 -0
  116. data/lang/es/rwdcore/languagefile-es.rb +62 -0
  117. data/lang/fr/rwdcore/languagefile.rb +64 -0
  118. data/lang/jp/rwdcore/languagefile.rb +72 -0
  119. data/lang/nl/rwdcore/languagefile.rb +75 -0
  120. data/lib/rconftool.rb +387 -0
  121. data/lib/rwd/browser.rb +123 -0
  122. data/lib/rwd/ftools.rb +174 -0
  123. data/lib/rwd/mime.rb +328 -0
  124. data/lib/rwd/net.rb +876 -0
  125. data/lib/rwd/ruby.rb +889 -0
  126. data/lib/rwd/rwd.rb +1422 -0
  127. data/lib/rwd/sgml.rb +236 -0
  128. data/lib/rwd/thread.rb +63 -0
  129. data/lib/rwd/tree.rb +371 -0
  130. data/lib/rwd/xml.rb +101 -0
  131. data/lib/rwdthemes/default.rwd +317 -0
  132. data/lib/rwdthemes/pda.rwd +72 -0
  133. data/lib/rwdthemes/windowslike.rwd +171 -0
  134. data/lib/zip/ioextras.rb +114 -0
  135. data/lib/zip/stdrubyext.rb +111 -0
  136. data/lib/zip/tempfile_bugfixed.rb +195 -0
  137. data/lib/zip/zip.rb +1378 -0
  138. data/lib/zip/zipfilesystem.rb +558 -0
  139. data/lib/zip/ziprequire.rb +61 -0
  140. data/rwd_files/HowTo_DialogMap.txt +233 -0
  141. data/rwd_files/HowTo_Tinker.txt +482 -0
  142. data/rwd_files/HowTo_TinkerWin2.txt +202 -0
  143. data/rwd_files/Notes/Another Brain Jam.mm +116 -0
  144. data/rwd_files/Notes/HR.xml +2 -0
  145. data/rwd_files/Notes/TaoistBooks.mm +82 -0
  146. data/rwd_files/Readme.txt +57 -0
  147. data/rwd_files/RubyWebDialogs.html +6 -0
  148. data/rwd_files/favicon.ico +0 -0
  149. data/rwd_files/rdoc-style.css +175 -0
  150. data/rwd_files/rwdapplications.html +54 -0
  151. data/rwd_files/tinker.png +0 -0
  152. data/rwdconfig.dist +22 -0
  153. data/rwddialogmap.rb +1 -0
  154. data/tests/RubyGauge.rb +179 -0
  155. data/tests/checkdepends.sh +4 -0
  156. data/tests/cleancnf.sh +6 -0
  157. data/tests/makedist-rwdwdialogmap.rb +58 -0
  158. data/tests/makedist.rb +65 -0
  159. data/tests/rdep.rb +354 -0
  160. data/tests/totranslate.lang +93 -0
  161. data/zips/rwdwaddresses-1.06.zip +0 -0
  162. data/zips/rwdwcalc-0.62.zip +0 -0
  163. data/zips/rwdwdialogmap-0.01.zip +0 -0
  164. data/zips/rwdwfoldeditor-0.04.zip +0 -0
  165. data/zips/rwdwgutenberg-0.09.zip +0 -0
  166. data/zips/rwdwruby-1.07.zip +0 -0
  167. data/zips/temp.rb +1 -0
  168. data/zips/tinkerbellw-0.02.zip +0 -0
  169. data/zips/wrubyslippers-1.06.zip +0 -0
  170. metadata +226 -0
@@ -0,0 +1,171 @@
1
+
2
+
3
+ $rwd_html["WINDOWSLOOKALIKE"] = "
4
+ <!-- Generated by RubyWebDialog. -->
5
+ <!-- For more information, please contact Erik Veenstra <rwd@erikveen.dds.nl>. -->
6
+ <html>
7
+ <head>
8
+ <title>%TITLE%</title>
9
+
10
+ <meta http-equiv='Content-Type' content='text/html; charset=%CHARSET%'>
11
+ <meta http-equiv='Content-Style-Type' content='text/css; charset=UTF-8' >
12
+ <meta http-equiv='Refresh' content='%REFRESH%, javascript:document.bodyform.submit();'>
13
+
14
+ <link rel='shortcut icon' href='%LOGO%'>
15
+
16
+ <style type='text/css'>
17
+ <!--
18
+
19
+ body {
20
+ background : url(%WATERMARK%) white center center no-repeat fixed;
21
+ }
22
+
23
+ a {
24
+ text-decoration : none;
25
+ }
26
+
27
+ a:hover {
28
+ background : #AAAAAA;
29
+ }
30
+
31
+ td.window {
32
+ border-color : #EEEEEE #888888 #888888 #EEEEEE;
33
+ border-width : 3pt;
34
+ border-style : solid solid solid solid;
35
+ }
36
+
37
+ td.panel1 {
38
+ border-color : #888888 #EEEEEE #EEEEEE #888888;
39
+ border-width : 1pt;
40
+ border-style : solid solid solid solid;
41
+ }
42
+
43
+ td.panel2 {
44
+ border-color : #EEEEEE #888888 #888888 #EEEEEE;
45
+ border-width : 1pt;
46
+ border-style : solid solid solid solid;
47
+ }
48
+
49
+ td.panel1high {
50
+ border-color : #EEEEEE #888888 #888888 #EEEEEE;
51
+ border-width : 1pt;
52
+ border-style : solid solid solid solid;
53
+ }
54
+
55
+ td.panel2high {
56
+ border-color : #EEEEEE #888888 #888888 #EEEEEE;
57
+ border-width : 1pt;
58
+ border-style : none none none none;
59
+ }
60
+
61
+ td.panel1low {
62
+ border-color : #888888 #EEEEEE #EEEEEE #888888;
63
+ border-width : 1pt;
64
+ border-style : solid solid solid solid;
65
+ }
66
+
67
+ td.panel2low {
68
+ border-color : #888888 #EEEEEE #EEEEEE #888888;
69
+ border-width : 1pt;
70
+ border-style : none none none none;
71
+ }
72
+
73
+ td.tabblad {
74
+ border-color : #EEEEEE #888888 #888888 #EEEEEE;
75
+ border-width : 1pt;
76
+ border-style : none solid solid solid;
77
+ }
78
+
79
+ td.passivetab {
80
+ background-color : #BBBBBB;
81
+ border-color : #DDDDDD #DDDDDD #EEEEEE #DDDDDD;
82
+ border-width : 1pt;
83
+ border-style : solid solid solid solid;
84
+ }
85
+
86
+ td.activetab {
87
+ border-color : #EEEEEE #888888 #888888 #EEEEEE;
88
+ border-width : 1pt;
89
+ border-style : solid solid none solid;
90
+ }
91
+
92
+ td.notab {
93
+ border-color : #EEEEEE #EEEEEE #EEEEEE #EEEEEE;
94
+ border-width : 1pt;
95
+ border-style : none none solid none;
96
+ }
97
+
98
+ //-->
99
+ </style>
100
+
101
+ <script type='text/javascript'>
102
+ <!--
103
+ function BodyGo() {
104
+ $RWD_FOCUS$
105
+ }
106
+ //-->
107
+ </script>
108
+ </head>
109
+
110
+ <body bgcolor='white' onload='BodyGo()' link='#000000' vlink='#000000' alink='#000000'>
111
+ <form name='bodyform' action='/' method='post'>
112
+ <table align='center' border='0' cellspacing='0' cellpadding='0' width='100%' height='100%'>
113
+ <tr align='center' valign='middle'>
114
+ <td align='center'>
115
+
116
+ <table align='center' border='0' cellspacing='0' cellpadding='0'>
117
+
118
+ <tr align='center'>
119
+ <td align='center' class='window'>
120
+
121
+ <table align='center' border='0' cellspacing='0' cellpadding='0' %WIDTH1%>
122
+ <tr align='center'>
123
+ <td align='center' bgcolor='#444488'>
124
+
125
+ <table align='left' border='0' cellspacing='1' cellpadding='0'>
126
+ <tr align='center'>
127
+ <td align='border'><img src='%LOGO%' width='14' height='14'></td>
128
+ <td align='center'><b><small><font color='#FFFFFF'>&nbsp;%TITLE%&nbsp;</font></small></b></td>
129
+ </tr>
130
+ </table>
131
+
132
+ <table align='right' border='0' cellspacing='1' cellpadding='0'>
133
+ <tr align='center'>
134
+ <!-- %HELPBUTTON% --><td align='center' bgcolor='#EEEEEE'><b><small><a href='javascript:document.bodyform.rwd_action.value=\"rwd_help\";document.bodyform.submit();'>&nbsp;?&nbsp;</a></small></b></td>
135
+ <!-- %BACKBUTTONS% --><td align='center' bgcolor='#EEEEEE'><b><small><a href='javascript:document.bodyform.rwd_action.value=\"rwd_main\";document.bodyform.submit();'>&nbsp;&lt;&lt;&nbsp;</a></small></b></td>
136
+ <!-- %BACKBUTTONS% --><td align='center' bgcolor='#EEEEEE'><b><small><a href='javascript:document.bodyform.rwd_action.value=\"rwd_back\";document.bodyform.submit();'>&nbsp;&lt;&nbsp;</a></small></b></td>
137
+ <!-- %CLOSEBUTTON% --><td align='center' bgcolor='#EEEEEE'><b><small><a href='javascript:document.bodyform.rwd_action.value=\"rwd_quit\";document.bodyform.submit();'>&nbsp;X&nbsp;</a></small></b></td>
138
+ </tr>
139
+ </table>
140
+
141
+ </td>
142
+ </tr>
143
+
144
+ <tr align='center'>
145
+ <td align='center' bgcolor='white'><img src='rwd_pixel.gif' height='1' width='%WIDTH2%'></td>
146
+ </tr>
147
+
148
+ <tr align='center'>
149
+ <td align='center' bgcolor='#CCCCCC'>
150
+ <table align='center' border='0' cellspacing='3' cellpadding='0'>
151
+ %BODY%
152
+ </table>
153
+
154
+ <input name='rwd_action' value='$RWD_FIRSTACTION$' type='hidden'>
155
+ <input name='rwd_session' value='$RWD_SESSION$' type='hidden'>
156
+ </td>
157
+ </tr>
158
+ </table>
159
+
160
+ </td>
161
+ </tr>
162
+
163
+ </table>
164
+
165
+ </td>
166
+ </tr>
167
+ </table>
168
+ </form>
169
+ </body>
170
+ </html>
171
+ "
@@ -0,0 +1,114 @@
1
+ module IOExtras
2
+ module FakeIO
3
+ def kind_of?(object)
4
+ object == IO || super
5
+ end
6
+ end
7
+
8
+ # Implements many of the convenience methods of IO
9
+ # such as gets, getc, readline and readlines
10
+ # depends on: input_finished?, produce_input and read
11
+ module AbstractInputStream
12
+ include Enumerable
13
+ include FakeIO
14
+
15
+ def initialize
16
+ super
17
+ @lineno = 0
18
+ @outputBuffer = ""
19
+ end
20
+
21
+ attr_accessor :lineno
22
+
23
+ def readlines(aSepString = $/)
24
+ retVal = []
25
+ each_line(aSepString) { |line| retVal << line }
26
+ return retVal
27
+ end
28
+
29
+ def gets(aSepString=$/)
30
+ @lineno = @lineno.next
31
+ return read if aSepString == nil
32
+ aSepString="#{$/}#{$/}" if aSepString == ""
33
+
34
+ bufferIndex=0
35
+ while ((matchIndex = @outputBuffer.index(aSepString, bufferIndex)) == nil)
36
+ bufferIndex=@outputBuffer.length
37
+ if input_finished?
38
+ return @outputBuffer.empty? ? nil : flush
39
+ end
40
+ @outputBuffer << produce_input
41
+ end
42
+ sepIndex=matchIndex + aSepString.length
43
+ return @outputBuffer.slice!(0...sepIndex)
44
+ end
45
+
46
+ def flush
47
+ retVal=@outputBuffer
48
+ @outputBuffer=""
49
+ return retVal
50
+ end
51
+
52
+ def readline(aSepString = $/)
53
+ retVal = gets(aSepString)
54
+ raise EOFError if retVal == nil
55
+ return retVal
56
+ end
57
+
58
+ def each_line(aSepString = $/)
59
+ while true
60
+ yield readline(aSepString)
61
+ end
62
+ rescue EOFError
63
+ end
64
+
65
+ alias_method :each, :each_line
66
+ end
67
+
68
+
69
+ #relies on <<
70
+ module AbstractOutputStream
71
+ include FakeIO
72
+
73
+ def write(data)
74
+ self << data
75
+ data.to_s.length
76
+ end
77
+
78
+
79
+ def print(*params)
80
+ self << params.to_s << $\.to_s
81
+ end
82
+
83
+ def printf(aFormatString, *params)
84
+ self << sprintf(aFormatString, *params)
85
+ end
86
+
87
+ def putc(anObject)
88
+ self << case anObject
89
+ when Fixnum then anObject.chr
90
+ when String then anObject
91
+ else raise TypeError, "putc: Only Fixnum and String supported"
92
+ end
93
+ anObject
94
+ end
95
+
96
+ def puts(*params)
97
+ params << "\n" if params.empty?
98
+ params.flatten.each {
99
+ |element|
100
+ val = element.to_s
101
+ self << val
102
+ self << "\n" unless val[-1,1] == "\n"
103
+ }
104
+ end
105
+
106
+ end
107
+
108
+ end # IOExtras namespace module
109
+
110
+
111
+
112
+ # Copyright (C) 2002-2004 Thomas Sondergaard
113
+ # rubyzip is free software; you can redistribute it and/or
114
+ # modify it under the terms of the ruby license.
@@ -0,0 +1,111 @@
1
+ unless Enumerable.method_defined?(:inject)
2
+ module Enumerable #:nodoc:all
3
+ def inject(n = 0)
4
+ each { |value| n = yield(n, value) }
5
+ n
6
+ end
7
+ end
8
+ end
9
+
10
+ module Enumerable #:nodoc:all
11
+ # returns a new array of all the return values not equal to nil
12
+ # This implementation could be faster
13
+ def select_map(&aProc)
14
+ map(&aProc).reject { |e| e.nil? }
15
+ end
16
+ end
17
+
18
+ unless Object.method_defined?(:object_id)
19
+ class Object
20
+ # Using object_id which is the new thing, so we need
21
+ # to make that work in versions prior to 1.8.0
22
+ alias object_id id
23
+ end
24
+ end
25
+
26
+ unless File.respond_to?(:read)
27
+ class File
28
+ # singleton method read does not exist in 1.6.x
29
+ def self.read(fileName)
30
+ open(fileName) { |f| f.read }
31
+ end
32
+ end
33
+ end
34
+
35
+ class String
36
+ def starts_with(aString)
37
+ rindex(aString, 0) == 0
38
+ end
39
+
40
+ def ends_with(aString)
41
+ index(aString, -aString.size)
42
+ end
43
+
44
+ def ensure_end(aString)
45
+ ends_with(aString) ? self : self + aString
46
+ end
47
+
48
+ def lchop
49
+ slice(1, length)
50
+ end
51
+ end
52
+
53
+ class Time
54
+
55
+ #MS-DOS File Date and Time format as used in Interrupt 21H Function 57H:
56
+ #
57
+ # Register CX, the Time:
58
+ # Bits 0-4 2 second increments (0-29)
59
+ # Bits 5-10 minutes (0-59)
60
+ # bits 11-15 hours (0-24)
61
+ #
62
+ # Register DX, the Date:
63
+ # Bits 0-4 day (1-31)
64
+ # bits 5-8 month (1-12)
65
+ # bits 9-15 year (four digit year minus 1980)
66
+
67
+
68
+ def to_binary_dos_time
69
+ (sec/2) +
70
+ (min << 5) +
71
+ (hour << 11)
72
+ end
73
+
74
+ def to_binary_dos_date
75
+ (day) +
76
+ (month << 5) +
77
+ ((year - 1980) << 9)
78
+ end
79
+
80
+ # Dos time is only stored with two seconds accuracy
81
+ def dos_equals(other)
82
+ to_i/2 == other.to_i/2
83
+ end
84
+
85
+ def self.parse_binary_dos_format(binaryDosDate, binaryDosTime)
86
+ second = 2 * ( 0b11111 & binaryDosTime)
87
+ minute = ( 0b11111100000 & binaryDosTime) >> 5
88
+ hour = (0b1111100000000000 & binaryDosTime) >> 11
89
+ day = ( 0b11111 & binaryDosDate)
90
+ month = ( 0b111100000 & binaryDosDate) >> 5
91
+ year = ((0b1111111000000000 & binaryDosDate) >> 9) + 1980
92
+ begin
93
+ return Time.local(year, month, day, hour, minute, second)
94
+ end
95
+ end
96
+ end
97
+
98
+ class Module
99
+ def forward_message(forwarder, *messagesToForward)
100
+ methodDefs = messagesToForward.map {
101
+ |msg|
102
+ "def #{msg}; #{forwarder}(:#{msg}); end"
103
+ }
104
+ module_eval(methodDefs.join("\n"))
105
+ end
106
+ end
107
+
108
+
109
+ # Copyright (C) 2002, 2003 Thomas Sondergaard
110
+ # rubyzip is free software; you can redistribute it and/or
111
+ # modify it under the terms of the ruby license.
@@ -0,0 +1,195 @@
1
+ #
2
+ # tempfile - manipulates temporary files
3
+ #
4
+ # $Id: tempfile_bugfixed.rb,v 1.2 2004/03/28 12:46:36 thomas Exp $
5
+ #
6
+
7
+ require 'delegate'
8
+ require 'tmpdir'
9
+
10
+ module BugFix
11
+
12
+ # A class for managing temporary files. This library is written to be
13
+ # thread safe.
14
+ class Tempfile < DelegateClass(File)
15
+ MAX_TRY = 10
16
+ @@cleanlist = []
17
+
18
+ # Creates a temporary file of mode 0600 in the temporary directory
19
+ # whose name is basename.pid.n and opens with mode "w+". A Tempfile
20
+ # object works just like a File object.
21
+ #
22
+ # If tmpdir is omitted, the temporary directory is determined by
23
+ # Dir::tmpdir provided by 'tmpdir.rb'.
24
+ # When $SAFE > 0 and the given tmpdir is tainted, it uses
25
+ # /tmp. (Note that ENV values are tainted by default)
26
+ def initialize(basename, tmpdir=Dir::tmpdir)
27
+ if $SAFE > 0 and tmpdir.tainted?
28
+ tmpdir = '/tmp'
29
+ end
30
+
31
+ lock = nil
32
+ n = failure = 0
33
+
34
+ begin
35
+ Thread.critical = true
36
+
37
+ begin
38
+ tmpname = sprintf('%s/%s%d.%d', tmpdir, basename, $$, n)
39
+ lock = tmpname + '.lock'
40
+ n += 1
41
+ end while @@cleanlist.include?(tmpname) or
42
+ File.exist?(lock) or File.exist?(tmpname)
43
+
44
+ Dir.mkdir(lock)
45
+ rescue
46
+ failure += 1
47
+ retry if failure < MAX_TRY
48
+ raise "cannot generate tempfile `%s'" % tmpname
49
+ ensure
50
+ Thread.critical = false
51
+ end
52
+
53
+ @data = [tmpname]
54
+ @clean_proc = Tempfile.callback(@data)
55
+ ObjectSpace.define_finalizer(self, @clean_proc)
56
+
57
+ @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600)
58
+ @tmpname = tmpname
59
+ @@cleanlist << @tmpname
60
+ @data[1] = @tmpfile
61
+ @data[2] = @@cleanlist
62
+
63
+ super(@tmpfile)
64
+
65
+ # Now we have all the File/IO methods defined, you must not
66
+ # carelessly put bare puts(), etc. after this.
67
+
68
+ Dir.rmdir(lock)
69
+ end
70
+
71
+ # Opens or reopens the file with mode "r+".
72
+ def open
73
+ @tmpfile.close if @tmpfile
74
+ @tmpfile = File.open(@tmpname, 'r+')
75
+ @data[1] = @tmpfile
76
+ __setobj__(@tmpfile)
77
+ end
78
+
79
+ def _close # :nodoc:
80
+ @tmpfile.close if @tmpfile
81
+ @data[1] = @tmpfile = nil
82
+ end
83
+ protected :_close
84
+
85
+ # Closes the file. If the optional flag is true, unlinks the file
86
+ # after closing.
87
+ #
88
+ # If you don't explicitly unlink the temporary file, the removal
89
+ # will be delayed until the object is finalized.
90
+ def close(unlink_now=false)
91
+ if unlink_now
92
+ close!
93
+ else
94
+ _close
95
+ end
96
+ end
97
+
98
+ # Closes and unlinks the file.
99
+ def close!
100
+ _close
101
+ @clean_proc.call
102
+ ObjectSpace.undefine_finalizer(self)
103
+ end
104
+
105
+ # Unlinks the file. On UNIX-like systems, it is often a good idea
106
+ # to unlink a temporary file immediately after creating and opening
107
+ # it, because it leaves other programs zero chance to access the
108
+ # file.
109
+ def unlink
110
+ # keep this order for thread safeness
111
+ File.unlink(@tmpname) if File.exist?(@tmpname)
112
+ @@cleanlist.delete(@tmpname) if @@cleanlist
113
+ end
114
+ alias delete unlink
115
+
116
+ if RUBY_VERSION > '1.8.0'
117
+ def __setobj__(obj)
118
+ @_dc_obj = obj
119
+ end
120
+ else
121
+ def __setobj__(obj)
122
+ @obj = obj
123
+ end
124
+ end
125
+
126
+ # Returns the full path name of the temporary file.
127
+ def path
128
+ @tmpname
129
+ end
130
+
131
+ # Returns the size of the temporary file. As a side effect, the IO
132
+ # buffer is flushed before determining the size.
133
+ def size
134
+ if @tmpfile
135
+ @tmpfile.flush
136
+ @tmpfile.stat.size
137
+ else
138
+ 0
139
+ end
140
+ end
141
+ alias length size
142
+
143
+ class << self
144
+ def callback(data) # :nodoc:
145
+ pid = $$
146
+ lambda{
147
+ if pid == $$
148
+ path, tmpfile, cleanlist = *data
149
+
150
+ print "removing ", path, "..." if $DEBUG
151
+
152
+ tmpfile.close if tmpfile
153
+
154
+ # keep this order for thread safeness
155
+ File.unlink(path) if File.exist?(path)
156
+ cleanlist.delete(path) if cleanlist
157
+
158
+ print "done\n" if $DEBUG
159
+ end
160
+ }
161
+ end
162
+
163
+ # If no block is given, this is a synonym for new().
164
+ #
165
+ # If a block is given, it will be passed tempfile as an argument,
166
+ # and the tempfile will automatically be closed when the block
167
+ # terminates. In this case, open() returns nil.
168
+ def open(*args)
169
+ tempfile = new(*args)
170
+
171
+ if block_given?
172
+ begin
173
+ yield(tempfile)
174
+ ensure
175
+ tempfile.close
176
+ end
177
+
178
+ nil
179
+ else
180
+ tempfile
181
+ end
182
+ end
183
+ end
184
+ end
185
+
186
+ end # module BugFix
187
+ if __FILE__ == $0
188
+ # $DEBUG = true
189
+ f = Tempfile.new("foo")
190
+ f.print("foo\n")
191
+ f.close
192
+ f.open
193
+ p f.gets # => "foo\n"
194
+ f.close!
195
+ end