Module: RUtilAnts::URLAccess
- Defined in:
- lib/rUtilAnts/URLAccess.rb
Defined Under Namespace
Classes: Manager, RedirectionError
Constant Summary collapse
- CONTENT_ERROR =
Constants identifying which form is the content returned by URL handlers
0
- CONTENT_REDIRECT =
1
- CONTENT_STRING =
2
- CONTENT_LOCALFILENAME =
3
- CONTENT_LOCALFILENAME_TEMPORARY =
4
Class Method Summary collapse
-
.initializeURLAccess ⇒ Object
Initialize a global plugins cache.
Instance Method Summary collapse
-
#accessFile(iURL, iParameters = {}) ⇒ Object
Access the content of a URL.
-
#getURLHandler(iURL) ⇒ Object
Get the URL handler corresponding to this URL.
Class Method Details
Instance Method Details
#accessFile(iURL, iParameters = {}) ⇒ Object
Access the content of a URL. No cache. It calls a code block with the binary content of the URL (or a local file name if required).
Parameters:
-
iURL (String): The URL (used to detect cyclic redirections)
-
iParameters (map<Symbol,Object>): Additional parameters:
** :FollowRedirections (Boolean): Do we follow redirections ? [optional = true] ** :NbrRedirectionsAllowed (Integer): Number of redirections allowed [optional = 10] ** :LocalFileAccess (Boolean): Do we need a local file to read the content from ? If not, the content itself will be given the code block. [optional = false] ** :URLHandler (Object): The URL handler, if it has already been instantiated, or nil otherwise [optional = nil]
-
CodeBlock: The code returning the object corresponding to the content:
** iContent (String): File content, or file name if :LocalFileAccess was true ** iFileBaseName (String): The base name the file could have. Useful to get file name extensions. ** Return: ** Exception: The error encountered, or nil in case of success Return:
-
Exception: The error encountered, or nil in case of success
214 215 216 217 218 |
# File 'lib/rUtilAnts/URLAccess.rb', line 214 def accessFile(iURL, iParameters = {}) return $rUtilAnts_URLAccess_Manager.accessFile(iURL, iParameters) do |iContent, iBaseName| yield(iContent, iBaseName) end end |
#getURLHandler(iURL) ⇒ Object
Get the URL handler corresponding to this URL
Parameters:
-
iURL (String): The URL
Return:
-
Object: The URL handler
226 227 228 |
# File 'lib/rUtilAnts/URLAccess.rb', line 226 def getURLHandler(iURL) return $rUtilAnts_URLAccess_Manager.getURLHandler(iURL) end |