rUtilAnts 0.2.2.20101125 → 0.3.0.20110825
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +11 -0
- data/LICENSE +1 -1
- data/ReleaseInfo +8 -8
- data/lib/rUtilAnts/Archive.rb +2 -2
- data/lib/rUtilAnts/ForeignProcess.rb +1 -1
- data/lib/rUtilAnts/GUI.rb +1 -1
- data/lib/rUtilAnts/GUI/BugReportDialog.rb +1 -1
- data/lib/rUtilAnts/Logging.rb +8 -7
- data/lib/rUtilAnts/Misc.rb +94 -1
- data/lib/rUtilAnts/MySQLPool.rb +237 -0
- data/lib/rUtilAnts/Platform.rb +1 -1
- data/lib/rUtilAnts/Platforms/i386-cygwin/PlatformInfo.rb +1 -1
- data/lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb +1 -1
- data/lib/rUtilAnts/Platforms/i386-mingw32/PlatformInfo.rb +1 -1
- data/lib/rUtilAnts/Platforms/i386-mswin32/PlatformInfo.rb +1 -1
- data/lib/rUtilAnts/Platforms/x86_64-linux/PlatformInfo.rb +1 -1
- data/lib/rUtilAnts/Plugins.rb +1 -1
- data/lib/rUtilAnts/URLAccess.rb +1 -1
- data/lib/rUtilAnts/URLCache.rb +1 -1
- data/lib/rUtilAnts/URLHandlers/DataImage.rb +1 -1
- data/lib/rUtilAnts/URLHandlers/FTP.rb +1 -1
- data/lib/rUtilAnts/URLHandlers/HTTP.rb +2 -1
- data/lib/rUtilAnts/URLHandlers/LocalFile.rb +1 -1
- metadata +11 -10
- data/TODO +0 -10
data/ChangeLog
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
= rUtilAnts Release History
|
2
2
|
|
3
|
+
== 0.3.0.20110825 (Beta)
|
4
|
+
|
5
|
+
* Added MySQLPool library: pool MySQL connections and prepared statements for reuse.
|
6
|
+
* Migrated TODO list to Trackers.
|
7
|
+
* Updated copyright info.
|
8
|
+
* Migration to git.
|
9
|
+
* Misc: Added cachedVar method: this uses an instance variable to cache a code block result.
|
10
|
+
* Misc: Added fileMutex method: this mimicks a mutex on tmpdir, but is not reliable yet. Meant for weak processes.
|
11
|
+
* Bug correction: Logging: Do not log debug logs in log file if logdebug is disabled.
|
12
|
+
* Bug correction: Archive: Dumping empty directories did not work.
|
13
|
+
|
3
14
|
== 0.2.2.20101125 (Beta)
|
4
15
|
|
5
16
|
* Archive: Implemented a new module that provides archiving strings, objects and files with compression and encryption
|
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 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
|
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/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 => '0.3.0.20110825',
|
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 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -274,7 +274,7 @@ module RUtilAnts
|
|
274
274
|
def dump
|
275
275
|
logMsg "#{@EmptyDirs.size} empty directories:"
|
276
276
|
@EmptyDirs.each_with_index do |iDirName, iIdxDir|
|
277
|
-
logMsg "* [#{
|
277
|
+
logMsg "* [#{iIdxDir}]: #{iDirName}"
|
278
278
|
end
|
279
279
|
logMsg "#{@LstFiles.size} files (#{@TotalSize} bytes):"
|
280
280
|
@LstFiles.each_with_index do |iFileInfo, iIdxFile|
|
data/lib/rUtilAnts/GUI.rb
CHANGED
data/lib/rUtilAnts/Logging.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -323,12 +323,13 @@ Details:
|
|
323
323
|
# * *iMsg* (_String_): Message to log
|
324
324
|
def logDebug(iMsg)
|
325
325
|
# Log into stdout
|
326
|
-
if (
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
326
|
+
if (@DebugMode)
|
327
|
+
if (@ScreenOutput)
|
328
|
+
$stdout << "#{iMsg}\n"
|
329
|
+
end
|
330
|
+
if (@LogFile != nil)
|
331
|
+
logFile(iMsg)
|
332
|
+
end
|
332
333
|
end
|
333
334
|
end
|
334
335
|
|
data/lib/rUtilAnts/Misc.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -12,6 +12,28 @@ module RUtilAnts
|
|
12
12
|
Object.module_eval('include RUtilAnts::Misc')
|
13
13
|
end
|
14
14
|
|
15
|
+
# Cache the access to a given code result, based on the caller ID
|
16
|
+
# This can be used to cache variables computation (ex. lVar = cachedVar{ lengthyFctToComputeVar } )
|
17
|
+
#
|
18
|
+
# Parameters:
|
19
|
+
# * *&iCode* (_CodeBlock_): The code called to compute the result
|
20
|
+
# ** Return:
|
21
|
+
# *** _Object_: The computed result
|
22
|
+
# Return:
|
23
|
+
# * _Object_: The result of the code
|
24
|
+
def cachedVar(&iCode)
|
25
|
+
if (defined?(@RUtilAnts_Misc_CachedVars) == nil)
|
26
|
+
@RUtilAnts_Misc_CachedVars = {}
|
27
|
+
end
|
28
|
+
# Compute the hash of this code
|
29
|
+
lHash = caller[0].hash
|
30
|
+
if (@RUtilAnts_Misc_CachedVars[lHash] == nil)
|
31
|
+
@RUtilAnts_Misc_CachedVars[lHash] = iCode.call
|
32
|
+
end
|
33
|
+
|
34
|
+
return @RUtilAnts_Misc_CachedVars[lHash]
|
35
|
+
end
|
36
|
+
|
15
37
|
# Get a valid file name, taking into account platform specifically prohibited characters in file names.
|
16
38
|
#
|
17
39
|
# Parameters:
|
@@ -145,6 +167,77 @@ module RUtilAnts
|
|
145
167
|
Dir.chdir(lOldDir)
|
146
168
|
end
|
147
169
|
|
170
|
+
# Constants used for fileMutex
|
171
|
+
# There was no lock on the mutex
|
172
|
+
FILEMUTEX_NO_LOCK = 0
|
173
|
+
# There was a lock on the mutex, but former process did not exist anymore
|
174
|
+
FILEMUTEX_ZOMBIE_LOCK = 1
|
175
|
+
# The lock is taken by a running process
|
176
|
+
FILEMUTEX_LOCK_TAKEN = 2
|
177
|
+
# The lock file is invalid
|
178
|
+
FILEMUTEX_INVALID_LOCK = 3
|
179
|
+
# Execute a code block protected by a file mutex
|
180
|
+
#
|
181
|
+
# Parameters:
|
182
|
+
# * *iProcessID* (_String_): Process ID to be used to identify the mutex
|
183
|
+
# * *CodeBlock*: The code called if the mutex is taken
|
184
|
+
# Return:
|
185
|
+
# * _Integer_: Error code
|
186
|
+
def fileMutex(iProcessID)
|
187
|
+
rResult = FILEMUTEX_NO_LOCK
|
188
|
+
|
189
|
+
# Prevent concurrent execution
|
190
|
+
require 'tmpdir'
|
191
|
+
lLockFile = "#{Dir.tmpdir}/FileMutex_#{iProcessID}.lock"
|
192
|
+
if (File.exists?(lLockFile))
|
193
|
+
logErr "Another instance of process #{iProcessID} is already running. Delete file #{lLockFile} if it is not."
|
194
|
+
begin
|
195
|
+
lDetails = nil
|
196
|
+
File.open(lLockFile, 'r') do |iFile|
|
197
|
+
lDetails = eval(iFile.read)
|
198
|
+
end
|
199
|
+
logErr "Details of the running instance: #{lDetails.inspect}"
|
200
|
+
# If the process does not exist anymore, remove the lock file
|
201
|
+
# TODO: Adapt this to non Unix systems
|
202
|
+
if (File.exists?("/proc/#{lDetails[:PID]}"))
|
203
|
+
rResult = FILEMUTEX_LOCK_TAKEN
|
204
|
+
else
|
205
|
+
logErr "Process #{lDetails[:PID]} does not exist anymore. Removing lock file."
|
206
|
+
File.unlink(lLockFile)
|
207
|
+
rResult = FILEMUTEX_ZOMBIE_LOCK
|
208
|
+
end
|
209
|
+
rescue Exception
|
210
|
+
logErr "Invalid lock file #{lLockFile}: #{$!}."
|
211
|
+
rResult = FILEMUTEX_INVALID_LOCK
|
212
|
+
end
|
213
|
+
end
|
214
|
+
if ((rResult == FILEMUTEX_NO_LOCK) or
|
215
|
+
(rResult == FILEMUTEX_ZOMBIE_LOCK))
|
216
|
+
# Create the lock for our process
|
217
|
+
File.open(lLockFile, 'w') do |oFile|
|
218
|
+
oFile << "
|
219
|
+
{
|
220
|
+
:ExecutionTime => '#{DateTime.now.strftime('%Y-%m-%d %H:%M:%S')}',
|
221
|
+
:PID => '#{Process.pid}'
|
222
|
+
}
|
223
|
+
"
|
224
|
+
end
|
225
|
+
begin
|
226
|
+
yield
|
227
|
+
File.unlink(lLockFile)
|
228
|
+
rescue Exception
|
229
|
+
begin
|
230
|
+
File.unlink(lLockFile)
|
231
|
+
rescue Exception
|
232
|
+
logErr "Exception while deleting lock file #{lLockFile}: #{$!}"
|
233
|
+
end
|
234
|
+
raise
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
return rResult
|
239
|
+
end
|
240
|
+
|
148
241
|
end
|
149
242
|
|
150
243
|
end
|
@@ -0,0 +1,237 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
|
3
|
+
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
|
+
#++
|
5
|
+
|
6
|
+
module RUtilAnts
|
7
|
+
|
8
|
+
module MySQLPool
|
9
|
+
|
10
|
+
class MissingExistingConnectionError < RuntimeError
|
11
|
+
end
|
12
|
+
|
13
|
+
class MissingConnectionFromPoolError < RuntimeError
|
14
|
+
end
|
15
|
+
|
16
|
+
class MissingPreparedStatementFromPoolError < RuntimeError
|
17
|
+
end
|
18
|
+
|
19
|
+
# Set these methods into the Object namespace
|
20
|
+
def self.initializeMySQLPool
|
21
|
+
Object.module_eval('include RUtilAnts::MySQLPool')
|
22
|
+
end
|
23
|
+
|
24
|
+
# Create a MySQL connection to a MySQL database.
|
25
|
+
# Keep connections in a pool with counters.
|
26
|
+
# Reuse existing connections.
|
27
|
+
# If the given password is nil, we force the reuse of an existing connection.
|
28
|
+
#
|
29
|
+
# Parameters:
|
30
|
+
# * *iHost* (_String_): The host to connect to
|
31
|
+
# * *iDBName* (_String_): The MySQL database name to connect to
|
32
|
+
# * *iUser* (_String_): The user
|
33
|
+
# * *iPassword* (_String_): The password. If nil, this will only try to reuse an existing connection [optional = nil]
|
34
|
+
# Return:
|
35
|
+
# * _Exception_: An error, or nil in case of success
|
36
|
+
# * _MySQL_: The MySQL connection, or nil in case of failure
|
37
|
+
def connectToMySQL(iHost, iDBName, iUser, iPassword = nil)
|
38
|
+
rError = nil
|
39
|
+
rMySQL = nil
|
40
|
+
|
41
|
+
if (defined?($RUtilAnts_MySQLPool_Pool) == nil)
|
42
|
+
# The pool: connection, counters and prepared statements per host/dbname/user
|
43
|
+
# map< [ HostName, DBName, UserName ], [ MySQLConnection, Counter, map< SQLString, [ MySQLPreparedStatement, Counter ] > ] >
|
44
|
+
$RUtilAnts_MySQLPool_Pool = {}
|
45
|
+
end
|
46
|
+
lDBKey = [ iHost, iDBName, iUser ]
|
47
|
+
if ($RUtilAnts_MySQLPool_Pool[lDBKey] == nil)
|
48
|
+
if (iPassword == nil)
|
49
|
+
# This is a problem: we want an existing connection, but none exists.
|
50
|
+
rError = MissingExistingConnectionError.new("An existing connection should already exist for #{lDBKey.inspect}")
|
51
|
+
else
|
52
|
+
# Create the connection
|
53
|
+
require 'mysql'
|
54
|
+
begin
|
55
|
+
lMySQL = Mysql.new(iHost, iUser, iPassword, iDBName)
|
56
|
+
# lMySQL = Mysql.init
|
57
|
+
# lMySQL.options(Mysql::OPT_CONNECT_TIMEOUT, 28800)
|
58
|
+
# lMySQL.options(Mysql::OPT_READ_TIMEOUT, 28800)
|
59
|
+
# lMySQL.options(Mysql::OPT_WRITE_TIMEOUT, 28800)
|
60
|
+
# lMySQL.real_connect(iHost, iUser, iPassword, iDBName)
|
61
|
+
rescue Exception
|
62
|
+
logErr "Error while creating MySQL connection to #{lDBKey.inspect}: #{$!}.\n#{$!.backtrace.join("\n")}"
|
63
|
+
rError = $!
|
64
|
+
lMySQL = nil
|
65
|
+
end
|
66
|
+
if (rError == nil)
|
67
|
+
$RUtilAnts_MySQLPool_Pool[lDBKey] = [ lMySQL, 0, {} ]
|
68
|
+
else
|
69
|
+
$RUtilAnts_MySQLPool_Pool[lDBKey] = nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
if ((rError == nil) and
|
74
|
+
($RUtilAnts_MySQLPool_Pool[lDBKey] != nil))
|
75
|
+
# Increase the count of clients to this connection
|
76
|
+
$RUtilAnts_MySQLPool_Pool[lDBKey][1] += 1
|
77
|
+
rMySQL = $RUtilAnts_MySQLPool_Pool[lDBKey][0]
|
78
|
+
end
|
79
|
+
|
80
|
+
return rError, rMySQL
|
81
|
+
end
|
82
|
+
|
83
|
+
# Close a MySQL connection created with connectToMySQL
|
84
|
+
#
|
85
|
+
# Parameters:
|
86
|
+
# * *iMySQLConnection* (_MySQL_): The MySQL connection to close
|
87
|
+
def closeMySQL(iMySQLConnection)
|
88
|
+
# Find the connection
|
89
|
+
if (defined?($RUtilAnts_MySQLPool_Pool) == nil)
|
90
|
+
$RUtilAnts_MySQLPool_Pool = {}
|
91
|
+
end
|
92
|
+
lDBKey = findMySQLConnectionKey(iMySQLConnection)
|
93
|
+
$RUtilAnts_MySQLPool_Pool[lDBKey][1] -= 1
|
94
|
+
if ($RUtilAnts_MySQLPool_Pool[lDBKey][1] == 0)
|
95
|
+
# Close for real
|
96
|
+
$RUtilAnts_MySQLPool_Pool[lDBKey][0].close
|
97
|
+
$RUtilAnts_MySQLPool_Pool[lDBKey] = nil
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Setup a MySQL connection, and ensure it is closed once the client code ends.
|
102
|
+
#
|
103
|
+
# Parameters:
|
104
|
+
# * *iHost* (_String_): The host to connect to
|
105
|
+
# * *iDBName* (_String_): The MySQL database name to connect to
|
106
|
+
# * *iUser* (_String_): The user
|
107
|
+
# * *iPassword* (_String_): The password. If nil, this will only try to reuse an existing connection [optional = nil]
|
108
|
+
# * *CodeBlock*: The code executed with the MySQL connection
|
109
|
+
# ** *iMySQL* (_MySQL_): The MySQL connection
|
110
|
+
# Return:
|
111
|
+
# * _Exception_: An error, or nil in case of success
|
112
|
+
def setupMySQLConnection(iHost, iDBName, iUser, iPassword = nil)
|
113
|
+
rError = nil
|
114
|
+
|
115
|
+
rError, lMySQL = connectToMySQL(iHost, iDBName, iUser, iPassword)
|
116
|
+
if (rError == nil)
|
117
|
+
begin
|
118
|
+
yield(lMySQL)
|
119
|
+
ensure
|
120
|
+
closeMySQL(lMySQL)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
return rError
|
125
|
+
end
|
126
|
+
|
127
|
+
# Get a prepared statement for a given SQL string of a given MySQL connection.
|
128
|
+
# Use the cache of prepared statements.
|
129
|
+
#
|
130
|
+
# Parameters:
|
131
|
+
# * *iMySQLConnection* (_MySQL_): The MySQL connection
|
132
|
+
# * *iStrSQL* (_String_): The SQL statement to prepare
|
133
|
+
# * *iAdditionalOptions* (<em>map<Symbol,Object></em>): Additional options [optional = {}]
|
134
|
+
# ** *:LeaveOpen* (_Boolean_): Do we NOT close the opened statement once it is not used anymore ? [optional = false]
|
135
|
+
# Return:
|
136
|
+
# * <em>MySQL::Statement</em>: The MySQL statement
|
137
|
+
def getPreparedStatement(iMySQLConnection, iStrSQL, iAdditionalOptions = {})
|
138
|
+
# Parse options
|
139
|
+
lLeaveOpen = iAdditionalOptions[:LeaveOpen] || false
|
140
|
+
# Find the prepared statements set
|
141
|
+
lPreparedStatements = $RUtilAnts_MySQLPool_Pool[findMySQLConnectionKey(iMySQLConnection)][2]
|
142
|
+
if (lPreparedStatements[iStrSQL] == nil)
|
143
|
+
# Create a new one
|
144
|
+
lPreparedStatements[iStrSQL] = [
|
145
|
+
iMySQLConnection.prepare(iStrSQL),
|
146
|
+
0
|
147
|
+
]
|
148
|
+
end
|
149
|
+
if (lLeaveOpen)
|
150
|
+
# We set its counter to -1
|
151
|
+
lPreparedStatements[iStrSQL][1] = -1
|
152
|
+
elsif (lPreparedStatements[iStrSQL][1] != -1)
|
153
|
+
# We increment its usage counter
|
154
|
+
lPreparedStatements[iStrSQL][1] += 1
|
155
|
+
end
|
156
|
+
|
157
|
+
return lPreparedStatements[iStrSQL][0]
|
158
|
+
end
|
159
|
+
|
160
|
+
# Close a previously created prepared statement using getPreparedStatement.
|
161
|
+
#
|
162
|
+
# Parameters:
|
163
|
+
# * *iMySQLConnection* (_MySQL_): The MySQL connection
|
164
|
+
# * *iPreparedStatement* (<em>MySQL::Statement</em>): The MySQL prepared statement
|
165
|
+
def closePreparedStatement(iMySQLConnection, iPreparedStatement)
|
166
|
+
lPreparedStatements = $RUtilAnts_MySQLPool_Pool[findMySQLConnectionKey(iMySQLConnection)][2]
|
167
|
+
lFound = false
|
168
|
+
lPreparedStatements.each do |iStrSQL, ioPreparedStatementInfo|
|
169
|
+
if (ioPreparedStatementInfo[0] == iPreparedStatement)
|
170
|
+
# Found it
|
171
|
+
if (ioPreparedStatementInfo[1] != -1)
|
172
|
+
ioPreparedStatementInfo[1] -= 1
|
173
|
+
if (ioPreparedStatementInfo[1] == 0)
|
174
|
+
# Close it for real
|
175
|
+
ioPreparedStatementInfo[1].close
|
176
|
+
lPreparedStatements[iStrSQL] = nil
|
177
|
+
end
|
178
|
+
end
|
179
|
+
lFound = true
|
180
|
+
end
|
181
|
+
end
|
182
|
+
if (!lFound)
|
183
|
+
raise MissingPreparedStatementFromPoolError.new("Prepared statement #{iPreparedStatement.inspect} can't be found among the pool of MySQL connection #{iMySQLConnection.inspect}")
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# Setup a prepared statement, and ensure it will be closed
|
188
|
+
#
|
189
|
+
# Parameters:
|
190
|
+
# * *iMySQLConnection* (_MySQL_): The MySQL connection
|
191
|
+
# * *iStrSQL* (_String_): The SQL statement to prepare
|
192
|
+
# * *iAdditionalOptions* (<em>map<Symbol,Object></em>): Additional options [optional = {}]
|
193
|
+
# ** *:LeaveOpen* (_Boolean_): Do we NOT close the opened statement once it is not used anymore ? [optional = false]
|
194
|
+
# * *CodeBlock*: The code executed once the statement is prepared
|
195
|
+
# ** *iPreparedStatement* (<em>MySQL::Statement</em>): The prepared statement
|
196
|
+
def setupPreparedStatement(iMySQLConnection, iStrSQL, iAdditionalOptions = {})
|
197
|
+
lStatement = getPreparedStatement(iMySQLConnection, iStrSQL, iAdditionalOptions)
|
198
|
+
begin
|
199
|
+
yield(lStatement)
|
200
|
+
ensure
|
201
|
+
closePreparedStatement(iMySQLConnection, lStatement)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
private
|
206
|
+
|
207
|
+
# Find the MySQL connection key
|
208
|
+
#
|
209
|
+
# Parameters:
|
210
|
+
# * *iMySQLConnection* (_MySQL_): The MySQL connection
|
211
|
+
# Return:
|
212
|
+
# * _String_: Host name, or nil if none
|
213
|
+
# * _String_: DB name
|
214
|
+
# * _String_: User name
|
215
|
+
def findMySQLConnectionKey(iMySQLConnection)
|
216
|
+
rHostName = nil
|
217
|
+
rDBName = nil
|
218
|
+
rUserName = nil
|
219
|
+
|
220
|
+
$RUtilAnts_MySQLPool_Pool.each do |iDBKey, ioConnectionInfo|
|
221
|
+
iMySQL = ioConnectionInfo[0]
|
222
|
+
if (iMySQLConnection == iMySQL)
|
223
|
+
# Found it
|
224
|
+
rHostName, rDBName, rUserName = iDBKey
|
225
|
+
break
|
226
|
+
end
|
227
|
+
end
|
228
|
+
if (rHostName == nil)
|
229
|
+
raise MissingConnectionFromPoolError.new("Unable to find connection #{iMySQLConnection.inspect} among the MySQL connections pool.")
|
230
|
+
end
|
231
|
+
|
232
|
+
return rHostName, rDBName, rUserName
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
data/lib/rUtilAnts/Platform.rb
CHANGED
data/lib/rUtilAnts/Plugins.rb
CHANGED
data/lib/rUtilAnts/URLAccess.rb
CHANGED
data/lib/rUtilAnts/URLCache.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -62,6 +62,7 @@ module RUtilAnts
|
|
62
62
|
# Return:
|
63
63
|
# * _String_: The file name
|
64
64
|
def getCorrespondingFileBaseName
|
65
|
+
# TODO: Handle the case where there is no base name (ie. www.google.com instead of www.google.com/index.html)
|
65
66
|
# Check that extension has no characters following the URL (#, ? and ;)
|
66
67
|
return getValidFileName(File.basename(@URLPath.gsub(/^([^#\?;]*).*$/,'\1')))
|
67
68
|
end
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rUtilAnts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 40221573
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
- 20110825
|
11
|
+
version: 0.3.0.20110825
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Muriel Salvan
|
@@ -15,8 +16,7 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
19
|
+
date: 2011-08-25 00:00:00 Z
|
20
20
|
dependencies: []
|
21
21
|
|
22
22
|
description: rUtilAnts is used by several projects. It includes common standard code.
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/rUtilAnts/GUI.rb
|
39
39
|
- lib/rUtilAnts/Logging.rb
|
40
40
|
- lib/rUtilAnts/Misc.rb
|
41
|
+
- lib/rUtilAnts/MySQLPool.rb
|
41
42
|
- lib/rUtilAnts/Platform.rb
|
42
43
|
- lib/rUtilAnts/Platforms/i386-cygwin/PlatformInfo.rb
|
43
44
|
- lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb
|
@@ -54,8 +55,6 @@ files:
|
|
54
55
|
- LICENSE
|
55
56
|
- README
|
56
57
|
- ReleaseInfo
|
57
|
-
- TODO
|
58
|
-
has_rdoc: true
|
59
58
|
homepage: http://rutilants.sourceforge.net/
|
60
59
|
licenses: []
|
61
60
|
|
@@ -69,6 +68,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
68
|
requirements:
|
70
69
|
- - ">="
|
71
70
|
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
72
|
segments:
|
73
73
|
- 0
|
74
74
|
version: "0"
|
@@ -77,13 +77,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
requirements:
|
78
78
|
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
+
hash: 3
|
80
81
|
segments:
|
81
82
|
- 0
|
82
83
|
version: "0"
|
83
84
|
requirements: []
|
84
85
|
|
85
86
|
rubyforge_project: rutilants
|
86
|
-
rubygems_version: 1.
|
87
|
+
rubygems_version: 1.8.7
|
87
88
|
signing_key:
|
88
89
|
specification_version: 3
|
89
90
|
summary: A collection of various utility libraries.
|