Module: Sprockets::Svg
- Extended by:
- Svg
- Included in:
- Svg
- Defined in:
- lib/sprockets/svg.rb,
lib/sprockets/svg/server.rb,
lib/sprockets/svg/cleaner.rb,
lib/sprockets/svg/version.rb,
lib/sprockets/svg/proxy_asset.rb,
lib/sprockets/svg/sass_functions.rb
Defined Under Namespace
Modules: SassFunctions, Server Classes: Cleaner, ProxyAsset
Constant Summary collapse
- VERSION =
'0.4.2'
Class Method Summary collapse
-
.convert(svg_path, png_path) ⇒ Object
TODO: integrate svgo instead: github.com/svg/svgo See github.com/lautis/uglifier on how to integrate a npm package as a gem.
- .image?(path) ⇒ Boolean
- .png_path(svg_path) ⇒ Object
Instance Method Summary collapse
Class Method Details
.convert(svg_path, png_path) ⇒ Object
TODO: integrate svgo instead: github.com/svg/svgo See github.com/lautis/uglifier on how to integrate a npm package as a gem.
12 13 14 15 |
# File 'lib/sprockets/svg.rb', line 12 def self.convert(svg_path, png_path) image = Magick::ImageList.new(svg_path) image.write(png_path) end |
.image?(path) ⇒ Boolean
17 18 19 20 21 22 23 |
# File 'lib/sprockets/svg.rb', line 17 def self.image?(path) return false unless path.ends_with?('.svg') document = Nokogiri::XML(File.read(path)) svg = document.css('svg') svg.attribute('height') && svg.attribute('width') end |
.png_path(svg_path) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/sprockets/svg.rb', line 25 def self.png_path(svg_path) if svg_path =~ /^(.*)\-([0-9a-f]{32})\.svg$/ "#{$1}.svg-#{$2}.png" else "#{svg_path}.png" end end |