Class: IcomoonAsWell::Icomoon
- Inherits:
-
Object
- Object
- IcomoonAsWell::Icomoon
- Includes:
- FileHelper
- Defined in:
- lib/icomoon_as_well.rb
Instance Method Summary collapse
-
#initialize(path, target_dir, is_rails) ⇒ Icomoon
constructor
A new instance of Icomoon.
Methods included from FileHelper
#icomoon_dir, #parse_css, #put_files
Constructor Details
#initialize(path, target_dir, is_rails) ⇒ Icomoon
Returns a new instance of Icomoon.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/icomoon_as_well.rb', line 9 def initialize(path, target_dir, is_rails) @archive = Unzip.new(path) put_files(@archive.files, @archive.files.keys.map{|name| name if name =~ /^fonts\/(.+)$/}.compact, File.join(target_dir, "fonts", "Icomoon")) @icomoon_variables = parse_css(@archive.files["style.css"]) @icon_prefix = "icon" ["variables", "icons", "core", "mixins", "main"].each do |tpl| renderer = ::ERB.new File.read("#{File.dirname(__FILE__)}/icomoon_as_well/templates/#{tpl}.scss.erb") File.open(File.join(icomoon_dir(target_dir), "#{tpl}.scss"), "w"){|f| f.write(renderer.result(binding)) } end if is_rails && target_dir =~ /^(.+)\/app\/assets.*$/ app_dir = $1 put_files(@archive.files, ["selection.json"], File.join(app_dir, "doc")) else put_files(@archive.files, ["selection.json"], target_dir) end end |