class Cyborg::Importer

Public Instance Methods

watched_file?(uri) click to toggle source
# File lib/cyborg/sass/importer.rb, line 50
def watched_file?(uri)
  !!(uri =~ /\.yml$/ &&
    uri.start_with?(root + File::SEPARATOR))
end

Protected Instance Methods

extensions() click to toggle source
# File lib/cyborg/sass/importer.rb, line 57
def extensions
  {'yml' => :scss}
end
yaml?(name) click to toggle source
# File lib/cyborg/sass/importer.rb, line 61
def yaml?(name)
  File.extname(name) == '.yml'
end

Private Instance Methods

_convert_to_sass(item) click to toggle source
# File lib/cyborg/sass/importer.rb, line 83
def _convert_to_sass(item)
  if item.is_a? Array
    _make_list(item)
  elsif item.is_a? Hash
    _make_map(item)
  else
    item.to_s
  end
end
_find(dir, name, options) click to toggle source
# File lib/cyborg/sass/importer.rb, line 67
def _find(dir, name, options)
  return unless yaml? name

  full_filename, syntax = Sass::Util.destructure(find_real_file(dir, name, options))
  return unless full_filename && File.readable?(full_filename)

  yaml       = SassParser.parse(full_filename)
  variables  = yaml.map { |key, value| "$#{key}: #{_convert_to_sass(value)};" }.join("\n")

  Sass::Engine.new(variables, options.merge(
      :filename => full_filename,
      :importer => self,
      :syntax   => :scss
  ))
end
_make_list(item) click to toggle source
# File lib/cyborg/sass/importer.rb, line 93
def _make_list(item)
  '(' + item.map { |i| _convert_to_sass(i) }.join(',') + ')'
end
_make_map(item) click to toggle source
# File lib/cyborg/sass/importer.rb, line 97
def _make_map(item)
  '(' + item.map {|key, value| key.to_s + ':' + _convert_to_sass(value) }.join(',') + ')'
end