Class: Staticfy::Handlers::CSS
- Defined in:
- lib/staticfy/handlers/css.rb
Constant Summary collapse
- URL_PATTERN =
/url\s*\(['"]?(.+?)['"]?\)/
Instance Method Summary collapse
Methods inherited from Base
#initialize, #local_uri, #method_missing
Constructor Details
This class inherits a constructor from Staticfy::Handlers::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Staticfy::Handlers::Base
Instance Method Details
#fetch_links ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/staticfy/handlers/css.rb', line 26 def fetch_links links = [] body.scan(URL_PATTERN) do |url| url = url[0] next if url.empty? abs = to_absolute(URI(url)) if in_domain?(abs) links << abs end end links end |
#local_body ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/staticfy/handlers/css.rb', line 42 def local_body body.gsub(URL_PATTERN) do |url| parts = url.match(URL_PATTERN) next if url.empty? abs = to_absolute(URI(parts[1])) if in_domain?(abs) local = Staticfy::Handlers.local_uri(abs).to_s "url('#{local}')" else url end end end |