rUtilAnts 1.0.1.20130320 → 2.0.0.20130827

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 CHANGED
@@ -8,3 +8,4 @@
8
8
  * 0.3.0.20110825
9
9
  * 1.0.0.20120223
10
10
  * 1.0.1.20130320
11
+ * 2.0.0.20130827
data/ChangeLog CHANGED
@@ -1,5 +1,9 @@
1
1
  = rUtilAnts Release History
2
2
 
3
+ == 2.0.0.20130827 (Beta)
4
+
5
+ * [Platform] New API for Platforms
6
+
3
7
  == 1.0.1.20130320 (Beta)
4
8
 
5
9
  * [Platform] Added missing platforms, works for JRuby and MacOS
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 - 2012 Muriel Salvan (muriel@x-aeon.com)
9
+ Copyright (c) 2009 - 2013 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/ReleaseInfo CHANGED
@@ -2,7 +2,7 @@
2
2
  # This file has been generated by RubyPackager during a delivery.
3
3
  # More info about RubyPackager: http://rubypackager.sourceforge.net
4
4
  {
5
- :version => '1.0.1.20130320',
5
+ :version => '2.0.0.20130827',
6
6
  :tags => [ 'Beta' ],
7
7
  :dev_status => 'Beta'
8
8
  }
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  require 'ezcrypto'
7
2
  require 'zlib'
8
3
  require 'fileutils'
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  # This module defines a method to run a given Ruby's object and parameters in a separate process.
data/lib/rUtilAnts/GUI.rb CHANGED
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  # WxRuby has to be loaded correctly in the environment before requiring this file
7
2
 
8
3
  module RUtilAnts
@@ -312,7 +307,7 @@ module RUtilAnts
312
307
  # Very handy for timers processing data that might be destroyed.
313
308
  # To be used with safeTimerAfter and safeTimerEvery.
314
309
  class SafeTimersManager
315
-
310
+
316
311
  # Constructor
317
312
  def initialize
318
313
  # List of registered timers
@@ -503,7 +498,7 @@ module RUtilAnts
503
498
 
504
499
  return rBitmap, rError
505
500
  end
506
-
501
+
507
502
  # Check if it is ok and the error set correctly
508
503
  if ((rReadBitmap == nil) and
509
504
  (rReadError == nil))
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module GUI
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module Logging
@@ -210,9 +205,9 @@ Stack:
210
205
  end
211
206
  else
212
207
  # Use normal platform dependent message, if the platform has been initialized (otherwise, stick to $stderr)
