Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets prefix #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bin/fontello
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions lib/fontello_rails_converter/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
17 changes: 11 additions & 6 deletions spec/cli_spec.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down