rUtilAnts 0.3.0.20110825 → 1.0.0.20120223
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.
- 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
@@ -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
|
|
@@ -7,12 +7,12 @@ module RUtilAnts
|
|
7
7
|
|
8
8
|
module Platform
|
9
9
|
|
10
|
-
|
10
|
+
module PlatformInfo
|
11
11
|
|
12
12
|
# Return the ID of the OS
|
13
13
|
# Applications may adapt their behavior based on it.
|
14
14
|
#
|
15
|
-
# Return
|
15
|
+
# Return::
|
16
16
|
# * _Integer_: OS ID
|
17
17
|
def os
|
18
18
|
return OS_CYGWIN
|
@@ -20,7 +20,7 @@ module RUtilAnts
|
|
20
20
|
|
21
21
|
# Return the list of directories where we look for executables
|
22
22
|
#
|
23
|
-
# Return
|
23
|
+
# Return::
|
24
24
|
# * <em>list<String></em>: List of directories
|
25
25
|
def getSystemExePath
|
26
26
|
return ENV['PATH'].split(':')
|
@@ -28,7 +28,7 @@ module RUtilAnts
|
|
28
28
|
|
29
29
|
# Set the list of directories where we look for executables
|
30
30
|
#
|
31
|
-
# Parameters
|
31
|
+
# Parameters::
|
32
32
|
# * *iNewDirsList* (<em>list<String></em>): List of directories
|
33
33
|
def setSystemExePath(iNewDirsList)
|
34
34
|
ENV['PATH'] = iNewDirsList.join(':')
|
@@ -37,7 +37,7 @@ module RUtilAnts
|
|
37
37
|
# Return the list of file extensions that might be discretely happened to executable files.
|
38
38
|
# This is the optional extensions that can be happened when invoked from a terminal.
|
39
39
|
#
|
40
|
-
# Return
|
40
|
+
# Return::
|
41
41
|
# * <em>list<String></em>: List of extensions (including .)
|
42
42
|
def getDiscreteExeExtensions
|
43
43
|
return []
|
@@ -45,7 +45,7 @@ module RUtilAnts
|
|
45
45
|
|
46
46
|
# Return the list of directories where we look for libraries
|
47
47
|
#
|
48
|
-
# Return
|
48
|
+
# Return::
|
49
49
|
# * <em>list<String></em>: List of directories
|
50
50
|
def getSystemLibsPath
|
51
51
|
rList = ENV['PATH'].split(':')
|
@@ -59,7 +59,7 @@ module RUtilAnts
|
|
59
59
|
|
60
60
|
# Set the list of directories where we look for libraries
|
61
61
|
#
|
62
|
-
# Parameters
|
62
|
+
# Parameters::
|
63
63
|
# * *iNewDirsList* (<em>list<String></em>): List of directories
|
64
64
|
def setSystemLibsPath(iNewDirsList)
|
65
65
|
ENV['LD_LIBRARY_PATH'] = iNewDirsList.join(':')
|
@@ -67,7 +67,7 @@ module RUtilAnts
|
|
67
67
|
|
68
68
|
# This method sends a message (platform dependent) to the user, without the use of wxruby
|
69
69
|
#
|
70
|
-
# Parameters
|
70
|
+
# Parameters::
|
71
71
|
# * *iMsg* (_String_): The message to display
|
72
72
|
def sendMsg(iMsg)
|
73
73
|
# TODO: Handle case of xmessage not installed
|
@@ -84,10 +84,10 @@ module RUtilAnts
|
|
84
84
|
# Execute a Shell command.
|
85
85
|
# Do not wait for its termination.
|
86
86
|
#
|
87
|
-
# Parameters
|
87
|
+
# Parameters::
|
88
88
|
# * *iCmd* (_String_): The command to execute
|
89
89
|
# * *iInTerminal* (_Boolean_): Do we execute this command in a separate terminal ?
|
90
|
-
# Return
|
90
|
+
# Return::
|
91
91
|
# * _Exception_: Error, or nil if success
|
92
92
|
def execShellCmdNoWait(iCmd, iInTerminal)
|
93
93
|
rException = nil
|
@@ -110,9 +110,9 @@ module RUtilAnts
|
|
110
110
|
|
111
111
|
# Execute a given URL to be launched in a browser
|
112
112
|
#
|
113
|
-
# Parameters
|
113
|
+
# Parameters::
|
114
114
|
# * *iURL* (_String_): The URL to launch
|
115
|
-
# Return
|
115
|
+
# Return::
|
116
116
|
# * _String_: Error message, or nil if success
|
117
117
|
def launchURL(iURL)
|
118
118
|
rError = nil
|
@@ -128,7 +128,7 @@ module RUtilAnts
|
|
128
128
|
|
129
129
|
# Get file extensions specifics to executable files
|
130
130
|
#
|
131
|
-
# Return
|
131
|
+
# Return::
|
132
132
|
# * <em>list<String></em>: List of extensions (including . character). It can be empty.
|
133
133
|
def getExecutableExtensions
|
134
134
|
return []
|
@@ -136,12 +136,43 @@ module RUtilAnts
|
|
136
136
|
|
137
137
|
# Get prohibited characters from file names
|
138
138
|
#
|
139
|
-
# Return
|
139
|
+
# Return::
|
140
140
|
# * _String_: String of prohibited characters in file names
|
141
141
|
def getProhibitedFileNamesCharacters
|
142
142
|
return '/'
|
143
143
|
end
|
144
144
|
|
145
|
+
# Create a shortcut (ln -s on Cygwin/Unix systems, a .lnk file on Windows systems)
|
146
|
+
#
|
147
|
+
# Parameters::
|
148
|
+
# * *iSrc* (_String_): The source file
|
149
|
+
# * *iDst* (_String_): The destination file
|
150
|
+
def createShortcut(iSrc, iDst)
|
151
|
+
require 'fileutils'
|
152
|
+
FileUtils::ln_s(iSrc, iDst)
|
153
|
+
end
|
154
|
+
|
155
|
+
# Get the name of a real file name, pointed by a shortcut.
|
156
|
+
# On Windows systems, it will be the target of the lnk file.
|
157
|
+
#
|
158
|
+
# Parameters::
|
159
|
+
# * *iShortcutName* (_String_): Name of the shortcut (same name used by createShortcut). Don't use OS specific extensions in this name (no .lnk).
|
160
|
+
# Return::
|
161
|
+
# * _String_: The real file name pointed by this shortcut
|
162
|
+
def followShortcut(iShortcutName)
|
163
|
+
return File.readlink(iShortcutName)
|
164
|
+
end
|
165
|
+
|
166
|
+
# Get the real file name of a shortcut
|
167
|
+
#
|
168
|
+
# Parameters::
|
169
|
+
# * *iDst* (_String_): The destination file that will host the shortcut
|
170
|
+
# Return::
|
171
|
+
# * _String_: The real shortcut file name
|
172
|
+
def getShortcutFileName(iDst)
|
173
|
+
return iDst
|
174
|
+
end
|
175
|
+
|
145
176
|
end
|
146
177
|
|
147
178
|
end
|
@@ -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
|
|
@@ -7,12 +7,12 @@ module RUtilAnts
|
|
7
7
|
|
8
8
|
module Platform
|
9
9
|
|
10
|
-
|
10
|
+
module PlatformInfo
|
11
11
|
|
12
12
|
# Return the ID of the OS
|
13
13
|
# Applications may adapt their behavior based on it.
|
14
14
|
#
|
15
|
-
# Return
|
15
|
+
# Return::
|
16
16
|
# * _Integer_: OS ID
|
17
17
|
def os
|
18
18
|
return OS_LINUX
|
@@ -20,7 +20,7 @@ module RUtilAnts
|
|
20
20
|
|
21
21
|
# Return the list of directories where we look for executables
|
22
22
|
#
|
23
|
-
# Return
|
23
|
+
# Return::
|
24
24
|
# * <em>list<String></em>: List of directories
|
25
25
|
def getSystemExePath
|
26
26
|
return ENV['PATH'].split(':')
|
@@ -28,7 +28,7 @@ module RUtilAnts
|
|
28
28
|
|
29
29
|
# Set the list of directories where we look for executables
|
30
30
|
#
|
31
|
-
# Parameters
|
31
|
+
# Parameters::
|
32
32
|
# * *iNewDirsList* (<em>list<String></em>): List of directories
|
33
33
|
def setSystemExePath(iNewDirsList)
|
34
34
|
ENV['PATH'] = iNewDirsList.join(':')
|
@@ -37,7 +37,7 @@ module RUtilAnts
|
|
37
37
|
# Return the list of file extensions that might be discretely happened to executable files.
|
38
38
|
# This is the optional extensions that can be happened when invoked from a terminal.
|
39
39
|
#
|
40
|
-
# Return
|
40
|
+
# Return::
|
41
41
|
# * <em>list<String></em>: List of extensions (including .)
|
42
42
|
def getDiscreteExeExtensions
|
43
43
|
return []
|
@@ -45,7 +45,7 @@ module RUtilAnts
|
|
45
45
|
|
46
46
|
# Return the list of directories where we look for libraries
|
47
47
|
#
|
48
|
-
# Return
|
48
|
+
# Return::
|
49
49
|
# * <em>list<String></em>: List of directories
|
50
50
|
def getSystemLibsPath
|
51
51
|
rList = ENV['PATH'].split(':')
|
@@ -59,7 +59,7 @@ module RUtilAnts
|
|
59
59
|
|
60
60
|
# Set the list of directories where we look for libraries
|
61
61
|
#
|
62
|
-
# Parameters
|
62
|
+
# Parameters::
|
63
63
|
# * *iNewDirsList* (<em>list<String></em>): List of directories
|
64
64
|
def setSystemLibsPath(iNewDirsList)
|
65
65
|
ENV['LD_LIBRARY_PATH'] = iNewDirsList.join(':')
|
@@ -67,7 +67,7 @@ module RUtilAnts
|
|
67
67
|
|
68
68
|
# This method sends a message (platform dependent) to the user, without the use of wxruby
|
69
69
|
#
|
70
|
-
# Parameters
|
70
|
+
# Parameters::
|
71
71
|
# * *iMsg* (_String_): The message to display
|
72
72
|
def sendMsg(iMsg)
|
73
73
|
# TODO: Handle case of xmessage not installed
|
@@ -84,10 +84,10 @@ module RUtilAnts
|
|
84
84
|
# Execute a Shell command.
|
85
85
|
# Do not wait for its termination.
|
86
86
|
#
|
87
|
-
# Parameters
|
87
|
+
# Parameters::
|
88
88
|
# * *iCmd* (_String_): The command to execute
|
89
89
|
# * *iInTerminal* (_Boolean_): Do we execute this command in a separate terminal ?
|
90
|
-
# Return
|
90
|
+
# Return::
|
91
91
|
# * _Exception_: Error, or nil if success
|
92
92
|
def execShellCmdNoWait(iCmd, iInTerminal)
|
93
93
|
rException = nil
|
@@ -110,9 +110,9 @@ module RUtilAnts
|
|
110
110
|
|
111
111
|
# Execute a given URL to be launched in a browser
|
112
112
|
#
|
113
|
-
# Parameters
|
113
|
+
# Parameters::
|
114
114
|
# * *iURL* (_String_): The URL to launch
|
115
|
-
# Return
|
115
|
+
# Return::
|
116
116
|
# * _String_: Error message, or nil if success
|
117
117
|
def launchURL(iURL)
|
118
118
|
rError = nil
|
@@ -128,7 +128,7 @@ module RUtilAnts
|
|
128
128
|
|
129
129
|
# Get file extensions specifics to executable files
|
130
130
|
#
|
131
|
-
# Return
|
131
|
+
# Return::
|
132
132
|
# * <em>list<String></em>: List of extensions (including . character). It can be empty.
|
133
133
|
def getExecutableExtensions
|
134
134
|
return []
|
@@ -136,12 +136,43 @@ module RUtilAnts
|
|
136
136
|
|
137
137
|
# Get prohibited characters from file names
|
138
138
|
#
|
139
|
-
# Return
|
139
|
+
# Return::
|
140
140
|
# * _String_: String of prohibited characters in file names
|
141
141
|
def getProhibitedFileNamesCharacters
|
142
142
|
return '/'
|
143
143
|
end
|
144
144
|
|
145
|
+
# Create a shortcut (ln -s on Cygwin/Unix systems, a .lnk file on Windows systems)
|
146
|
+
#
|
147
|
+
# Parameters::
|
148
|
+
# * *iSrc* (_String_): The source file
|
149
|
+
# * *iDst* (_String_): The destination file
|
150
|
+
def createShortcut(iSrc, iDst)
|
151
|
+
require 'fileutils'
|
152
|
+
FileUtils::ln_s(iSrc, iDst)
|
153
|
+
end
|
154
|
+
|
155
|
+
# Get the name of a real file name, pointed by a shortcut.
|
156
|
+
# On Windows systems, it will be the target of the lnk file.
|
157
|
+
#
|
158
|
+
# Parameters::
|
159
|
+
# * *iShortcutName* (_String_): Name of the shortcut (same name used by createShortcut). Don't use OS specific extensions in this name (no .lnk).
|
160
|
+
# Return::
|
161
|
+
# * _String_: The real file name pointed by this shortcut
|
162
|
+
def followShortcut(iShortcutName)
|
163
|
+
return File.readlink(iShortcutName)
|
164
|
+
end
|
165
|
+
|
166
|
+
# Get the real file name of a shortcut
|
167
|
+
#
|
168
|
+
# Parameters::
|
169
|
+
# * *iDst* (_String_): The destination file that will host the shortcut
|
170
|
+
# Return::
|
171
|
+
# * _String_: The real shortcut file name
|
172
|
+
def getShortcutFileName(iDst)
|
173
|
+
return iDst
|
174
|
+
end
|
175
|
+
|
145
176
|
end
|
146
177
|
|
147
178
|
end
|
@@ -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
|
|
@@ -7,12 +7,12 @@ module RUtilAnts
|
|
7
7
|
|
8
8
|
module Platform
|
9
9
|
|
10
|
-
|
10
|
+
module PlatformInfo
|
11
11
|
|
12
12
|
# Return the ID of the OS
|
13
13
|
# Applications may adapt their behavior based on it.
|
14
14
|
#
|
15
|
-
# Return
|
15
|
+
# Return::
|
16
16
|
# * _Integer_: OS ID
|
17
17
|
def os
|
18
18
|
return OS_WINDOWS
|
@@ -20,7 +20,7 @@ module RUtilAnts
|
|
20
20
|
|
21
21
|
# Return the list of directories where we look for executables
|
22
22
|
#
|
23
|
-
# Return
|
23
|
+
# Return::
|
24
24
|
# * <em>list<String></em>: List of directories
|
25
25
|
def getSystemExePath
|
26
26
|
return ENV['PATH'].split(';')
|
@@ -28,7 +28,7 @@ module RUtilAnts
|
|
28
28
|
|
29
29
|
# Set the list of directories where we look for executables
|
30
30
|
#
|
31
|
-
# Parameters
|
31
|
+
# Parameters::
|
32
32
|
# * *iNewDirsList* (<em>list<String></em>): List of directories
|
33
33
|
def setSystemExePath(iNewDirsList)
|
34
34
|
ENV['PATH'] = iNewDirsList.join(';')
|
@@ -37,7 +37,7 @@ module RUtilAnts
|
|
37
37
|
# Return the list of file extensions that might be discretely happened to executable files.
|
38
38
|
# This is the optional extensions that can be happened when invoked from a terminal.
|
39
39
|
#
|
40
|
-
# Return
|
40
|
+
# Return::
|
41
41
|
# * <em>list<String></em>: List of extensions (including .)
|
42
42
|
def getDiscreteExeExtensions
|
43
43
|
rExtList = []
|
@@ -51,7 +51,7 @@ module RUtilAnts
|
|
51
51
|
|
52
52
|
# Return the list of directories where we look for libraries
|
53
53
|
#
|
54
|
-
# Return
|
54
|
+
# Return::
|
55
55
|
# * <em>list<String></em>: List of directories
|
56
56
|
def getSystemLibsPath
|
57
57
|
return ENV['PATH'].split(';')
|
@@ -59,7 +59,7 @@ module RUtilAnts
|
|
59
59
|
|
60
60
|
# Set the list of directories where we look for libraries
|
61
61
|
#
|
62
|
-
# Parameters
|
62
|
+
# Parameters::
|
63
63
|
# * *iNewDirsList* (<em>list<String></em>): List of directories
|
64
64
|
def setSystemLibsPath(iNewDirsList)
|
65
65
|
ENV['PATH'] = iNewDirsList.join(';')
|
@@ -67,7 +67,7 @@ module RUtilAnts
|
|
67
67
|
|
68
68
|
# This method sends a message (platform dependent) to the user, without the use of wxruby
|
69
69
|
#
|
70
|
-
# Parameters
|
70
|
+
# Parameters::
|
71
71
|
# * *iMsg* (_String_): The message to display
|
72
72
|
def sendMsg(iMsg)
|
73
73
|
# iMsg must not be longer than 255 characters
|
@@ -82,10 +82,10 @@ module RUtilAnts
|
|
82
82
|
# Execute a Shell command.
|
83
83
|
# Do not wait for its termination.
|
84
84
|
#
|
85
|
-
# Parameters
|
85
|
+
# Parameters::
|
86
86
|
# * *iCmd* (_String_): The command to execute
|
87
87
|
# * *iInTerminal* (_Boolean_): Do we execute this command in a separate terminal ?
|
88
|
-
# Return
|
88
|
+
# Return::
|
89
89
|
# * _Exception_: Error, or nil if success
|
90
90
|
def execShellCmdNoWait(iCmd, iInTerminal)
|
91
91
|
rException = nil
|
@@ -107,9 +107,9 @@ module RUtilAnts
|
|
107
107
|
|
108
108
|
# Execute a given URL to be launched in a browser
|
109
109
|
#
|
110
|
-
# Parameters
|
110
|
+
# Parameters::
|
111
111
|
# * *iURL* (_String_): The URL to launch
|
112
|
-
# Return
|
112
|
+
# Return::
|
113
113
|
# * _String_: Error message, or nil if success
|
114
114
|
def launchURL(iURL)
|
115
115
|
rError = nil
|
@@ -127,21 +127,62 @@ module RUtilAnts
|
|
127
127
|
|
128
128
|
# Get file extensions specifics to executable files
|
129
129
|
#
|
130
|
-
# Return
|
130
|
+
# Return::
|
131
131
|
# * <em>list<String></em>: List of extensions (including . character). It can be empty.
|
132
132
|
def getExecutableExtensions
|
133
|
-
|
134
|
-
|
133
|
+
rLstExt = [ '.exe', '.com', '.bat' ]
|
134
|
+
|
135
|
+
# Use PATHEXT environment variable if possible
|
136
|
+
if (ENV['PATHEXT'] != nil)
|
137
|
+
rLstExt.concat(ENV['PATHEXT'].split(';').map { |iExt| iExt.downcase })
|
138
|
+
rLstExt.uniq!
|
139
|
+
end
|
140
|
+
|
141
|
+
return rLstExt
|
135
142
|
end
|
136
143
|
|
137
144
|
# Get prohibited characters from file names
|
138
145
|
#
|
139
|
-
# Return
|
146
|
+
# Return::
|
140
147
|
# * _String_: String of prohibited characters in file names
|
141
148
|
def getProhibitedFileNamesCharacters
|
142
149
|
return '\\/:*?"<>|'
|
143
150
|
end
|
144
151
|
|
152
|
+
# Create a shortcut (ln -s on Cygwin/Unix systems, a .lnk file on Windows systems)
|
153
|
+
#
|
154
|
+
# Parameters::
|
155
|
+
# * *iSrc* (_String_): The source file
|
156
|
+
# * *iDst* (_String_): The destination file
|
157
|
+
def createShortcut(iSrc, iDst)
|
158
|
+
require 'win32/shortcut'
|
159
|
+
Win32::Shortcut.new(getShortcutFileName(iDst)) do |oShortcut|
|
160
|
+
oShortcut.path = File.expand_path(iSrc)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# Get the name of a real file name, pointed by a shortcut.
|
165
|
+
# On Windows systems, it will be the target of the lnk file.
|
166
|
+
#
|
167
|
+
# Parameters::
|
168
|
+
# * *iShortcutName* (_String_): Name of the shortcut (same name used by createShortcut). Don't use OS specific extensions in this name (no .lnk).
|
169
|
+
# Return::
|
170
|
+
# * _String_: The real file name pointed by this shortcut
|
171
|
+
def followShortcut(iShortcutName)
|
172
|
+
require 'win32/shortcut'
|
173
|
+
return Win32::Shortcut.open(getShortcutFileName(iShortcutName)).path
|
174
|
+
end
|
175
|
+
|
176
|
+
# Get the real file name of a shortcut
|
177
|
+
#
|
178
|
+
# Parameters::
|
179
|
+
# * *iDst* (_String_): The destination file that will host the shortcut
|
180
|
+
# Return::
|
181
|
+
# * _String_: The real shortcut file name
|
182
|
+
def getShortcutFileName(iDst)
|
183
|
+
return "#{iDst}.lnk"
|
184
|
+
end
|
185
|
+
|
145
186
|
end
|
146
187
|
|
147
188
|
end
|