class JS::RequireRemote::URLResolver

When require_relative is called within a running Ruby script, the URL is resolved from a relative file path based on the URL of the running Ruby script. It uses a stack to store URLs of running Ruby Script. Push the URL onto the stack before executing the new script. Then pop it when the script has finished executing.

Public Class Methods

new(base_url) click to toggle source
# File packages/gems/js/lib/js/require_remote/url_resolver.rb, line 11
def initialize(base_url)
  @url_stack = [base_url]
end

Public Instance Methods

get_location(relative_feature) click to toggle source
# File packages/gems/js/lib/js/require_remote/url_resolver.rb, line 15
def get_location(relative_feature)
  filename = filename_from(relative_feature)
  url = resolve(filename)
  ScriptLocation.new(url, filename)
end
pop() click to toggle source
# File packages/gems/js/lib/js/require_remote/url_resolver.rb, line 25
def pop()
  @url_stack.pop
end
push(url) click to toggle source
# File packages/gems/js/lib/js/require_remote/url_resolver.rb, line 21
def push(url)
  @url_stack.push url
end