Class: UsageMod::OpenURIInputPlugin
- Inherits:
-
FilePlugin
- Object
- ArgumentParserPlugin
- FilePlugin
- UsageMod::OpenURIInputPlugin
- Defined in:
- lib/Usage.rb
Instance Attribute Summary
Attributes inherited from ArgumentParserPlugin
Instance Method Summary collapse
-
#initialize(usage_ui, str) ⇒ OpenURIInputPlugin
constructor
A new instance of OpenURIInputPlugin.
Methods inherited from FilePlugin
Methods inherited from ArgumentParserPlugin
Constructor Details
#initialize(usage_ui, str) ⇒ OpenURIInputPlugin
Returns a new instance of OpenURIInputPlugin.
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
# File 'lib/Usage.rb', line 526 def initialize(usage_ui, str) $TRACE.debug 5, "trying to open uri '#{str}' for input" # see if it looks like a URI m = /^(\w+):\/\//.match(str) # if it matches and its not either http or ftp (which is all open-uri # does at this point if m && !(["http", "ftp"].include?(m[1].downcase)) then # tell the user raise OpenURIBadFormatError.new(str) end # if it starts with www. or ftp. then just pre-pend the transport protocol if m = /^(www|ftp)\./i.match(str) then if m[1].downcase == "www" then str = "http://" + str else str = "ftp://" + str end end # try opening it with open-uri begin @value = open(str) rescue Exception => e puts e. raise IOInputError.new(str, e.) end end |