rUtilAnts 0.3.0.20110825 → 1.0.0.20120223
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +7 -1
- data/ChangeLog +16 -0
- data/LICENSE +1 -1
- data/README +2 -5
- data/ReleaseInfo +8 -8
- data/lib/rUtilAnts/Archive.rb +26 -26
- data/lib/rUtilAnts/ForeignProcess.rb +20 -21
- data/lib/rUtilAnts/GUI.rb +38 -38
- data/lib/rUtilAnts/GUI/BugReportDialog.rb +5 -5
- data/lib/rUtilAnts/Logging.rb +124 -254
- data/lib/rUtilAnts/Misc.rb +70 -37
- data/lib/rUtilAnts/MySQLPool.rb +31 -31
- data/lib/rUtilAnts/Platform.rb +33 -16
- data/lib/rUtilAnts/Platforms/i386-cygwin/PlatformInfo.rb +46 -15
- data/lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb +46 -15
- data/lib/rUtilAnts/Platforms/i386-mingw32/PlatformInfo.rb +58 -17
- data/lib/rUtilAnts/Platforms/i386-mswin32/PlatformInfo.rb +58 -17
- data/lib/rUtilAnts/Platforms/x86_64-linux/PlatformInfo.rb +46 -15
- data/lib/rUtilAnts/Plugins.rb +54 -139
- data/lib/rUtilAnts/SingletonProxy.rb +33 -0
- data/lib/rUtilAnts/URLAccess.rb +44 -66
- data/lib/rUtilAnts/URLCache.rb +39 -56
- data/lib/rUtilAnts/URLHandlers/DataImage.rb +20 -20
- data/lib/rUtilAnts/URLHandlers/FTP.rb +24 -24
- data/lib/rUtilAnts/URLHandlers/HTTP.rb +21 -21
- data/lib/rUtilAnts/URLHandlers/LocalFile.rb +19 -19
- metadata +10 -10
data/AUTHORS
CHANGED
data/ChangeLog
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
= rUtilAnts Release History
|
2
2
|
|
3
|
+
== 1.0.0.20120223 (Beta)
|
4
|
+
|
5
|
+
* Renamed public methods to match standard Ruby's conventions
|
6
|
+
* Removed rdoc warning in documentation
|
7
|
+
* Adapted to last version of RDI
|
8
|
+
* Adapted to new RDoc conventions
|
9
|
+
* Updated Copyright information
|
10
|
+
* Updated email address of Muriel Salvan
|
11
|
+
* Removed global variables used as singletons, and replaced them with class variables on a generic mechanism
|
12
|
+
* Logging: Added :no_dialog option to avoid dialogs when log_err, log_msg or log_bug are used
|
13
|
+
* Logging: Changed the way initialization work, with optional arguments the Ruby way
|
14
|
+
* Misc: Added replace_vars method to substitute variables of form %{...} in a string
|
15
|
+
* Platform: Added support for shortcuts (create, get file name and follow)
|
16
|
+
* Platform: Windows platforms use PATHEXT environment variable to get default executable extensions
|
17
|
+
* Bug correction: URLHandlers did not work due to wrong namespace
|
18
|
+
|
3
19
|
== 0.3.0.20110825 (Beta)
|
4
20
|
|
5
21
|
* Added MySQLPool library: pool MySQL connections and prepared statements for reuse.
|
data/LICENSE
CHANGED
@@ -6,7 +6,7 @@ This list is found in the file named AUTHORS.
|
|
6
6
|
The AUTHORS and LICENSE files have to be included in any release of software
|
7
7
|
embedding source code of this package, or using it as a derivative software.
|
8
8
|
|
9
|
-
Copyright (c) 2009 -
|
9
|
+
Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
10
10
|
|
11
11
|
Redistribution and use in source and binary forms, with or without
|
12
12
|
modification, are permitted provided that the following conditions are met:
|
data/README
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
-- This file is best viewed when processed by rdoc.
|
2
|
-
++
|
3
|
-
|
4
1
|
= rUtilAnts
|
5
2
|
|
6
3
|
Library that ships several mini-libraries for everyday development activity.
|
@@ -11,8 +8,8 @@ Check the website at http://rutilants.sourceforge.net
|
|
11
8
|
|
12
9
|
== Who wrote it ?
|
13
10
|
|
14
|
-
Check the AUTHORS[link:
|
11
|
+
Check the AUTHORS[link:AUTHORS.html] file.
|
15
12
|
|
16
13
|
== What is the license ?
|
17
14
|
|
18
|
-
You can find out in the LICENSE[link:
|
15
|
+
You can find out in the LICENSE[link:LICENSE.html] file.
|
data/ReleaseInfo
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
2
|
-
# This file has been generated by RubyPackager during a delivery.
|
3
|
-
# More info about RubyPackager: http://rubypackager.sourceforge.net
|
4
|
-
{
|
5
|
-
:Version => '0.
|
6
|
-
:Tags => [ 'Beta' ],
|
7
|
-
:DevStatus => 'Beta'
|
8
|
-
}
|
1
|
+
|
2
|
+
# This file has been generated by RubyPackager during a delivery.
|
3
|
+
# More info about RubyPackager: http://rubypackager.sourceforge.net
|
4
|
+
{
|
5
|
+
:Version => '1.0.0.20120223',
|
6
|
+
:Tags => [ 'Beta' ],
|
7
|
+
:DevStatus => 'Beta'
|
8
|
+
}
|
data/lib/rUtilAnts/Archive.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009 -
|
2
|
+
# Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -19,7 +19,7 @@ module RUtilAnts
|
|
19
19
|
|
20
20
|
# Constructor
|
21
21
|
#
|
22
|
-
# Parameters
|
22
|
+
# Parameters::
|
23
23
|
# * *iPassword* (_String_): Password encrypting data
|
24
24
|
# * *iSalt* (_String_): Salt encoding data
|
25
25
|
# * *oFile* (_IO_): The IO that will receive encrypted data
|
@@ -30,7 +30,7 @@ module RUtilAnts
|
|
30
30
|
|
31
31
|
# Add a string to write
|
32
32
|
#
|
33
|
-
# Parameters
|
33
|
+
# Parameters::
|
34
34
|
# * *iData* (_String_): The data to encrypt and write
|
35
35
|
def <<(iData)
|
36
36
|
# Add to the buffer
|
@@ -72,7 +72,7 @@ module RUtilAnts
|
|
72
72
|
|
73
73
|
# Constructor
|
74
74
|
#
|
75
|
-
# Parameters
|
75
|
+
# Parameters::
|
76
76
|
# * *iPassword* (_String_): Password encrypting data
|
77
77
|
# * *iSalt* (_String_): Salt encoding data
|
78
78
|
# * *iFile* (_IO_): The IO that will send encrypted data
|
@@ -82,7 +82,7 @@ module RUtilAnts
|
|
82
82
|
|
83
83
|
# Get the next string encrypted
|
84
84
|
#
|
85
|
-
# Return
|
85
|
+
# Return::
|
86
86
|
# * _String_: The next string encrypted (or nil if none)
|
87
87
|
def get
|
88
88
|
rObject = nil
|
@@ -111,7 +111,7 @@ module RUtilAnts
|
|
111
111
|
|
112
112
|
# Constructor
|
113
113
|
#
|
114
|
-
# Parameters
|
114
|
+
# Parameters::
|
115
115
|
# * *iPassword* (_String_): Password encrypting data
|
116
116
|
# * *iSalt* (_String_): Salt encoding data
|
117
117
|
# * *oFile* (_IO_): The IO that will receive encrypted data
|
@@ -121,7 +121,7 @@ module RUtilAnts
|
|
121
121
|
|
122
122
|
# Add an object to write
|
123
123
|
#
|
124
|
-
# Parameters
|
124
|
+
# Parameters::
|
125
125
|
# * *iObject* (_Object_): The object to write
|
126
126
|
def <<(iObject)
|
127
127
|
lStrType = nil
|
@@ -152,7 +152,7 @@ module RUtilAnts
|
|
152
152
|
|
153
153
|
# Constructor
|
154
154
|
#
|
155
|
-
# Parameters
|
155
|
+
# Parameters::
|
156
156
|
# * *iPassword* (_String_): Password encrypting data
|
157
157
|
# * *iSalt* (_String_): Salt encoding data
|
158
158
|
# * *iFile* (_IO_): The IO that will send encrypted data
|
@@ -163,7 +163,7 @@ module RUtilAnts
|
|
163
163
|
|
164
164
|
# Get the next object encrypted
|
165
165
|
#
|
166
|
-
# Return
|
166
|
+
# Return::
|
167
167
|
# * _Object_: The next object encrypted (or nil if none)
|
168
168
|
def get
|
169
169
|
rObject = nil
|
@@ -201,7 +201,7 @@ module RUtilAnts
|
|
201
201
|
|
202
202
|
# Constructor
|
203
203
|
#
|
204
|
-
# Parameters
|
204
|
+
# Parameters::
|
205
205
|
# * *iPassword* (_String_): Password encrypting data
|
206
206
|
# * *iSalt* (_String_): Salt encoding data
|
207
207
|
# * *oFile* (_IO_): The IO that will receive encrypted data
|
@@ -220,9 +220,9 @@ module RUtilAnts
|
|
220
220
|
|
221
221
|
# Add a single file to write
|
222
222
|
#
|
223
|
-
# Parameters
|
223
|
+
# Parameters::
|
224
224
|
# * *iFileName* (_String_): File to add
|
225
|
-
def
|
225
|
+
def add_file(iFileName)
|
226
226
|
lFileSize = File.size(iFileName)
|
227
227
|
@LstFiles << [ iFileName, lFileSize ]
|
228
228
|
@TotalSize += lFileSize
|
@@ -230,9 +230,9 @@ module RUtilAnts
|
|
230
230
|
|
231
231
|
# Add a directory with all its recursive content
|
232
232
|
#
|
233
|
-
# Parameters
|
233
|
+
# Parameters::
|
234
234
|
# * *iDirName* (_String_): Name of the directory
|
235
|
-
def
|
235
|
+
def add_dir(iDirName)
|
236
236
|
lEmpty = true
|
237
237
|
lRealDir = iDirName
|
238
238
|
if (iDirName == '')
|
@@ -247,9 +247,9 @@ module RUtilAnts
|
|
247
247
|
lCompleteFileName = iFileName
|
248
248
|
end
|
249
249
|
if (File.directory?(lCompleteFileName))
|
250
|
-
|
250
|
+
add_dir(lCompleteFileName)
|
251
251
|
else
|
252
|
-
|
252
|
+
add_file(lCompleteFileName)
|
253
253
|
end
|
254
254
|
end
|
255
255
|
end
|
@@ -260,26 +260,26 @@ module RUtilAnts
|
|
260
260
|
|
261
261
|
# Add a files filter
|
262
262
|
#
|
263
|
-
# Parameters
|
263
|
+
# Parameters::
|
264
264
|
# * *iFilesFilter* (_String_): The files filter, to be used with glob
|
265
|
-
def
|
265
|
+
def add_files(iFilesFilter)
|
266
266
|
Dir.glob(iFilesFilter).each do |iFileName|
|
267
267
|
if (!File.directory?(iFileName))
|
268
|
-
|
268
|
+
add_file(iFileName)
|
269
269
|
end
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
273
273
|
# Dump files to write on screen
|
274
274
|
def dump
|
275
|
-
|
275
|
+
log_msg "#{@EmptyDirs.size} empty directories:"
|
276
276
|
@EmptyDirs.each_with_index do |iDirName, iIdxDir|
|
277
|
-
|
277
|
+
log_msg "* [#{iIdxDir}]: #{iDirName}"
|
278
278
|
end
|
279
|
-
|
279
|
+
log_msg "#{@LstFiles.size} files (#{@TotalSize} bytes):"
|
280
280
|
@LstFiles.each_with_index do |iFileInfo, iIdxFile|
|
281
281
|
iFileName, iFileSize = iFileInfo
|
282
|
-
|
282
|
+
log_msg "* [#{iIdxFile}]: #{iFileName} (#{iFileSize} bytes)"
|
283
283
|
end
|
284
284
|
end
|
285
285
|
|
@@ -295,7 +295,7 @@ module RUtilAnts
|
|
295
295
|
if (iFileSize % FILE_BUFFER_SIZE != 0)
|
296
296
|
lNbrChunks += 1
|
297
297
|
end
|
298
|
-
|
298
|
+
log_debug "Writing file #{iFileName} (#{iFileSize} bytes, #{lNbrChunks} chunks) ..."
|
299
299
|
@ObjectWriter << [ iFileName, lNbrChunks ]
|
300
300
|
File.open(iFileName, 'rb') do |iFile|
|
301
301
|
lNbrChunks.times do |iIdxChunk|
|
@@ -316,7 +316,7 @@ module RUtilAnts
|
|
316
316
|
|
317
317
|
# Constructor
|
318
318
|
#
|
319
|
-
# Parameters
|
319
|
+
# Parameters::
|
320
320
|
# * *iPassword* (_String_): Password encrypting data
|
321
321
|
# * *iSalt* (_String_): Salt encoding data
|
322
322
|
# * *iFile* (_IO_): The IO that will send encrypted data
|
@@ -336,7 +336,7 @@ module RUtilAnts
|
|
336
336
|
lDecodedSize = 0
|
337
337
|
lNbrFiles.times do |iIdxFile|
|
338
338
|
lFileName, lNbrChunks = @ObjectReader.get
|
339
|
-
|
339
|
+
log_debug "Reading file #{lFileName} (#{lNbrChunks} chunks) ..."
|
340
340
|
FileUtils::mkdir_p(File.dirname(lFileName))
|
341
341
|
File.open(lFileName, 'wb') do |oFile|
|
342
342
|
lNbrChunks.times do |iIdxChunk|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010 -
|
2
|
+
# Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -57,27 +57,27 @@ module RUtilAnts
|
|
57
57
|
|
58
58
|
# Execute a command in another Ruby session, executing some Shell commands before invocation.
|
59
59
|
#
|
60
|
-
# Parameters
|
60
|
+
# Parameters::
|
61
61
|
# * *iShellCmd* (_String_): Shell command to invoke before Ruby
|
62
62
|
# * *iObject* (_Object_): Object that will have a function to call in the new session
|
63
63
|
# * *iMethod* (_Symbol_): Method to call on the object
|
64
64
|
# * *Parameters* (<em>list<Object></em>): Remaining parameters
|
65
|
-
# Return
|
65
|
+
# Return::
|
66
66
|
# * _Exception_: An error, or nil if success
|
67
67
|
# * _Object_: The result of the function call (valid only if no error returned)
|
68
|
-
def self.
|
68
|
+
def self.exec_cmd_other_session(iShellCmd, iObject, iMethod, iParameters)
|
69
69
|
rError = nil
|
70
70
|
rResult = nil
|
71
71
|
|
72
72
|
# Protect it from exceptions, to ensure that a valid error message will be returned
|
73
73
|
begin
|
74
|
-
|
74
|
+
log_debug "Execute method #{iMethod}(#{iParameters.join(', ')}) in a new process with shell command: #{iShellCmd} ..."
|
75
75
|
|
76
76
|
# Create an object that we will serialize, containing all needed information for the session
|
77
77
|
lInfo = MethodCallInfo.new
|
78
|
-
lInfo.LogFile =
|
79
|
-
lInfo.LibRootDir =
|
80
|
-
lInfo.BugTrackerURL =
|
78
|
+
lInfo.LogFile = get_log_file
|
79
|
+
lInfo.LibRootDir = get_lib_root_dir
|
80
|
+
lInfo.BugTrackerURL = get_bug_tracker_url
|
81
81
|
lInfo.RequireFiles = []
|
82
82
|
# Do not store ForeignProcess require
|
83
83
|
$".each do |iRequireName|
|
@@ -90,7 +90,7 @@ module RUtilAnts
|
|
90
90
|
lMethodDetails.Parameters = iParameters
|
91
91
|
lMethodDetails.Method = iMethod
|
92
92
|
lMethodDetails.Object = iObject
|
93
|
-
|
93
|
+
log_debug "Method to be marshalled: #{lMethodDetails.inspect}"
|
94
94
|
lInfo.SerializedMethodDetails = Marshal.dump(lMethodDetails)
|
95
95
|
lCurrentThread = Thread.current
|
96
96
|
# Dump this object in a temporary file
|
@@ -109,7 +109,7 @@ module RUtilAnts
|
|
109
109
|
\# This is a generated file that should not stay persistent. You can delete it.
|
110
110
|
\# It has been generated by rUtilAnts::ForeignProcess module. Check http://rutilants.sourceforge.net for further details.
|
111
111
|
require '#{File.expand_path(__FILE__)}'
|
112
|
-
RUtilAnts::ForeignProcess::
|
112
|
+
RUtilAnts::ForeignProcess::execute_embedded_function(ARGV[0], ARGV[1])
|
113
113
|
"
|
114
114
|
end
|
115
115
|
# For security reasons, ensure that only us can read and execute this file.
|
@@ -140,19 +140,19 @@ RUtilAnts::ForeignProcess::executeEmbeddedFunction(ARGV[0], ARGV[1])
|
|
140
140
|
rError = $!
|
141
141
|
end
|
142
142
|
|
143
|
-
|
143
|
+
log_debug "Method executed with error #{rError} and result #{rResult}."
|
144
144
|
|
145
145
|
return rError, rResult
|
146
146
|
end
|
147
147
|
|
148
148
|
# Execute a function along with its parameters stored in a file.
|
149
|
-
# This method is used by the file generated by
|
149
|
+
# This method is used by the file generated by exec_cmd_other_session.
|
150
150
|
# It should not be called directly.
|
151
151
|
#
|
152
|
-
# Parameters
|
152
|
+
# Parameters::
|
153
153
|
# * *iInfoFileName* (_String_): The file containing info
|
154
154
|
# * *iResultFileName* (_String_): The file used to store the result serialized
|
155
|
-
def self.
|
155
|
+
def self.execute_embedded_function(iInfoFileName, iResultFileName)
|
156
156
|
begin
|
157
157
|
# Read the file
|
158
158
|
lInfo = nil
|
@@ -170,15 +170,14 @@ RUtilAnts::ForeignProcess::executeEmbeddedFunction(ARGV[0], ARGV[1])
|
|
170
170
|
require iRequireName
|
171
171
|
end
|
172
172
|
# Initialize logging
|
173
|
-
RUtilAnts::Logging::
|
174
|
-
|
175
|
-
logDebug "New process spawned with requires: #{lInfo.RequireFiles.join(', ')}."
|
173
|
+
RUtilAnts::Logging::install_logger_on_object(:lib_root_dir => lInfo.LibRootDir, :bug_tracker_url => lInfo.BugTrackerURL, :log_file => lInfo.LogFile)
|
174
|
+
log_debug "New process spawned with requires: #{lInfo.RequireFiles.join(', ')}."
|
176
175
|
# Unserialize the method details
|
177
176
|
lMethodDetails = Marshal.load(lInfo.SerializedMethodDetails)
|
178
177
|
# Call the method on the object with all its parameters
|
179
|
-
|
178
|
+
log_debug "Calling method #{lMethodDetails.Method}(#{lMethodDetails.Parameters.join(', ')}) ..."
|
180
179
|
lResult = lMethodDetails.Object.send(lMethodDetails.Method, *lMethodDetails.Parameters)
|
181
|
-
|
180
|
+
log_debug "Method returned #{lResult}."
|
182
181
|
rescue Exception
|
183
182
|
lResult = RuntimeError.new("Error occurred while executing foreign call: #{$!}. Backtrace: #{$!.backtrace.join("\n")}")
|
184
183
|
end
|
@@ -191,12 +190,12 @@ RUtilAnts::ForeignProcess::executeEmbeddedFunction(ARGV[0], ARGV[1])
|
|
191
190
|
require 'fileutils'
|
192
191
|
FileUtils.chmod(0700, iResultFileName)
|
193
192
|
rescue Exception
|
194
|
-
|
193
|
+
log_err "Error while writing result in to #{iResultFileName}: #{$!}."
|
195
194
|
end
|
196
195
|
end
|
197
196
|
|
198
197
|
# Initialize the ForeignProcess methods in the Object namespace
|
199
|
-
def self.
|
198
|
+
def self.install_foreign_process_on_object
|
200
199
|
Object.module_eval('include RUtilAnts::ForeignProcess')
|
201
200
|
end
|
202
201
|
|
data/lib/rUtilAnts/GUI.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009 -
|
2
|
+
# Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -14,7 +14,7 @@ module RUtilAnts
|
|
14
14
|
|
15
15
|
# Constructor
|
16
16
|
#
|
17
|
-
# Parameters
|
17
|
+
# Parameters::
|
18
18
|
# * *ioImageList* (<em>Wx::ImageList</em>): The image list this manager will handle
|
19
19
|
# * *iWidth* (_Integer_): The images width
|
20
20
|
# * *iHeight* (_Integer_): The images height
|
@@ -30,7 +30,7 @@ module RUtilAnts
|
|
30
30
|
|
31
31
|
# Get the image index for a given image ID
|
32
32
|
#
|
33
|
-
# Parameters
|
33
|
+
# Parameters::
|
34
34
|
# * *iID* (_Object_): Id of the image
|
35
35
|
# * *CodeBlock*: The code that will be called if the image ID is unknown. This code has to return a Wx::Bitmap object, representing the bitmap for the given image ID.
|
36
36
|
def getImageIndex(iID)
|
@@ -65,15 +65,15 @@ module RUtilAnts
|
|
65
65
|
|
66
66
|
# Constructor
|
67
67
|
#
|
68
|
-
# Parameters
|
68
|
+
# Parameters::
|
69
69
|
# * *iParentWindow* (<em>Wx::Window</em>): Parent window
|
70
70
|
# * *iCodeToExecute* (_Proc_): The code to execute that will update the progression
|
71
71
|
# * *iParameters* (<em>map<Symbol,Object></em>): Additional parameters:
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
72
|
+
# * *:cancellable* (_Boolean_): Can we cancel this dialog ? [optional = false]
|
73
|
+
# * *:title* (_String_): Caption of the progress dialog [optional = '']
|
74
|
+
# * *:icon* (<em>Wx::Bitmap</em>): Icon of the progress dialog [optional = nil]
|
75
75
|
def initialize(iParentWindow, iCodeToExecute, iParameters = {})
|
76
|
-
lCancellable = iParameters[:
|
76
|
+
lCancellable = iParameters[:cancellable]
|
77
77
|
if (lCancellable == nil)
|
78
78
|
lCancellable = false
|
79
79
|
end
|
@@ -158,9 +158,9 @@ module RUtilAnts
|
|
158
158
|
|
159
159
|
# Set the progress range
|
160
160
|
#
|
161
|
-
# Parameters
|
161
|
+
# Parameters::
|
162
162
|
# * *iRange* (_Integer_): The progress range
|
163
|
-
def
|
163
|
+
def set_range(iRange)
|
164
164
|
@GProgress.range = iRange
|
165
165
|
if (!@Determined)
|
166
166
|
@Determined = true
|
@@ -171,7 +171,7 @@ module RUtilAnts
|
|
171
171
|
|
172
172
|
# Set the progress value
|
173
173
|
#
|
174
|
-
# Parameters
|
174
|
+
# Parameters::
|
175
175
|
# * *iValue* (_Integer_): The progress value
|
176
176
|
def setValue(iValue)
|
177
177
|
@GProgress.value = iValue
|
@@ -180,16 +180,16 @@ module RUtilAnts
|
|
180
180
|
|
181
181
|
# Increment the progress value
|
182
182
|
#
|
183
|
-
# Parameters
|
183
|
+
# Parameters::
|
184
184
|
# * *iIncrement* (_Integer_): Value to increment [optional = 1]
|
185
|
-
def
|
185
|
+
def inc_value(iIncrement = 1)
|
186
186
|
@GProgress.value += iIncrement
|
187
187
|
refreshState
|
188
188
|
end
|
189
189
|
|
190
190
|
# Increment the progress range
|
191
191
|
#
|
192
|
-
# Parameters
|
192
|
+
# Parameters::
|
193
193
|
# * *iIncrement* (_Integer_): Value to increment [optional = 1]
|
194
194
|
def incRange(iIncrement = 1)
|
195
195
|
if (@Determined)
|
@@ -219,7 +219,7 @@ module RUtilAnts
|
|
219
219
|
|
220
220
|
# Constructor
|
221
221
|
#
|
222
|
-
# Parameters
|
222
|
+
# Parameters::
|
223
223
|
# * *iParentWindow* (<em>Wx::Window</em>): Parent window
|
224
224
|
# * *iCodeToExecute* (_Proc_): The code to execute that will update the progression
|
225
225
|
# * *iText* (_String_): The text to display
|
@@ -231,7 +231,7 @@ module RUtilAnts
|
|
231
231
|
|
232
232
|
# Get the panel to display as title
|
233
233
|
#
|
234
|
-
# Return
|
234
|
+
# Return::
|
235
235
|
# * <em>Wx::Panel</em>: The panel to use as a title
|
236
236
|
def getTitlePanel
|
237
237
|
rPanel = Wx::Panel.new(self)
|
@@ -249,7 +249,7 @@ module RUtilAnts
|
|
249
249
|
|
250
250
|
# Set the text
|
251
251
|
#
|
252
|
-
# Parameters
|
252
|
+
# Parameters::
|
253
253
|
# * *iText* (_String_): The text
|
254
254
|
def setText(iText)
|
255
255
|
@STText.label = iText
|
@@ -264,7 +264,7 @@ module RUtilAnts
|
|
264
264
|
|
265
265
|
# Constructor
|
266
266
|
#
|
267
|
-
# Parameters
|
267
|
+
# Parameters::
|
268
268
|
# * *iParentWindow* (<em>Wx::Window</em>): Parent window
|
269
269
|
# * *iCodeToExecute* (_Proc_): The code to execute that will update the progression
|
270
270
|
# * *iBitmap* (<em>Wx::Bitmap</em>): The bitmap to display (can be nil)
|
@@ -276,7 +276,7 @@ module RUtilAnts
|
|
276
276
|
|
277
277
|
# Get the panel to display as title
|
278
278
|
#
|
279
|
-
# Return
|
279
|
+
# Return::
|
280
280
|
# * <em>Wx::Panel</em>: The panel to use as a title
|
281
281
|
def getTitlePanel
|
282
282
|
rPanel = Wx::Panel.new(self)
|
@@ -298,7 +298,7 @@ module RUtilAnts
|
|
298
298
|
|
299
299
|
# Set the bitmap
|
300
300
|
#
|
301
|
-
# Parameters
|
301
|
+
# Parameters::
|
302
302
|
# * *iBitmap* (<em>Wx::Bitmap</em>): The bitmap
|
303
303
|
def setBitmap(iBitmap)
|
304
304
|
@SBBitmap.bitmap = iBitmap
|
@@ -322,7 +322,7 @@ module RUtilAnts
|
|
322
322
|
|
323
323
|
# Register a given timer
|
324
324
|
#
|
325
|
-
# Parameters
|
325
|
+
# Parameters::
|
326
326
|
# * *iTimer* (<em>Wx::Timer</em>): The timer to register
|
327
327
|
def registerTimer(iTimer)
|
328
328
|
@Timers << iTimer
|
@@ -330,9 +330,9 @@ module RUtilAnts
|
|
330
330
|
|
331
331
|
# Unregister a given timer
|
332
332
|
#
|
333
|
-
# Parameters
|
333
|
+
# Parameters::
|
334
334
|
# * *iTimer* (<em>Wx::Timer</em>): The timer to unregister
|
335
|
-
# Return
|
335
|
+
# Return::
|
336
336
|
# * _Boolean_: Was the Timer registered ?
|
337
337
|
def unregisterTimer(iTimer)
|
338
338
|
rFound = false
|
@@ -384,11 +384,11 @@ module RUtilAnts
|
|
384
384
|
|
385
385
|
# Get a bitmap resized to a given size if it differs from it
|
386
386
|
#
|
387
|
-
# Parameters
|
387
|
+
# Parameters::
|
388
388
|
# * *iBitmap* (<em>Wx::Bitmap</em>): The original bitmap
|
389
389
|
# * *iWidth* (_Integer_): The width of the resized bitmap
|
390
390
|
# * *iHeight* (_Integer_): The height of the resized bitmap
|
391
|
-
# Return
|
391
|
+
# Return::
|
392
392
|
# * <em>Wx::Bitmap</em>: The resized bitmap (can be the same object as iBitmap)
|
393
393
|
def getResizedBitmap(iBitmap, iWidth, iHeight)
|
394
394
|
rResizedBitmap = iBitmap
|
@@ -403,13 +403,13 @@ module RUtilAnts
|
|
403
403
|
|
404
404
|
# Display a dialog in modal mode, ensuring it is destroyed afterwards.
|
405
405
|
#
|
406
|
-
# Parameters
|
406
|
+
# Parameters::
|
407
407
|
# * *iDialogClass* (_class_): Class of the dialog to display
|
408
408
|
# * *iParentWindow* (<em>Wx::Window</em>): Parent window (can be nil)
|
409
409
|
# * *iParameters* (...): List of parameters to give the constructor
|
410
410
|
# * *CodeBlock*: The code called once the dialog has been displayed and modally closed
|
411
|
-
#
|
412
|
-
#
|
411
|
+
# * *iModalResult* (_Integer_): Modal result
|
412
|
+
# * *iDialog* (<em>Wx::Dialog</em>): The dialog
|
413
413
|
def showModal(iDialogClass, iParentWindow, *iParameters)
|
414
414
|
# If the parent is nil, we fall into a buggy behaviour in the case of GC enabled:
|
415
415
|
# * If we destroy the window after show_modal, random core dumps occur in the application
|
@@ -436,18 +436,18 @@ module RUtilAnts
|
|
436
436
|
# If no type has been provided, it detects the type of icon based on the file extension.
|
437
437
|
# Use URL caching.
|
438
438
|
#
|
439
|
-
# Parameters
|
439
|
+
# Parameters::
|
440
440
|
# * *iFileName* (_String_): The file name
|
441
441
|
# * *iIconIndex* (_Integer_): Specify the icon index (used by Windows for EXE/DLL/ICO...) [optional = nil]
|
442
442
|
# * *iBitmapTypes* (_Integer_ or <em>list<Integer></em>): Bitmap/Icon type. Can be nil for autodetection. Can be the list of types to try. [optional = nil]
|
443
|
-
# Return
|
443
|
+
# Return::
|
444
444
|
# * <em>Wx::Bitmap</em>: The bitmap, or nil in case of failure
|
445
445
|
# * _Exception_: The exception containing details about the error, or nil in case of success
|
446
446
|
def getBitmapFromURL(iFileName, iIconIndex = nil, iBitmapTypes = nil)
|
447
447
|
rReadBitmap = nil
|
448
448
|
rReadError = nil
|
449
449
|
|
450
|
-
rReadBitmap, rReadError =
|
450
|
+
rReadBitmap, rReadError = get_url_content(iFileName, :local_file_access => true) do |iRealFileName|
|
451
451
|
rBitmap = nil
|
452
452
|
rError = nil
|
453
453
|
|
@@ -461,7 +461,7 @@ module RUtilAnts
|
|
461
461
|
when '.CUR', '.ANI', '.EXE', '.DLL'
|
462
462
|
lBitmapTypesToTry = [ Wx::BITMAP_TYPE_ICO ]
|
463
463
|
else
|
464
|
-
|
464
|
+
log_err "Unable to determine the bitmap type corresponding to extension #{File.extname(iRealFileName).upcase}. Assuming ICO."
|
465
465
|
lBitmapTypesToTry = [ Wx::BITMAP_TYPE_ICO ]
|
466
466
|
end
|
467
467
|
end
|
@@ -515,12 +515,12 @@ module RUtilAnts
|
|
515
515
|
|
516
516
|
# Setup a progress bar with some text in it and call code around it
|
517
517
|
#
|
518
|
-
# Parameters
|
518
|
+
# Parameters::
|
519
519
|
# * *iParentWindow* (<em>Wx::Window</em>): The parent window
|
520
520
|
# * *iText* (_String_): The text to display
|
521
521
|
# * *iParameters* (<em>map<Symbol,Object></em>): Additional parameters (check RUtilAnts::GUI::ProgressDialog#initialize documentation):
|
522
522
|
# * _CodeBlock_: The code called with the progress bar created:
|
523
|
-
#
|
523
|
+
# * *ioProgressDlg* (<em>RUtilAnts::GUI::ProgressDialog</em>): The progress dialog
|
524
524
|
def setupTextProgress(iParentWindow, iText, iParameters = {}, &iCodeToExecute)
|
525
525
|
showModal(TextProgressDialog, iParentWindow, iCodeToExecute, iText, iParameters) do |iModalResult, iDialog|
|
526
526
|
# Nothing to do
|
@@ -529,12 +529,12 @@ module RUtilAnts
|
|
529
529
|
|
530
530
|
# Setup a progress bar with some bitmap in it and call code around it
|
531
531
|
#
|
532
|
-
# Parameters
|
532
|
+
# Parameters::
|
533
533
|
# * *iParentWindow* (<em>Wx::Window</em>): The parent window
|
534
534
|
# * *iBitmap* (<em>Wx::Bitmap</em>): The bitmap to display
|
535
535
|
# * *iParameters* (<em>map<Symbol,Object></em>): Additional parameters (check RUtilAnts::GUI::ProgressDialog#initialize documentation):
|
536
536
|
# * _CodeBlock_: The code called with the progress bar created:
|
537
|
-
#
|
537
|
+
# * *ioProgressDlg* (<em>RUtilAnts::GUI::ProgressDialog</em>): The progress dialog
|
538
538
|
def setupBitmapProgress(iParentWindow, iBitmap, iParameters = {}, &iCodeToExecute)
|
539
539
|
showModal(BitmapProgressDialog, iParentWindow, iCodeToExecute, iBitmap, iParameters) do |iModalResult, iDialog|
|
540
540
|
# Nothing to do
|
@@ -543,7 +543,7 @@ module RUtilAnts
|
|
543
543
|
|
544
544
|
# Execute some code after some elapsed time.
|
545
545
|
#
|
546
|
-
# Parameters
|
546
|
+
# Parameters::
|
547
547
|
# * *ioSafeTimersManager* (_SafeTimersManager_): The manager that handles this SafeTimer
|
548
548
|
# * *iElapsedTime* (_Integer_): The elapsed time to wait before running the code
|
549
549
|
# * _CodeBlock_: The code to execute
|
@@ -560,7 +560,7 @@ module RUtilAnts
|
|
560
560
|
|
561
561
|
# Execute some code every some elapsed time.
|
562
562
|
#
|
563
|
-
# Parameters
|
563
|
+
# Parameters::
|
564
564
|
# * *ioSafeTimersManager* (_SafeTimersManager_): The manager that handles this SafeTimer
|
565
565
|
# * *iElapsedTime* (_Integer_): The elapsed time to wait before running the code
|
566
566
|
# * _CodeBlock_: The code to execute
|