Class: SassJSONVars::Importer
- Inherits:
-
Sass::Importers::Filesystem
- Object
- Sass::Importers::Filesystem
- SassJSONVars::Importer
- Defined in:
- lib/sass-json-vars/importer.rb
Instance Method Summary collapse
- #extensions ⇒ Object
- #find(name, options) ⇒ Object
- #find_relative(name, base, options) ⇒ Object
- #json?(name) ⇒ Boolean
- #sass_engine(uri, options) ⇒ Object
- #watched_file?(uri) ⇒ Boolean
Instance Method Details
#extensions ⇒ Object
10 11 12 |
# File 'lib/sass-json-vars/importer.rb', line 10 def extensions {'json' => :scss} end |
#find(name, options) ⇒ Object
18 19 20 |
# File 'lib/sass-json-vars/importer.rb', line 18 def find(name, ) super(name, ) if json? name end |
#find_relative(name, base, options) ⇒ Object
22 23 24 |
# File 'lib/sass-json-vars/importer.rb', line 22 def find_relative(name, base, ) super(name, base, ) if json? name end |
#json?(name) ⇒ Boolean
14 15 16 |
# File 'lib/sass-json-vars/importer.rb', line 14 def json?(name) File.extname(name) == '.json' end |
#sass_engine(uri, options) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sass-json-vars/importer.rb', line 26 def sass_engine(uri, ) json = JSON.parse(IO.read(uri)) variables = json.map do |name, value| output = _convert_to_sass(value); "$#{name}: #{output}" end Sass::Engine.new(variables.join("\n")) end |
#watched_file?(uri) ⇒ Boolean
6 7 8 |
# File 'lib/sass-json-vars/importer.rb', line 6 def watched_file?(uri) uri =~ /\.json$/ && uri.start_with?(root + File::SEPARATOR) end |