213
- if ((defined?(sendMsg) != nil) and
208
+ if ((defined?(display_msg) != nil) and
214
209
  (!@NoDialogs))
215
- sendMsg("A bug has just occurred.
210
+ display_msg("A bug has just occurred.
216
211
  Normally you should never see this message, but this application is not bug-less.
217
212
  We are sorry for the inconvenience caused.
218
213
  If you want to help improving this application, please inform us of this bug:
@@ -251,10 +246,10 @@ Details:
251
246
  ) do |iModalResult, iDialog|
252
247
  # Nothing to do
253
248
  end
254
- elsif ((defined?(sendMsg) != nil) and
249
+ elsif ((defined?(display_msg) != nil) and
255
250
  (!@NoDialogs))
256
251
  # Use normal platform dependent message, if the platform has been initialized (otherwise, stick to $stderr)
257
- sendMsg(iMsg)
252
+ display_msg(iMsg)
258
253
  end
259
254
  else
260
255
  @ErrorsStack << iMsg
@@ -285,10 +280,10 @@ Details:
285
280
  ) do |iModalResult, iDialog|
286
281
  # Nothing to do
287
282
  end
288
- elsif ((defined?(sendMsg) != nil) and
283
+ elsif ((defined?(display_msg) != nil) and
289
284
  (!@NoDialogs))
290
285
  # Use normal platform dependent message, if the platform has been initialized (otherwise, stick to $stderr)
291
- sendMsg(iMsg)
286
+ display_msg(iMsg)
292
287
  end
293
288
  else
294
289
  @MessagesStack << iMsg
@@ -442,4 +437,4 @@ Details:
442
437
 
443
438
  end
444
439
 
445
- end
440
+ end
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module Misc
@@ -41,8 +36,8 @@ module RUtilAnts
41
36
  # Return::
42
37
  # * _String_: The correct file name
43
38
  def get_valid_file_name(iFileName)
44
- if (defined?(getProhibitedFileNamesCharacters) != nil)
45
- return iFileName.gsub(/[#{Regexp.escape(getProhibitedFileNamesCharacters)}]/, '_')
39
+ if (defined?(prohibited_file_names_chars) != nil)
40
+ return iFileName.gsub(/[#{Regexp.escape(prohibited_file_names_chars)}]/, '_')
46
41
  else
47
42
  return iFileName
48
43
  end
@@ -90,7 +85,7 @@ module RUtilAnts
90
85
  end
91
86
  end
92
87
  # Then, ensure the gem dependency
93
- rError, lCMApplied, lIgnored, lUnresolved = lRDIInstaller.ensure_dependencies(
88
+ rError, _, lIgnored, lUnresolved = lRDIInstaller.ensure_dependencies(
94
89
  [
95
90
  RDI::Model::DependencyDescription.new('RubyZip').add_description( {
96
91
  :Testers => [
@@ -273,4 +268,4 @@ module RUtilAnts
273
268
 
274
269
  end
275
270
 
276
- end
271
+ end
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2011 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module MySQLPool
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module Platform
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module Platform
@@ -22,7 +17,7 @@ module RUtilAnts
22
17
  #
23
18
  # Return::
24
19
  # * <em>list<String></em>: List of directories
25
- def getSystemExePath
20
+ def system_exe_paths
26
21
  return ENV['PATH'].split(':')
27
22
  end
28
23
 
@@ -30,7 +25,7 @@ module RUtilAnts
30
25
  #
31
26
  # Parameters::
32
27
  # * *iNewDirsList* (<em>list<String></em>): List of directories
33
- def setSystemExePath(iNewDirsList)
28
+ def set_system_exe_paths(iNewDirsList)
34
29
  ENV['PATH'] = iNewDirsList.join(':')
35
30
  end
36
31
 
@@ -39,7 +34,7 @@ module RUtilAnts
39
34
  #
40
35
  # Return::
41
36
  # * <em>list<String></em>: List of extensions (including .)
42
- def getDiscreteExeExtensions
37
+ def discrete_exe_extensions
43
38
  return []
44
39
  end
45
40
 
@@ -47,7 +42,7 @@ module RUtilAnts
47
42
  #
48
43
  # Return::
49
44
  # * <em>list<String></em>: List of directories
50
- def getSystemLibsPath
45
+ def system_lib_paths
51
46
  rList = ENV['PATH'].split(':')
52
47
 
53
48
  if (ENV['LD_LIBRARY_PATH'] != nil)
@@ -61,7 +56,7 @@ module RUtilAnts
61
56
  #
62
57
  # Parameters::
63
58
  # * *iNewDirsList* (<em>list<String></em>): List of directories
64
- def setSystemLibsPath(iNewDirsList)
59
+ def set_system_lib_paths(iNewDirsList)
65
60
  ENV['LD_LIBRARY_PATH'] = iNewDirsList.join(':')
66
61
  end
67
62
 
@@ -69,7 +64,7 @@ module RUtilAnts
69
64
  #
70
65
  # Parameters::
71
66
  # * *iMsg* (_String_): The message to display
72
- def sendMsg(iMsg)
67
+ def display_msg(iMsg)
73
68
  # TODO: Handle case of xmessage not installed
74
69
  # Create a temporary file with the content to display
75
70
  require 'tmpdir'
@@ -87,50 +82,36 @@ module RUtilAnts
87
82
  # Parameters::
88
83
  # * *iCmd* (_String_): The command to execute
89
84
  # * *iInTerminal* (_Boolean_): Do we execute this command in a separate terminal ?
90
- # Return::
91
- # * _Exception_: Error, or nil if success
92
- def execShellCmdNoWait(iCmd, iInTerminal)
93
- rException = nil
94
-
85
+ def exec_cmd_async(iCmd, iInTerminal)
95
86
  if (iInTerminal)
96
87
  # TODO: Handle case of xterm not installed
97
- if (!system("xterm -e \"#{iCmd}\""))
98
- rException = RuntimeError.new
99
- end
88
+ raise "Error while executing \"xterm -e \"#{iCmd}\"\": exit status #{$?.exitstatus}" if (!system("xterm -e \"#{iCmd}\""))
100
89
  else
101
- begin
102
- IO.popen(iCmd)
103
- rescue Exception
104
- rException = $!
105
- end
90
+ IO.popen(iCmd)
106
91
  end
107
-
108
- return rException
109
92
  end
110
93
 
111
94
  # Execute a given URL to be launched in a browser
112
95
  #
113
96
  # Parameters::
114
97
  # * *iURL* (_String_): The URL to launch
115
- # Return::
116
- # * _String_: Error message, or nil if success
117
- def launchURL(iURL)
118
- rError = nil
119
-
120
- begin
121
- IO.popen("xdg-open '#{iURL}'")
122
- rescue Exception
123
- rError = $!.to_s
124
- end
98
+ def os_open_url(iURL)
99
+ IO.popen("xdg-open '#{iURL}'")
100
+ end
125
101
 
126
- return rError
102
+ # Open a given file with the default OS application
103
+ #
104
+ # Parameters::
105
+ # * *file_name* (_String_): The file to open
106
+ def os_open_file(file_name)
107
+ IO.popen("xdg-open \"#{file_name}\"")
127
108
  end
128
109
 
129
110
  # Get file extensions specifics to executable files
130
111
  #
131
112
  # Return::
132
113
  # * <em>list<String></em>: List of extensions (including . character). It can be empty.
133
- def getExecutableExtensions
114
+ def executables_ext
134
115
  return []
135
116
  end
136
117
 
@@ -138,7 +119,7 @@ module RUtilAnts
138
119
  #
139
120
  # Return::
140
121
  # * _String_: String of prohibited characters in file names
141
- def getProhibitedFileNamesCharacters
122
+ def prohibited_file_names_chars
142
123
  return '/'
143
124
  end
144
125
 
@@ -147,7 +128,7 @@ module RUtilAnts
147
128
  # Parameters::
148
129
  # * *iSrc* (_String_): The source file
149
130
  # * *iDst* (_String_): The destination file
150
- def createShortcut(iSrc, iDst)
131
+ def create_shortcut(iSrc, iDst)
151
132
  require 'fileutils'
152
133
  FileUtils::ln_s(iSrc, iDst)
153
134
  end
@@ -156,10 +137,10 @@ module RUtilAnts
156
137
  # On Windows systems, it will be the target of the lnk file.
157
138
  #
158
139
  # Parameters::
159
- # * *iShortcutName* (_String_): Name of the shortcut (same name used by createShortcut). Don't use OS specific extensions in this name (no .lnk).
140
+ # * *iShortcutName* (_String_): Name of the shortcut (same name used by create_shortcut). Don't use OS specific extensions in this name (no .lnk).
160
141
  # Return::
161
142
  # * _String_: The real file name pointed by this shortcut
162
- def followShortcut(iShortcutName)
143
+ def get_shortcut_target(iShortcutName)
163
144
  return File.readlink(iShortcutName)
164
145
  end
165
146
 
@@ -169,7 +150,7 @@ module RUtilAnts
169
150
  # * *iDst* (_String_): The destination file that will host the shortcut
170
151
  # Return::
171
152
  # * _String_: The real shortcut file name
172
- def getShortcutFileName(iDst)
153
+ def get_shortcut_file_name(iDst)
173
154
  return iDst
174
155
  end
175
156
 
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module Platform
@@ -22,7 +17,7 @@ module RUtilAnts
22
17
  #
23
18
  # Return::
24
19
  # * <em>list<String></em>: List of directories
25
- def getSystemExePath
20
+ def system_exe_paths
26
21
  return ENV['PATH'].split(':')
27
22
  end
28
23
 
@@ -30,7 +25,7 @@ module RUtilAnts
30
25
  #
31
26
  # Parameters::
32
27
  # * *iNewDirsList* (<em>list<String></em>): List of directories
33
- def setSystemExePath(iNewDirsList)
28
+ def set_system_exe_paths(iNewDirsList)
34
29
  ENV['PATH'] = iNewDirsList.join(':')
35
30
  end
36
31
 
@@ -39,7 +34,7 @@ module RUtilAnts
39
34
  #
40
35
  # Return::
41
36
  # * <em>list<String></em>: List of extensions (including .)
42
- def getDiscreteExeExtensions
37
+ def discrete_exe_extensions
43
38
  return []
44
39
  end
45
40
 
@@ -47,7 +42,7 @@ module RUtilAnts
47
42
  #
48
43
  # Return::
49
44
  # * <em>list<String></em>: List of directories
50
- def getSystemLibsPath
45
+ def system_lib_paths
51
46
  rList = ENV['PATH'].split(':')
52
47
 
53
48
  if (ENV['LD_LIBRARY_PATH'] != nil)
@@ -61,7 +56,7 @@ module RUtilAnts
61
56
  #
62
57
  # Parameters::
63
58
  # * *iNewDirsList* (<em>list<String></em>): List of directories
64
- def setSystemLibsPath(iNewDirsList)
59
+ def set_system_lib_paths(iNewDirsList)
65
60
  ENV['LD_LIBRARY_PATH'] = iNewDirsList.join(':')
66
61
  end
67
62
 
@@ -69,7 +64,7 @@ module RUtilAnts
69
64
  #
70
65
  # Parameters::
71
66
  # * *iMsg* (_String_): The message to display
72
- def sendMsg(iMsg)
67
+ def display_msg(iMsg)
73
68
  # TODO: Handle case of xmessage not installed
74
69
  # Create a temporary file with the content to display
75
70
  require 'tmpdir'
@@ -87,50 +82,36 @@ module RUtilAnts
87
82
  # Parameters::
88
83
  # * *iCmd* (_String_): The command to execute
89
84
  # * *iInTerminal* (_Boolean_): Do we execute this command in a separate terminal ?
90
- # Return::
91
- # * _Exception_: Error, or nil if success
92
- def execShellCmdNoWait(iCmd, iInTerminal)
93
- rException = nil
94
-
85
+ def exec_cmd_async(iCmd, iInTerminal)
95
86
  if (iInTerminal)
96
87
  # TODO: Handle case of xterm not installed
97
- if (!system("xterm -e \"#{iCmd}\""))
98
- rException = RuntimeError.new
99
- end
88
+ raise "Error while executing \"xterm -e \"#{iCmd}\"\": exit status #{$?.exitstatus}" if (!system("xterm -e \"#{iCmd}\""))
100
89
  else
101
- begin
102
- IO.popen(iCmd)
103
- rescue Exception
104
- rException = $!
105
- end
90
+ IO.popen(iCmd)
106
91
  end
107
-
108
- return rException
109
92
  end
110
93
 
111
94
  # Execute a given URL to be launched in a browser
112
95
  #
113
96
  # Parameters::
114
97
  # * *iURL* (_String_): The URL to launch
115
- # Return::
116
- # * _String_: Error message, or nil if success
117
- def launchURL(iURL)
118
- rError = nil
119
-
120
- begin
121
- IO.popen("xdg-open '#{iURL}'")
122
- rescue Exception
123
- rError = $!.to_s
124
- end
98
+ def os_open_url(iURL)
99
+ IO.popen("xdg-open '#{iURL}'")
100
+ end
125
101
 
126
- return rError
102
+ # Open a given file with the default OS application
103
+ #
104
+ # Parameters::
105
+ # * *file_name* (_String_): The file to open
106
+ def os_open_file(file_name)
107
+ IO.popen("xdg-open \"#{file_name}\"")
127
108
  end
128
109
 
129
110
  # Get file extensions specifics to executable files
130
111
  #
131
112
  # Return::
132
113
  # * <em>list<String></em>: List of extensions (including . character). It can be empty.
133
- def getExecutableExtensions
114
+ def executables_ext
134
115
  return []
135
116
  end
136
117
 
@@ -138,7 +119,7 @@ module RUtilAnts
138
119
  #
139
120
  # Return::
140
121
  # * _String_: String of prohibited characters in file names
141
- def getProhibitedFileNamesCharacters
122
+ def prohibited_file_names_chars
142
123
  return '/'
143
124
  end
144
125
 
@@ -147,7 +128,7 @@ module RUtilAnts
147
128
  # Parameters::
148
129
  # * *iSrc* (_String_): The source file
149
130
  # * *iDst* (_String_): The destination file
150
- def createShortcut(iSrc, iDst)
131
+ def create_shortcut(iSrc, iDst)
151
132
  require 'fileutils'
152
133
  FileUtils::ln_s(iSrc, iDst)
153
134
  end
@@ -156,10 +137,10 @@ module RUtilAnts
156
137
  # On Windows systems, it will be the target of the lnk file.
157
138
  #
158
139
  # Parameters::
159
- # * *iShortcutName* (_String_): Name of the shortcut (same name used by createShortcut). Don't use OS specific extensions in this name (no .lnk).
140
+ # * *iShortcutName* (_String_): Name of the shortcut (same name used by create_shortcut). Don't use OS specific extensions in this name (no .lnk).
160
141
  # Return::
161
142
  # * _String_: The real file name pointed by this shortcut
162
- def followShortcut(iShortcutName)
143
+ def get_shortcut_target(iShortcutName)
163
144
  return File.readlink(iShortcutName)
164
145
  end
165
146
 
@@ -169,7 +150,7 @@ module RUtilAnts
169
150
  # * *iDst* (_String_): The destination file that will host the shortcut
170
151
  # Return::
171
152
  # * _String_: The real shortcut file name
172
- def getShortcutFileName(iDst)
153
+ def get_shortcut_file_name(iDst)
173
154
  return iDst
174
155
  end
175
156
 
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module Platform
@@ -22,7 +17,7 @@ module RUtilAnts
22
17
  #
23
18
  # Return::
24
19
  # * <em>list<String></em>: List of directories
25
- def getSystemExePath
20
+ def system_exe_paths
26
21
  return ENV['PATH'].split(':')
27
22
  end
28
23
 
@@ -30,7 +25,7 @@ module RUtilAnts
30
25
  #
31
26
  # Parameters::
32
27
  # * *iNewDirsList* (<em>list<String></em>): List of directories
33
- def setSystemExePath(iNewDirsList)
28
+ def set_system_exe_paths(iNewDirsList)
34
29
  ENV['PATH'] = iNewDirsList.join(':')
35
30
  end
36
31
 
@@ -39,7 +34,7 @@ module RUtilAnts
39
34
  #
40
35
  # Return::
41
36
  # * <em>list<String></em>: List of extensions (including .)
42
- def getDiscreteExeExtensions
37
+ def discrete_exe_extensions
43
38
  return []
44
39
  end
45
40
 
@@ -47,7 +42,7 @@ module RUtilAnts
47
42
  #
48
43
  # Return::
49
44
  # * <em>list<String></em>: List of directories
50
- def getSystemLibsPath
45
+ def system_lib_paths
51
46
  rList = ENV['PATH'].split(':')
52
47
 
53
48
  if (ENV['LD_LIBRARY_PATH'] != nil)
@@ -61,7 +56,7 @@ module RUtilAnts
61
56
  #
62
57
  # Parameters::
63
58
  # * *iNewDirsList* (<em>list<String></em>): List of directories
64
- def setSystemLibsPath(iNewDirsList)
59
+ def set_system_lib_paths(iNewDirsList)
65
60
  ENV['LD_LIBRARY_PATH'] = iNewDirsList.join(':')
66
61
  end
67
62
 
@@ -69,7 +64,7 @@ module RUtilAnts
69
64
  #
70
65
  # Parameters::
71
66
  # * *iMsg* (_String_): The message to display
72
- def sendMsg(iMsg)
67
+ def display_msg(iMsg)
73
68
  # TODO: Handle case of xmessage not installed
74
69
  # Create a temporary file with the content to display
75
70
  require 'tmpdir'
@@ -87,50 +82,36 @@ module RUtilAnts
87
82
  # Parameters::
88
83
  # * *iCmd* (_String_): The command to execute
89
84
  # * *iInTerminal* (_Boolean_): Do we execute this command in a separate terminal ?
90
- # Return::
91
- # * _Exception_: Error, or nil if success
92
- def execShellCmdNoWait(iCmd, iInTerminal)
93
- rException = nil
94
-
85
+ def exec_cmd_async(iCmd, iInTerminal)
95
86
  if (iInTerminal)
96
87
  # TODO: Handle case of xterm not installed
97
- if (!system("xterm -e \"#{iCmd}\""))
98
- rException = RuntimeError.new
99
- end
88
+ raise "Error while executing \"xterm -e \"#{iCmd}\"\": exit status #{$?.exitstatus}" if (!system("xterm -e \"#{iCmd}\""))
100
89
  else
101
- begin
102
- IO.popen(iCmd)
103
- rescue Exception
104
- rException = $!
105
- end
90
+ IO.popen(iCmd)
106
91
  end
107
-
108
- return rException
109
92
  end
110
93
 
111
94
  # Execute a given URL to be launched in a browser
112
95
  #
113
96
  # Parameters::
114
97
  # * *iURL* (_String_): The URL to launch
115
- # Return::
116
- # * _String_: Error message, or nil if success
117
- def launchURL(iURL)
118
- rError = nil
119
-
120
- begin
121
- IO.popen("xdg-open '#{iURL}'")
122
- rescue Exception
123
- rError = $!.to_s
124
- end
98
+ def os_open_url(iURL)
99
+ IO.popen("xdg-open '#{iURL}'")
100
+ end
125
101
 
126
- return rError
102
+ # Open a given file with the default OS application
103
+ #
104
+ # Parameters::
105
+ # * *file_name* (_String_): The file to open
106
+ def os_open_file(file_name)
107
+ IO.popen("open \"#{file_name}\"")
127
108
  end
128
109
 
129
110
  # Get file extensions specifics to executable files
130
111
  #
131
112
  # Return::
132
113
  # * <em>list<String></em>: List of extensions (including . character). It can be empty.
133
- def getExecutableExtensions
114
+ def executables_ext
134
115
  return []
135
116
  end
136
117
 
@@ -138,7 +119,7 @@ module RUtilAnts
138
119
  #
139
120
  # Return::
140
121
  # * _String_: String of prohibited characters in file names
141
- def getProhibitedFileNamesCharacters
122
+ def prohibited_file_names_chars
142
123
  return '/'
143
124
  end
144
125
 
@@ -147,7 +128,7 @@ module RUtilAnts
147
128
  # Parameters::
148
129
  # * *iSrc* (_String_): The source file
149
130
  # * *iDst* (_String_): The destination file
150
- def createShortcut(iSrc, iDst)
131
+ def create_shortcut(iSrc, iDst)
151
132
  require 'fileutils'
152
133
  FileUtils::ln_s(iSrc, iDst)
153
134
  end
@@ -156,10 +137,10 @@ module RUtilAnts
156
137
  # On Windows systems, it will be the target of the lnk file.
157
138
  #
158
139
  # Parameters::
159
- # * *iShortcutName* (_String_): Name of the shortcut (same name used by createShortcut). Don't use OS specific extensions in this name (no .lnk).
140
+ # * *iShortcutName* (_String_): Name of the shortcut (same name used by create_shortcut). Don't use OS specific extensions in this name (no .lnk).
160
141
  # Return::
161
142
  # * _String_: The real file name pointed by this shortcut
162
- def followShortcut(iShortcutName)
143
+ def get_shortcut_target(iShortcutName)
163
144
  return File.readlink(iShortcutName)
164
145
  end
165
146
 
@@ -169,7 +150,7 @@ module RUtilAnts
169
150
  # * *iDst* (_String_): The destination file that will host the shortcut
170
151
  # Return::
171
152
  # * _String_: The real shortcut file name
172
- def getShortcutFileName(iDst)
153
+ def get_shortcut_file_name(iDst)
173
154
  return iDst
174
155
  end
175
156
 
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module Platform
@@ -22,7 +17,7 @@ module RUtilAnts
22
17
  #
23
18
  # Return::
24
19
  # * <em>list<String></em>: List of directories
25
- def getSystemExePath
20
+ def system_exe_paths
26
21
  return ENV['PATH'].split(':')
27
22
  end
28
23
 
@@ -30,7 +25,7 @@ module RUtilAnts
30
25
  #
31
26
  # Parameters::
32
27
  # * *iNewDirsList* (<em>list<String></em>): List of directories
33
- def setSystemExePath(iNewDirsList)
28
+ def set_system_exe_paths(iNewDirsList)
34
29
  ENV['PATH'] = iNewDirsList.join(':')
35
30
  end
36
31
 
@@ -39,7 +34,7 @@ module RUtilAnts
39
34
  #
40
35
  # Return::
41
36
  # * <em>list<String></em>: List of extensions (including .)
42
- def getDiscreteExeExtensions
37
+ def discrete_exe_extensions
43
38
  return []
44
39
  end
45
40
 
@@ -47,7 +42,7 @@ module RUtilAnts
47
42
  #
48
43
  # Return::
49
44
  # * <em>list<String></em>: List of directories
50
- def getSystemLibsPath
45
+ def system_lib_paths
51
46
  rList = ENV['PATH'].split(':')
52
47
 
53
48
  if (ENV['LD_LIBRARY_PATH'] != nil)
@@ -61,7 +56,7 @@ module RUtilAnts
61
56
  #
62
57
  # Parameters::
63
58
  # * *iNewDirsList* (<em>list<String></em>): List of directories
64
- def setSystemLibsPath(iNewDirsList)
59
+ def set_system_lib_paths(iNewDirsList)
65
60
  ENV['LD_LIBRARY_PATH'] = iNewDirsList.join(':')
66
61
  end
67
62
 
@@ -69,7 +64,7 @@ module RUtilAnts
69
64
  #
70
65
  # Parameters::
71
66
  # * *iMsg* (_String_): The message to display
72
- def sendMsg(iMsg)
67
+ def display_msg(iMsg)
73
68
  # TODO: Handle case of xmessage not installed
74
69
  # Create a temporary file with the content to display
75
70
  require 'tmpdir'
@@ -87,50 +82,36 @@ module RUtilAnts
87
82
  # Parameters::
88
83
  # * *iCmd* (_String_): The command to execute
89
84
  # * *iInTerminal* (_Boolean_): Do we execute this command in a separate terminal ?
90
- # Return::
91
- # * _Exception_: Error, or nil if success
92
- def execShellCmdNoWait(iCmd, iInTerminal)
93
- rException = nil
94
-
85
+ def exec_cmd_async(iCmd, iInTerminal)
95
86
  if (iInTerminal)
96
87
  # TODO: Handle case of xterm not installed
97
- if (!system("xterm -e \"#{iCmd}\""))
98
- rException = RuntimeError.new
99
- end
88
+ raise "Error while executing \"xterm -e \"#{iCmd}\"\": exit status #{$?.exitstatus}" if (!system("xterm -e \"#{iCmd}\""))
100
89
  else
101
- begin
102
- IO.popen(iCmd)
103
- rescue Exception
104
- rException = $!
105
- end
90
+ IO.popen(iCmd)
106
91
  end
107
-
108
- return rException
109
92
  end
110
93
 
111
94
  # Execute a given URL to be launched in a browser
112
95
  #
113
96
  # Parameters::
114
97
  # * *iURL* (_String_): The URL to launch
115
- # Return::
116
- # * _String_: Error message, or nil if success
117
- def launchURL(iURL)
118
- rError = nil
119
-
120
- begin
121
- IO.popen("xdg-open '#{iURL}'")
122
- rescue Exception
123
- rError = $!.to_s
124
- end
98
+ def os_open_url(iURL)
99
+ IO.popen("xdg-open '#{iURL}'")
100
+ end
125
101
 
126
- return rError
102
+ # Open a given file with the default OS application
103
+ #
104
+ # Parameters::
105
+ # * *file_name* (_String_): The file to open
106
+ def os_open_file(file_name)
107
+ IO.popen("xdg-open \"#{file_name}\"")
127
108
  end
128
109
 
129
110
  # Get file extensions specifics to executable files
130
111
  #
131
112
  # Return::
132
113
  # * <em>list<String></em>: List of extensions (including . character). It can be empty.
133
- def getExecutableExtensions
114
+ def executables_ext
134
115
  return []
135
116
  end
136
117
 
@@ -138,7 +119,7 @@ module RUtilAnts
138
119
  #
139
120
  # Return::
140
121
  # * _String_: String of prohibited characters in file names
141
- def getProhibitedFileNamesCharacters
122
+ def prohibited_file_names_chars
142
123
  return '/'
143
124
  end
144
125
 
@@ -147,7 +128,7 @@ module RUtilAnts
147
128
  # Parameters::
148
129
  # * *iSrc* (_String_): The source file
149
130
  # * *iDst* (_String_): The destination file
150
- def createShortcut(iSrc, iDst)
131
+ def create_shortcut(iSrc, iDst)
151
132
  require 'fileutils'
152
133
  FileUtils::ln_s(iSrc, iDst)
153
134
  end
@@ -156,10 +137,10 @@ module RUtilAnts
156
137
  # On Windows systems, it will be the target of the lnk file.
157
138
  #
158
139
  # Parameters::
159
- # * *iShortcutName* (_String_): Name of the shortcut (same name used by createShortcut). Don't use OS specific extensions in this name (no .lnk).
140
+ # * *iShortcutName* (_String_): Name of the shortcut (same name used by create_shortcut). Don't use OS specific extensions in this name (no .lnk).
160
141
  # Return::
161
142
  # * _String_: The real file name pointed by this shortcut
162
- def followShortcut(iShortcutName)
143
+ def get_shortcut_target(iShortcutName)
163
144
  return File.readlink(iShortcutName)
164
145
  end
165
146
 
@@ -169,7 +150,7 @@ module RUtilAnts
169
150
  # * *iDst* (_String_): The destination file that will host the shortcut
170
151
  # Return::
171
152
  # * _String_: The real shortcut file name
172
- def getShortcutFileName(iDst)
153
+ def get_shortcut_file_name(iDst)
173
154
  return iDst
174
155
  end
175
156
 
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module Platform
@@ -22,7 +17,7 @@ module RUtilAnts
22
17
  #
23
18
  # Return::
24
19
  # * <em>list<String></em>: List of directories
25
- def getSystemExePath
20
+ def system_exe_paths
26
21
  return ENV['PATH'].split(';')
27
22
  end
28
23
 
@@ -30,7 +25,7 @@ module RUtilAnts
30
25
  #
31
26
  # Parameters::
32
27
  # * *iNewDirsList* (<em>list<String></em>): List of directories
33
- def setSystemExePath(iNewDirsList)
28
+ def set_system_exe_paths(iNewDirsList)
34
29
  ENV['PATH'] = iNewDirsList.join(';')
35
30
  end
36
31
 
@@ -39,7 +34,7 @@ module RUtilAnts
39
34
  #
40
35
  # Return::
41
36
  # * <em>list<String></em>: List of extensions (including .)
42
- def getDiscreteExeExtensions
37
+ def discrete_exe_extensions
43
38
  rExtList = []
44
39
 
45
40
  ENV['PATHEXT'].split(';').each do |iExt|
@@ -53,7 +48,7 @@ module RUtilAnts
53
48
  #
54
49
  # Return::
55
50
  # * <em>list<String></em>: List of directories
56
- def getSystemLibsPath
51
+ def system_lib_paths
57
52
  return ENV['PATH'].split(';')
58
53
  end
59
54
 
@@ -61,7 +56,7 @@ module RUtilAnts
61
56
  #
62
57
  # Parameters::
63
58
  # * *iNewDirsList* (<em>list<String></em>): List of directories
64
- def setSystemLibsPath(iNewDirsList)
59
+ def set_system_lib_paths(iNewDirsList)
65
60
  ENV['PATH'] = iNewDirsList.join(';')
66
61
  end
67
62
 
@@ -69,7 +64,7 @@ module RUtilAnts
69
64
  #
70
65
  # Parameters::
71
66
  # * *iMsg* (_String_): The message to display
72
- def sendMsg(iMsg)
67
+ def display_msg(iMsg)
73
68
  # iMsg must not be longer than 255 characters
74
69
  # \n must be escaped.
75
70
  if (iMsg.size > 255)
@@ -85,51 +80,38 @@ module RUtilAnts
85
80
  # Parameters::
86
81
  # * *iCmd* (_String_): The command to execute
87
82
  # * *iInTerminal* (_Boolean_): Do we execute this command in a separate terminal ?
88
- # Return::
89
- # * _Exception_: Error, or nil if success
90
- def execShellCmdNoWait(iCmd, iInTerminal)
91
- rException = nil
92
-
83
+ def exec_cmd_async(iCmd, iInTerminal)
93
84
  if (iInTerminal)
94
- if (!system("start cmd /c #{iCmd}"))
95
- rException = RuntimeError.new
96
- end
85
+ raise "Error while executing \"start cmd /c #{iCmd}\": exit status #{$?.exitstatus}" if (!system("start cmd /c #{iCmd}"))
97
86
  else
98
- begin
99
- IO.popen(iCmd)
100
- rescue Exception
101
- rException = $!
102
- end
87
+ IO.popen(iCmd)
103
88
  end
104
-
105
- return rException
106
89
  end
107
90
 
108
91
  # Execute a given URL to be launched in a browser
109
92
  #
110
93
  # Parameters::
111
94
  # * *iURL* (_String_): The URL to launch
112
- # Return::
113
- # * _String_: Error message, or nil if success
114
- def launchURL(iURL)
115
- rError = nil
116
-
95
+ def os_open_url(iURL)
117
96
  # We must put " around the URL after the http:// prefix, as otherwise & symbol will not be recognized
118
- lMatch = iURL.match(/^(http|https|ftp|ftps):\/\/(.*)$/)
119
- if (lMatch == nil)
120
- rError = "URL #{iURL} is not one of http://, https://, ftp:// or ftps://. Can't invoke it."
121
- else
122
- IO.popen("start #{lMatch[1]}://\"#{lMatch[2]}\"")
123
- end
97
+ lMatch = iURL.match(/^([^:]+):\/\/(.*)$/)
98
+ raise "URL \"#{iURL}\" is not valid. Can't invoke it." if (lMatch == nil)
99
+ IO.popen("start #{lMatch[1]}://\"#{lMatch[2]}\"")
100
+ end
124
101
 
125
- return rError
102
+ # Open a given file with the default OS application
103
+ #
104
+ # Parameters::
105
+ # * *file_name* (_String_): The file to open
106
+ def os_open_file(file_name)
107
+ IO.popen("start \"\" \"#{file_name}\"")
126
108
  end
127
109
 
128
110
  # Get file extensions specifics to executable files
129
111
  #
130
112
  # Return::
131
113
  # * <em>list<String></em>: List of extensions (including . character). It can be empty.
132
- def getExecutableExtensions
114
+ def executables_ext
133
115
  rLstExt = [ '.exe', '.com', '.bat' ]
134
116
 
135
117
  # Use PATHEXT environment variable if possible
@@ -145,7 +127,7 @@ module RUtilAnts
145
127
  #
146
128
  # Return::
147
129
  # * _String_: String of prohibited characters in file names
148
- def getProhibitedFileNamesCharacters
130
+ def prohibited_file_names_chars
149
131
  return '\\/:*?"<>|'
150
132
  end
151
133
 
@@ -154,9 +136,9 @@ module RUtilAnts
154
136
  # Parameters::
155
137
  # * *iSrc* (_String_): The source file
156
138
  # * *iDst* (_String_): The destination file
157
- def createShortcut(iSrc, iDst)
139
+ def create_shortcut(iSrc, iDst)
158
140
  require 'win32/shortcut'
159
- Win32::Shortcut.new(getShortcutFileName(iDst)) do |oShortcut|
141
+ Win32::Shortcut.new(get_shortcut_file_name(iDst)) do |oShortcut|
160
142
  oShortcut.path = File.expand_path(iSrc)
161
143
  end
162
144
  end
@@ -165,12 +147,12 @@ module RUtilAnts
165
147
  # On Windows systems, it will be the target of the lnk file.
166
148
  #
167
149
  # Parameters::
168
- # * *iShortcutName* (_String_): Name of the shortcut (same name used by createShortcut). Don't use OS specific extensions in this name (no .lnk).
150
+ # * *iShortcutName* (_String_): Name of the shortcut (same name used by create_shortcut). Don't use OS specific extensions in this name (no .lnk).
169
151
  # Return::
170
152
  # * _String_: The real file name pointed by this shortcut
171
- def followShortcut(iShortcutName)
153
+ def get_shortcut_target(iShortcutName)
172
154
  require 'win32/shortcut'
173
- return Win32::Shortcut.open(getShortcutFileName(iShortcutName)).path
155
+ return Win32::Shortcut.open(get_shortcut_file_name(iShortcutName)).path
174
156
  end
175
157
 
176
158
  # Get the real file name of a shortcut
@@ -179,7 +161,7 @@ module RUtilAnts
179
161
  # * *iDst* (_String_): The destination file that will host the shortcut
180
162
  # Return::
181
163
  # * _String_: The real shortcut file name
182
- def getShortcutFileName(iDst)
164
+ def get_shortcut_file_name(iDst)
183
165
  return "#{iDst}.lnk"
184
166
  end
185
167
 
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  # Module that defines a generic way to handle plugins:
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  # Make public methods from a module accessible in another module, using a singleton as proxy
@@ -12,22 +7,20 @@ module RUtilAnts
12
7
  # * *oDstModule* (_Module_): Module that will encapsulate the singleton and route all public methods through that singleton
13
8
  def self.make_singleton_proxy(iSrcModule, oDstModule)
14
9
  lSrcModuleConstName = iSrcModule.name.gsub(/\W/,'_')
15
-
16
10
  # Create the singleton class
17
- lSingletonClass = oDstModule.const_set("SingletonClassForModule__#{lSrcModuleConstName}", Class.new)
18
- lSingletonClass.class_eval("include #{iSrcModule}")
19
-
20
- # Instantiate it in the module
21
- lSymSingletonVarName = "@@__SingletonForModule__#{lSrcModuleConstName}".to_sym
22
- oDstModule.send(:class_variable_set, lSymSingletonVarName, lSingletonClass.new)
23
-
24
- # Create public methods from iSrcModule to oDstModule, using the singleton as a proxy
25
- iSrcModule.instance_methods.map { |iMethodName| iMethodName.to_sym }.each do |iSymMethodName|
26
- oDstModule.send(:define_method, iSymMethodName) do |*iArgs, &iBlock|
27
- oDstModule.send(:class_variable_get, lSymSingletonVarName).send(iSymMethodName, *iArgs, &iBlock)
11
+ if !oDstModule.const_defined?("SingletonClassForModule__#{lSrcModuleConstName}")
12
+ lSingletonClass = oDstModule.const_set("SingletonClassForModule__#{lSrcModuleConstName}", Class.new)
13
+ lSingletonClass.class_eval("include #{iSrcModule}")
14
+ # Instantiate it in the module
15
+ lSymSingletonVarName = "@@__SingletonForModule__#{lSrcModuleConstName}".to_sym
16
+ oDstModule.send(:class_variable_set, lSymSingletonVarName, lSingletonClass.new)
17
+ # Create public methods from iSrcModule to oDstModule, using the singleton as a proxy
18
+ iSrcModule.instance_methods.map { |iMethodName| iMethodName.to_sym }.each do |iSymMethodName|
19
+ oDstModule.send(:define_method, iSymMethodName) do |*iArgs, &iBlock|
20
+ oDstModule.send(:class_variable_get, lSymSingletonVarName).send(iSymMethodName, *iArgs, &iBlock)
21
+ end
28
22
  end
29
23
  end
30
-
31
24
  end
32
25
 
33
26
  end
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module URLAccess
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module URLCache
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module URLAccess
@@ -101,4 +96,4 @@ module RUtilAnts
101
96
 
102
97
  end
103
98
 
104
- end
99
+ end
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module URLAccess
@@ -117,4 +112,4 @@ module RUtilAnts
117
112
 
118
113
  end
119
114
 
120
- end
115
+ end
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module URLAccess
@@ -125,4 +120,4 @@ module RUtilAnts
125
120
 
126
121
  end
127
122
 
128
- end
123
+ end
@@ -1,8 +1,3 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
1
  module RUtilAnts
7
2
 
8
3
  module URLAccess
@@ -97,4 +92,4 @@ module RUtilAnts
97
92
 
98
93
  end
99
94
 
100
- end
95
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rUtilAnts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1.20130320
4
+ version: 2.0.0.20130827
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-20 00:00:00.000000000 Z
12
+ date: 2013-08-27 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: rUtilAnts is used by several projects. It includes common standard code.
15
15
  email: muriel@x-aeon.com
@@ -43,7 +43,6 @@ files:
43
43
  - lib/rUtilAnts/URLHandlers/HTTP.rb
44
44
  - lib/rUtilAnts/URLHandlers/LocalFile.rb
45
45
  - LICENSE
46
- - README
47
46
  - ReleaseInfo
48
47
  homepage: http://rutilants.sourceforge.net/
49
48
  licenses: []
data/README DELETED
@@ -1,15 +0,0 @@
1
- = rUtilAnts
2
-
3
- Library that ships several mini-libraries for everyday development activity.
4
-
5
- == Where is the documentation ?
6
-
7
- Check the website at http://rutilants.sourceforge.net
8
-
9
- == Who wrote it ?
10
-
11
- Check the AUTHORS[link:AUTHORS.html] file.
12
-
13
- == What is the license ?
14
-
15
- You can find out in the LICENSE[link:LICENSE.html] file.