Module: Roadie::Utils

Defined in:
lib/roadie/utils.rb

Class Method Summary collapse

Class Method Details

.path_is_absolute?(path) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/roadie/utils.rb', line 4

def path_is_absolute?(path)
  # Ruby's URI is pretty unforgiving, but roadie aims to be. Don't involve
  # URI for URLs that's easy to determine to be absolute.
  # URLs starting with a scheme (http:, data:) are absolute.
  #
  # URLs that start with double slashes (//css/app.css) are also absolute
  # in modern browsers, but most email clients do not understand them.
  return true if path =~ %r{^(\w+:|//)}

  begin
    !URI.parse(path).relative?
  rescue URI::InvalidURIError => error
    raise InvalidUrlPath.new(path, error)
  end
end

.warn(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
# File 'lib/roadie/utils.rb', line 23

def warn(message)
  Kernel.warn("Roadie: #{message}")
end