diff --git a/bin/fontello b/bin/fontello index e679a0e..b3aba21 100755 --- a/bin/fontello +++ b/bin/fontello @@ -19,7 +19,9 @@ def set_options_based_on_rails_root(options) zip_file: "#{options[:rails_root_dir]}/tmp/fontello.zip", config_file: "#{options[:asset_dir]}/fonts/config.json", fontello_session_id_file: "#{options[:rails_root_dir]}/tmp/fontello_session_id", - options_file: "#{options[:rails_root_dir]}/config/fontello_rails_converter.yml" + options_file: "#{options[:rails_root_dir]}/config/fontello_rails_converter.yml", + assets_prefix_css: "/assets", + assets_prefix_fonts: "/assets" }) end diff --git a/lib/fontello_rails_converter/cli.rb b/lib/fontello_rails_converter/cli.rb index 56b2b42..cdb297f 100644 --- a/lib/fontello_rails_converter/cli.rb +++ b/lib/fontello_rails_converter/cli.rb @@ -160,14 +160,14 @@ def copy_icon_guide(zipfile, demo_file) def convert_icon_guide content = File.read(icon_guide_target_file) File.open(icon_guide_target_file, 'w') do |f| - f.write self.class.convert_icon_guide_html(content) + f.write convert_icon_guide_html(content) end puts green("Converted demo.html for asset pipeline: #{icon_guide_target_file}") end - def self.convert_icon_guide_html(content) - content.gsub! /css\//, "/assets/" - content.gsub! "url('./font/", "url('/assets/" + def convert_icon_guide_html(content) + content.gsub! /css\//, "#{@options[:assets_prefix_css]}/" + content.gsub! "url('./font\/", "url('#{@options[:assets_prefix_fonts]}/" end def config_file_exists? diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 2db87fe..65a0d96 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -1,18 +1,23 @@ require 'spec_helper' describe FontelloRailsConverter::Cli do - let(:cli) { described_class.new({ - config_file: 'spec/fixtures/fontello/config.json', - stylesheet_dir: 'vendor/assets/stylesheets' - }) + let(:options) {{ + config_file: 'spec/fixtures/fontello/config.json', + stylesheet_dir: 'vendor/assets/stylesheets' + }} + let(:cli) { described_class.new(options) } - describe '.convert_icon_guide_html' do + describe '#convert_icon_guide_html' do let(:content) { File.read('spec/fixtures/fontello-demo.html') } let(:converted_content) { File.read('spec/fixtures/converted/fontello-demo.html') } + let(:options){{ + assets_prefix_css: '/assets', + assets_prefix_fonts: '/assets' + }} specify do - expect(described_class.convert_icon_guide_html(content)).to eql converted_content + expect(cli.send(:convert_icon_guide_html, content)).to eql converted_content end end