Class: Sass::Globbing::Importer
- Inherits:
-
Importers::Filesystem
- Object
- Importers::Filesystem
- Sass::Globbing::Importer
- Includes:
- Singleton
- Defined in:
- lib/sass/globbing/importer.rb
Constant Summary collapse
- GLOB =
/\*/
- SASS_EXTENSIONS =
{ ".sass" => :sass, ".scss" => :scss }
Instance Method Summary collapse
- #each_globbed_file(glob, base_pathname, options) ⇒ Object
- #find(name, options) ⇒ Object
- #find_relative(name, base, options) ⇒ Object
-
#initialize ⇒ Importer
constructor
A new instance of Importer.
- #key(name, options) ⇒ Object
- #mtime(name, options) ⇒ Object
- #sass_file?(filename) ⇒ Boolean
- #syntax(filename) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Importer
Returns a new instance of Importer.
15 16 17 |
# File 'lib/sass/globbing/importer.rb', line 15 def initialize super(".") end |
Instance Method Details
#each_globbed_file(glob, base_pathname, options) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/sass/globbing/importer.rb', line 47 def each_globbed_file(glob, base_pathname, ) Dir["#{base_pathname.dirname}/#{glob}"].sort.each do |filename| next if filename == [:filename] yield filename if sass_file?(filename) end end |
#find(name, options) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sass/globbing/importer.rb', line 35 def find(name, ) if [:filename] # globs must be relative if name =~ GLOB find_glob(name, [:filename], ) { "/* No files to import found in #{comment_safe(name)} */" } else super(name, ) end else nil end end |
#find_relative(name, base, options) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/sass/globbing/importer.rb', line 27 def find_relative(name, base, ) if name =~ GLOB find_glob(name, base, ) { nil } else super(name, base, ) end end |
#key(name, options) ⇒ Object
73 74 75 |
# File 'lib/sass/globbing/importer.rb', line 73 def key(name, ) ["Glob:" + File.dirname(File.(name)), File.basename(name)] end |
#mtime(name, options) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/sass/globbing/importer.rb', line 54 def mtime(name, ) if name =~ GLOB && [:filename] mtime = nil base_pathname = Pathname.new([:filename]) name_pathname = Pathname.new(name) if name_pathname.absolute? name = name_pathname.relative_path_from(base_pathname.dirname).to_s end each_globbed_file(name, base_pathname, ) do |p| if mtime.nil? mtime = File.mtime(p) else mtime = [mtime, File.mtime(p)].max end end mtime end end |
#sass_file?(filename) ⇒ Boolean
19 20 21 |
# File 'lib/sass/globbing/importer.rb', line 19 def sass_file?(filename) SASS_EXTENSIONS.has_key?(File.extname(filename.to_s)) end |
#syntax(filename) ⇒ Object
23 24 25 |
# File 'lib/sass/globbing/importer.rb', line 23 def syntax(filename) SASS_EXTENSIONS[File.extname(filename.to_s)] end |
#to_s ⇒ Object
77 78 79 |
# File 'lib/sass/globbing/importer.rb', line 77 def to_s "Sass::Globbing::Importer" end |