Class: Sass::Importers::HTTP

Inherits:
Base
  • Object
show all
Defined in:
lib/remote-sass/importer.rb

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ HTTP

Returns a new instance of HTTP.



8
9
10
11
12
13
14
# File 'lib/remote-sass/importer.rb', line 8

def initialize root
  @root = URI.parse root

  unless scheme_allowed? @root
    raise ArgumentError, "Absolute HTTP URIs only"
  end
end

Instance Method Details

#find(uri, options) ⇒ Object



20
21
22
# File 'lib/remote-sass/importer.rb', line 20

def find uri, options
  _find @root + uri, options
end

#find_relative(uri, base, options) ⇒ Object



16
17
18
# File 'lib/remote-sass/importer.rb', line 16

def find_relative uri, base, options
  _find @root + base + uri, options
end

#key(uri, options) ⇒ Object



41
42
43
# File 'lib/remote-sass/importer.rb', line 41

def key(uri, options)
  [self.class.name, uri]
end

#mtime(uri, options) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/remote-sass/importer.rb', line 24

def mtime uri, options
  uri = URI.parse uri
  return unless scheme_allowed? uri
  Net::HTTP.start(uri.host, uri.port) do |http|
    response = http.head uri.request_uri

    if response.is_a?(Net::HTTPOK) && response['Last-Modified']
      Time.parse response['Last-Modified']
    elsif response.is_a? Net::HTTPOK
      # we must assume that it just changed
      Time.now
    else
      nil
    end
  end
end

#to_sObject



45
46
47
# File 'lib/remote-sass/importer.rb', line 45

def to_s
  @root.to_s
end