class Rabbit::Source::URI

Public Class Methods

initial_args_description() click to toggle source
# File lib/rabbit/source/uri.rb, line 26
def initial_args_description
  N_("URI")
end
new(encoding, logger, uri) click to toggle source
# File lib/rabbit/source/uri.rb, line 14
def new(encoding, logger, uri)
  parsed_uri = ::URI.parse(uri)
  case parsed_uri.scheme
  when nil
    File.new(encoding, logger, parsed_uri.path)
  when /\Afile\z/i
    File.new(encoding, logger, uri.gsub(/\Afile:\/\//i, ""))
  else
    super
  end
end
new(encoding, logger, uri) click to toggle source
# File lib/rabbit/source/uri.rb, line 31
def initialize(encoding, logger, uri)
  @uri = ::URI.parse(uri)
  super(encoding, logger)
  @last_modified = nil
end

Public Instance Methods

extension() click to toggle source
# File lib/rabbit/source/uri.rb, line 41
def extension
  extract_extension(@uri.path)
end
need_read?() click to toggle source
Calls superclass method Rabbit::Source::Base#need_read?
# File lib/rabbit/source/uri.rb, line 37
def need_read?
  super or old?(@last_modified, :last_modified)
end

Private Instance Methods

_read() click to toggle source
# File lib/rabbit/source/uri.rb, line 46
def _read
  begin
    @uri.open do |f|
      @last_modified = f.last_modified
      f.read
    end
  rescue
    @logger.error($!.message)
    @last_modified = Time.now + MINIMUM_ACCESS_TIME
    ""
  end
end
init_base() click to toggle source
# File lib/rabbit/source/uri.rb, line 59
def init_base
  base = @uri.dup
  base.path = ::File.dirname(base.path)
  set_base(base.to_s)
end
last_modified() click to toggle source
# File lib/rabbit/source/uri.rb, line 65
def last_modified
  begin
    @uri.open do |f|
      f.last_modified
    end
  rescue
    @logger.error($!.message)
    Time.now
  end
end