lib/web_page_archiver.rb
def join_uri(base_filename_or_uri, path)
      stream = ""
      begin
        stream = open(base_filename_or_uri)
      rescue => ex
        print "!I1".colorize(:red)
        print " \"#{ex}\" ".gsub("\n", " ").gsub("\r", " ").colorize(:yellow)
        sleep(3.seconds)
        begin
          stream = open(base_filename_or_uri)
        rescue => ex
          print "!I2".colorize(:red)
          print " \"#{ex}\" ".gsub("\n", " ").gsub("\r", " ").colorize(:yellow)
          sleep(10.seconds)
          stream = open(base_filename_or_uri)
        end
      end

      joined = ""
      if stream.is_a? File
        base_filename_or_uri = base_filename_or_uri.path if base_filename_or_uri.is_a? File

        windows_drive_matcher = /((.*):\/)/
        windows_drive_match_data = base_filename_or_uri.match windows_drive_matcher
        if windows_drive_match_data
          base_filename_or_uri = base_filename_or_uri.gsub(windows_drive_matcher,'WINDOWS.DRIVE/')
        end

        joined = URI::join("file://#{base_filename_or_uri}", path)
        joined = joined.to_s.gsub('file://','').gsub('file:','')

        if windows_drive_match_data
          joined = joined.gsub('WINDOWS.DRIVE/',windows_drive_match_data[1])
        end
      else
        joined = URI::join(base_filename_or_uri, path)
      end
      return joined.to_s
    end
# Creates a absolute URI-string for referenced resources in base file name
#
# @param [String, URI] base_filename_or_uri from where the resource is linked
# @param [String] path of the resource (relative or absolute) within the parent resource
# @return [String] URI-string
#

Creates a absolute URI-string for referenced resources in base file name
Creates a absolute URI - string for referenced resources in base file name
def join_uri(base_filename_or_uri, path)
      stream = ""
      begin
        stream = open(base_filename_or_uri)
      rescue => ex
        print "!I1".colorize(:red)
        print " \"#{ex}\" ".gsub("\n", " ").gsub("\r", " ").colorize(:yellow)
        sleep(3.seconds)
        begin
          stream = open(base_filename_or_uri)
        rescue => ex
          print "!I2".colorize(:red)
          print " \"#{ex}\" ".gsub("\n", " ").gsub("\r", " ").colorize(:yellow)
          sleep(10.seconds)
          stream = open(base_filename_or_uri)
        end
      end
      joined = ""
      if stream.is_a? File
        base_filename_or_uri = base_filename_or_uri.path if base_filename_or_uri.is_a? File
        windows_drive_matcher = /((.*):\/)/
        windows_drive_match_data = base_filename_or_uri.match windows_drive_matcher
        if windows_drive_match_data
          base_filename_or_uri = base_filename_or_uri.gsub(windows_drive_matcher,'WINDOWS.DRIVE/')
        end
        joined = URI::join("file://#{base_filename_or_uri}", path)
        joined = joined.to_s.gsub('file://','').gsub('file:','')
        if windows_drive_match_data
          joined = joined.gsub('WINDOWS.DRIVE/',windows_drive_match_data[1])
        end
      else
        joined = URI::join(base_filename_or_uri, path)
      end
      return joined.to_s
    end
def join_uri ( base_filename_or_uri , path ) stream = "" begin stream = open ( base_filename_or_uri ) rescue => ex print "!I1" . colorize ( :red ) print " \"#{ex}\" " . gsub ( "\n" , " " ) . gsub ( "\r" , " " ) . colorize ( :yellow ) sleep ( 3 . seconds ) begin stream = open ( base_filename_or_uri ) rescue => ex print "!I2" . colorize ( :red ) print " \"#{ex}\" " . gsub ( "\n" , " " ) . gsub ( "\r" , " " ) . colorize ( :yellow ) sleep ( 10 . seconds ) stream = open ( base_filename_or_uri ) end end joined = "" if stream . is_a? File base_filename_or_uri = base_filename_or_uri . path if base_filename_or_uri . is_a? File windows_drive_matcher = / ((.*): \/ ) / windows_drive_match_data = base_filename_or_uri . match windows_drive_matcher if windows_drive_match_data base_filename_or_uri = base_filename_or_uri . gsub ( windows_drive_matcher , 'WINDOWS.DRIVE/' ) end joined = URI :: join ( "file://#{base_filename_or_uri}" , path ) joined = joined . to_s . gsub ( 'file://' , '' ) . gsub ( 'file:' , '' ) if windows_drive_match_data joined = joined . gsub ( 'WINDOWS.DRIVE/' , windows_drive_match_data [ 1 ] ) end else joined = URI :: join ( base_filename_or_uri , path ) end return joined . to_s end
Creates a absolute URI-string for referenced resources in base file name
Creates a absolute URI - string for referenced resources in base file name
None
String
base_filename_or_uri
path
path of the resource (relative or absolute) within the parent resource
path of the resource ( relative or absolute ) within the parent resource