font_awesome_rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.gitignore +18 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +2 -0
  4. data/LICENSE.md +26 -0
  5. data/README.md +69 -0
  6. data/Rakefile +6 -0
  7. data/app/assets/stylesheets/_font-awesome.scss +2 -0
  8. data/app/assets/stylesheets/font-awesome/_font.scss +13 -0
  9. data/app/assets/stylesheets/font-awesome/_icons.scss +210 -0
  10. data/app/assets/stylesheets/font-awesome/_mixins.scss +58 -0
  11. data/app/assets/stylesheets/font-awesome/_styles.scss +53 -0
  12. data/font_awesome_rails.gemspec +25 -0
  13. data/lib/font_awesome/font.rb +52 -0
  14. data/lib/font_awesome/hex_code.rb +39 -0
  15. data/lib/font_awesome/icon.rb +80 -0
  16. data/lib/font_awesome/nokogiri.rb +17 -0
  17. data/lib/font_awesome/sass_extensions/functions.rb +26 -0
  18. data/lib/font_awesome/sass_extensions.rb +6 -0
  19. data/lib/font_awesome.rb +10 -0
  20. data/lib/font_awesome_rails/engine.rb +4 -0
  21. data/lib/font_awesome_rails/version.rb +3 -0
  22. data/lib/font_awesome_rails.rb +10 -0
  23. data/spec/font_awesome/font_spec.rb +103 -0
  24. data/spec/font_awesome/hex_code_spec.rb +66 -0
  25. data/spec/font_awesome/icon_spec.rb +92 -0
  26. data/spec/font_awesome/sass_extensions/functions_spec.rb +69 -0
  27. data/spec/spec_helper.rb +14 -0
  28. data/spec/tasks/update_classic_sass_task_spec.rb +33 -0
  29. data/spec/tasks/update_hex_codes_task_spec.rb +44 -0
  30. data/spec/tasks/update_metrics_task_spec.rb +34 -0
  31. data/spec/tasks/update_sass_task_spec.rb +20 -0
  32. data/tasks/gem_dir.rb +12 -0
  33. data/tasks/spec.rake +3 -0
  34. data/tasks/task.rb +5 -0
  35. data/tasks/update/classic.rake +27 -0
  36. data/tasks/update/font.rake +13 -0
  37. data/tasks/update/font_awesome.rake +20 -0
  38. data/tasks/update/hex_codes.rake +9 -0
  39. data/tasks/update/metrics.rake +8 -0
  40. data/tasks/update/metrics.rb +62 -0
  41. data/tasks/update/sass.rake +6 -0
  42. data/tasks/update/update_classic_sass_task.rb +21 -0
  43. data/tasks/update/update_hex_codes_task.rb +34 -0
  44. data/tasks/update/update_metrics_task.rb +25 -0
  45. data/tasks/update/update_sass_task.rb +20 -0
  46. data/tasks/update.rake +8 -0
  47. data/vendor/assets/font/fontawesome-webfont.eot +0 -0
  48. data/vendor/assets/font/fontawesome-webfont.svg +255 -0
  49. data/vendor/assets/font/fontawesome-webfont.ttf +0 -0
  50. data/vendor/assets/font/fontawesome-webfont.woff +0 -0
  51. data/vendor/assets/stylesheets/font-awesome/_classic.scss +292 -0
  52. data/vendor/assets/stylesheets/font-awesome/ie7.css +645 -0
  53. metadata +225 -0
@@ -0,0 +1,17 @@
1
+ module FontAwesome
2
+ module Nokogiri
3
+ extend self
4
+
5
+ def raise_exception
6
+ raise LoadError, %{Nokogiri is required to use this feature -- please add "gem 'nokogiri'" to your Gemfile and run "bundle install"}
7
+ end
8
+
9
+ def method_missing(method, *args)
10
+ raise_exception
11
+ end
12
+
13
+ def const_missing(const)
14
+ raise_exception
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ require 'active_support/concern'
2
+
3
+ module FontAwesome
4
+ module SassExtensions
5
+ module Functions
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ declare :icon_image, [:name]
10
+ declare :icon_image, [:name, :style]
11
+ end
12
+
13
+ def icon_image(name, style=nil)
14
+ assert_type name, :String
15
+ icon = Icon.new(name.value)
16
+
17
+ unless style.nil?
18
+ assert_type style, :String
19
+ icon.style = style.value
20
+ end
21
+
22
+ Sass::Script::String.new icon.to_uri, :string
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ require "sass"
2
+ require "font_awesome/sass_extensions/functions"
3
+
4
+ module Sass::Script::Functions
5
+ include FontAwesome::SassExtensions::Functions
6
+ end
@@ -0,0 +1,10 @@
1
+ begin
2
+ require "nokogiri"
3
+ rescue LoadError
4
+ require "font_awesome/nokogiri"
5
+ end
6
+
7
+ require "font_awesome/font"
8
+ require "font_awesome/hex_code"
9
+ require "font_awesome/icon"
10
+ require "font_awesome/sass_extensions"
@@ -0,0 +1,4 @@
1
+ module FontAwesomeRails
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module FontAwesomeRails
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,10 @@
1
+ require "font_awesome_rails/version"
2
+ require "font_awesome_rails/engine" if defined?(Rails)
3
+
4
+ require "font_awesome"
5
+
6
+ module FontAwesomeRails
7
+ def self.root
8
+ File.expand_path "../..", __FILE__
9
+ end
10
+ end
@@ -0,0 +1,103 @@
1
+ require "spec_helper"
2
+
3
+ describe FontAwesome::Font do
4
+ subject(:font) { FontAwesome::Font.send :new }
5
+ before { FontAwesome::Font.stubs(:instance).returns(font) }
6
+
7
+ let(:hex_code) { stub("HexCode", to_unicode: "\uf00d") }
8
+
9
+ it "should be a singleton" do
10
+ expect{FontAwesome::Font.new}.to raise_error NoMethodError
11
+ end
12
+
13
+ describe "#svg" do
14
+ it "loads the webfont" do
15
+ Nokogiri.expects(:XML).with{|file| file.path == font.send(:path)}.returns(:parsed_xml)
16
+ font.send(:svg).should == :parsed_xml
17
+ end
18
+
19
+ it "memoizes" do
20
+ File.expects(:open).once.returns(:parsed_xml)
21
+ font.send(:svg)
22
+ font.send(:svg)
23
+ end
24
+ end
25
+
26
+ describe "#select" do
27
+ it "finds the first node in the webfont matching the given CSS selector" do
28
+ font.stubs(:svg).returns(mock{expects(:at_css).with("something")})
29
+ font.send(:select, "something")
30
+ end
31
+ end
32
+
33
+ describe "#attribute" do
34
+ let(:xml) { Nokogiri.XML('<pizza topping="meatlovers" />') }
35
+
36
+ before { font.stubs(:svg).returns(xml) }
37
+
38
+ context "when the attribute exists" do
39
+ it "returns its value" do
40
+ font.send(:attribute, "topping", "pizza").should == "meatlovers"
41
+ end
42
+ end
43
+
44
+ context "when the attribute does not exist" do
45
+ it "returns nil" do
46
+ font.send(:attribute, "base", "pizza").should be_nil
47
+ end
48
+ end
49
+ end
50
+
51
+ describe "#glyph" do
52
+ it "returns a selector for the specified character" do
53
+ font.send(:glyph, hex_code).should == "glyph[unicode=\uf00d]"
54
+ end
55
+ end
56
+
57
+ describe "#ascent" do
58
+ it "returns the ascent height" do
59
+ font.ascent.should > 0
60
+ end
61
+ end
62
+
63
+ describe "#descent" do
64
+ it "returns the descent height" do
65
+ font.descent.should < 0
66
+ end
67
+ end
68
+
69
+ describe "#em_size" do
70
+ it "returns the number of units per em" do
71
+ font.stubs(:attribute).with("units-per-em", "font-face").returns("2048")
72
+ font.em_size.should == 2048
73
+ end
74
+ end
75
+
76
+ describe "#character_width" do
77
+ before { font.stubs(:attribute).with("horiz-adv-x", "glyph[unicode=\uf00d]").returns(glyph_horiz_adv_x) }
78
+
79
+ context "when the glyph has its own horiz-adv-x" do
80
+ let(:glyph_horiz_adv_x) { "1542" }
81
+
82
+ it "returns it" do
83
+ font.character_width(hex_code).should == 1542
84
+ end
85
+ end
86
+
87
+ context "when the glyph does not have its own horiz-adv-x" do
88
+ let(:glyph_horiz_adv_x) { nil }
89
+
90
+ it "returns the font's horiz-adv-x" do
91
+ font.stubs(:attribute).with("horiz-adv-x", "font").returns("1536")
92
+ font.character_width(hex_code).should == 1536
93
+ end
94
+ end
95
+ end
96
+
97
+ describe "#character_outline" do
98
+ it "returns the glyph's path" do
99
+ font.stubs(:attribute).with("d", "glyph[unicode=\uf00d]").returns("M0 0z")
100
+ font.character_outline(hex_code).should == "M0 0z"
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,66 @@
1
+ require "spec_helper"
2
+
3
+ describe FontAwesome::HexCode do
4
+ subject(:hex_code) { FontAwesome::HexCode.new(name) }
5
+ let(:name) { :pizza }
6
+ before { FontAwesome::HexCode.stubs(:lookup_table).returns({"pizza" => "f00d"}) }
7
+
8
+ describe ".new" do
9
+ it "sets the name" do
10
+ FontAwesome::HexCode.any_instance.expects(:name=).with(:foo)
11
+ FontAwesome::HexCode.new(:foo)
12
+ end
13
+ end
14
+
15
+ describe "#name=" do
16
+ it "stringifies and dasherizes the name" do
17
+ ["some-icon", "some_icon", :some_icon].each do |value|
18
+ hex_code.name = value
19
+ hex_code.name.should == "some-icon"
20
+ end
21
+ end
22
+ end
23
+
24
+ describe "#to_s" do
25
+ it "looks up the name in the lookup table" do
26
+ FontAwesome::HexCode.expects(:lookup_table).returns(mock{expects(:[]).with("pizza").returns("f00d")})
27
+ hex_code.to_s.should == "f00d"
28
+ end
29
+ end
30
+
31
+ describe "#to_unicode" do
32
+ it "unicode-escapes the hex code" do
33
+ hex_code.to_unicode.should == "\uf00d"
34
+ end
35
+ end
36
+
37
+ describe "#to_css" do
38
+ it "css-escapes the hex code" do
39
+ hex_code.to_css.should == '\f00d'
40
+ end
41
+ end
42
+
43
+ describe "#to_xml" do
44
+ it "xml-escapes the hex code" do
45
+ hex_code.to_xml.should == "&#xf00d;"
46
+ end
47
+ end
48
+
49
+ describe ".all" do
50
+ it "returns an enumerator for the lookup table" do
51
+ FontAwesome::HexCode.all.to_a.should == FontAwesome::HexCode.lookup_table.each.to_a
52
+ end
53
+ end
54
+
55
+ describe ".lookup_table" do
56
+ subject(:lookup_table) { FontAwesome::HexCode.lookup_table }
57
+
58
+ before { FontAwesome::HexCode.unstub :lookup_table}
59
+
60
+ it { should be_a Hash }
61
+
62
+ it "translates icon names to hex codes" do
63
+ lookup_table["glass"].should == "f000"
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,92 @@
1
+ require "spec_helper"
2
+
3
+ describe FontAwesome::Icon do
4
+ subject { icon }
5
+ let(:icon) { FontAwesome::Icon.new("pizza") }
6
+ let(:font) { FontAwesome::Font.instance }
7
+
8
+ describe ".new" do
9
+ it "sets the hex code" do
10
+ FontAwesome::Icon.new("foo").hex_code.name.should == "foo"
11
+ end
12
+
13
+ it "defaults the style" do
14
+ FontAwesome::Icon.any_instance.stubs(:default_style).returns("fill:red")
15
+ FontAwesome::Icon.new("foo").style.should == "fill:red"
16
+ end
17
+
18
+ it "sets the font" do
19
+ FontAwesome::Icon.new("foo").font.should == font
20
+ end
21
+ end
22
+
23
+ describe "#to_svg" do
24
+ subject { to_svg }
25
+ let(:to_svg) { icon.to_svg }
26
+ let(:xml) { Nokogiri.XML to_svg }
27
+
28
+ before do
29
+ icon.stubs(:offset_x).returns(256)
30
+ icon.stubs(:offset_y).returns(1792)
31
+ icon.stubs(:path).returns("M0 0z")
32
+ icon.stubs(:style).returns("fill:blue")
33
+ font.stubs(:em_size).returns(2048)
34
+ end
35
+
36
+ it { should_not include "\n" }
37
+ it { should_not include "<?xml" }
38
+
39
+ it "is valid XML" do
40
+ xml.should have(0).errors
41
+ end
42
+
43
+ it "contains an SVG image" do
44
+ xml.root.name.should == "svg"
45
+ end
46
+
47
+ describe "returned SVG image" do
48
+ subject { svg }
49
+ let(:svg) { xml.root }
50
+
51
+ it "has the correct xml namespace" do
52
+ svg.namespace.href.should == "http://www.w3.org/2000/svg"
53
+ svg.namespace.prefix.should be_nil
54
+ end
55
+
56
+ its(["version"]) { should == "1.1" }
57
+
58
+ its(["width"]) { should == "100px" }
59
+ its(["height"]) { should == "100px" }
60
+ its(["viewBox"]) { should == "-256 -1792 2048 2048" }
61
+
62
+ it { should have(1).children }
63
+
64
+ describe "path" do
65
+ subject { path }
66
+ let(:path) { svg.child }
67
+
68
+ its(:name) { should == "path" }
69
+ its(["d"]) { should == "M0 0z" }
70
+ its(["style"]) { should == "fill:blue" }
71
+ its(["transform"]) { should == "rotate(180) scale(-1,1)" }
72
+ end
73
+ end
74
+ end
75
+
76
+ describe "#to_uri" do
77
+ it "returns a data-uri for the SVG image" do
78
+ icon.expects(:to_svg).returns("a bunch of xml")
79
+ icon.to_uri.should == "data:image/svg+xml,a%20bunch%20of%20xml"
80
+ end
81
+ end
82
+
83
+ describe ".all" do
84
+ it "returns an array of all icons" do
85
+ FontAwesome::HexCode.stubs(:lookup_table).returns({"pizza" => "f00d", "linux" => "f055"})
86
+ FontAwesome::Icon.expects(:new).with("pizza").returns(:pizza)
87
+ FontAwesome::Icon.expects(:new).with("linux").returns(:linux)
88
+
89
+ FontAwesome::Icon.all.should == [:pizza, :linux]
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ describe FontAwesome::SassExtensions::Functions do
4
+ class EvaluationContext
5
+ def self.declare(*args)
6
+ declarations << args
7
+ end
8
+
9
+ def self.declarations
10
+ @declarations ||= []
11
+ end
12
+
13
+ def assert_type(*args)
14
+ end
15
+
16
+ include FontAwesome::SassExtensions::Functions
17
+ end
18
+
19
+ let(:functions) { EvaluationContext.new }
20
+
21
+ it "declares icon-image($name)" do
22
+ EvaluationContext.declarations.should include [:icon_image, [:name]]
23
+ end
24
+
25
+ it "declares icon-image($name, $style)" do
26
+ EvaluationContext.declarations.should include [:icon_image, [:name, :style]]
27
+ end
28
+
29
+ describe "icon-image($name)" do
30
+ subject(:icon_image) { functions.icon_image(name) }
31
+ let(:name) { Sass::Script::String.new("foo") }
32
+ let(:icon) { stub("Icon", to_uri: "uri") }
33
+
34
+ before { FontAwesome::Icon.stubs(:new).with("foo").returns(icon) }
35
+
36
+ it "requires that $name be a string" do
37
+ functions.expects(:assert_type).with(name, :String)
38
+ icon_image
39
+ end
40
+
41
+ it "returns a data-uri representation of the icon" do
42
+ icon_image.should == Sass::Script::String.new("uri")
43
+ end
44
+ end
45
+
46
+ describe "icon-image($name, $style)" do
47
+ subject(:icon_image) { functions.icon_image(name, style) }
48
+ let(:name) { Sass::Script::String.new("foo") }
49
+ let(:style) { Sass::Script::String.new("fill:blue") }
50
+ let(:icon) { stub("Icon", :style= => nil, to_uri: "uri") }
51
+
52
+ before { FontAwesome::Icon.stubs(:new).with("foo").returns(icon) }
53
+
54
+ it "requires that $name and $style be strings" do
55
+ functions.expects(:assert_type).with(name, :String)
56
+ functions.expects(:assert_type).with(style, :String)
57
+ icon_image
58
+ end
59
+
60
+ it "sets the icon style" do
61
+ icon.expects(:style=).with("fill:blue")
62
+ icon_image
63
+ end
64
+
65
+ it "returns a data-uri representation of the icon" do
66
+ icon_image.should == Sass::Script::String.new("uri")
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,14 @@
1
+ require "bundler/setup"
2
+ require "font_awesome_rails"
3
+
4
+ Dir[File.expand_path("../tasks/**/*.rb", File.dirname(__FILE__))].each {|task| require task }
5
+
6
+ RSpec.configure do |config|
7
+ config.treat_symbols_as_metadata_keys_with_true_values = true
8
+ config.run_all_when_everything_filtered = true
9
+ config.filter_run :focus
10
+
11
+ config.order = "random"
12
+
13
+ config.mock_with :mocha
14
+ end
@@ -0,0 +1,33 @@
1
+ require "spec_helper"
2
+
3
+ describe UpdateClassicSassTask do
4
+ subject(:task) { UpdateClassicSassTask.new }
5
+
6
+ describe "#contents" do
7
+ it "returns the Font Awesome scss" do
8
+ task.expects(:open_file).with("Font-Awesome/sass/font-awesome.scss").returns("scss code")
9
+ task.contents.should == "scss code"
10
+ end
11
+ end
12
+
13
+ describe "#styles" do
14
+ it "returns the Font Awesome styles excluding the @font-face declaration" do
15
+ contents = task.contents.lines.to_a
16
+ styles = task.styles.lines.to_a
17
+
18
+ styles.first.should == "/* Font Awesome styles\n"
19
+ styles.should == contents.last(styles.length)
20
+ end
21
+ end
22
+
23
+ describe "#run" do
24
+ it "copies classic Font Awesome styles" do
25
+ task.stubs(:puts)
26
+ task.stubs(:styles).returns("classic styles")
27
+ task.expects(:open_file).with("vendor/assets/stylesheets/font-awesome/_classic.scss", "w").yields(mock{
28
+ expects(:write).with("classic styles")
29
+ })
30
+ task.run
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,44 @@
1
+ require "spec_helper"
2
+
3
+ describe UpdateHexCodesTask do
4
+ subject(:task) { UpdateHexCodesTask.new }
5
+
6
+ describe "#hex_code_class" do
7
+ it "returns the source code for FontAwesome::HexCode" do
8
+ task.expects(:open_file).with("lib/font_awesome/hex_code.rb").returns("source code")
9
+ task.hex_code_class.should == "source code"
10
+ end
11
+ end
12
+
13
+ describe "#css" do
14
+ it "returns the Font Awesome css styles" do
15
+ task.expects(:open_file).with("Font-Awesome/css/font-awesome.css").returns("css rules")
16
+ task.css.should == "css rules"
17
+ end
18
+ end
19
+
20
+ describe "#hex_codes" do
21
+ it "extracts the hex code lookup table from the css" do
22
+ task.hex_codes.should have_at_least(200).keys
23
+ task.hex_codes["glass"].should == "f000"
24
+ end
25
+ end
26
+
27
+ describe "#updated_hex_code_class" do
28
+ it "replaces the hex code lookup table in FontAwesome::HexCode" do
29
+ task.stubs(:hex_codes).returns({"pizza" => "f00d", "linux" => "f055"})
30
+ diff = task.updated_hex_code_class.lines.to_a - task.hex_code_class.lines.to_a
31
+ diff.should have(1).item
32
+ diff.first.should include 'HEX_CODES = {"pizza"=>"f00d", "linux"=>"f055"}'
33
+ end
34
+ end
35
+
36
+ describe "#run" do
37
+ it "writes the updated source code" do
38
+ task.stubs(:puts)
39
+ task.stubs(:updated_hex_code_class).returns("updated source code")
40
+ task.expects(:open_file).with("lib/font_awesome/hex_code.rb", "w").yields(mock{expects(:write).with("updated source code")})
41
+ task.run
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,34 @@
1
+ require "spec_helper"
2
+
3
+ describe UpdateMetricsTask do
4
+ subject(:task) { UpdateMetricsTask.new }
5
+
6
+ describe "#font_class" do
7
+ it "returns the source code for FontAwesome::Font" do
8
+ task.expects(:open_file).with("lib/font_awesome/font.rb").returns("source code")
9
+ task.font_class.should == "source code"
10
+ end
11
+ end
12
+
13
+ describe "#updated_font_class" do
14
+ it "replaces the ascent and descent constants in FontAwesome::Font" do
15
+ Metrics.stubs(:ascent).returns(1234)
16
+ Metrics.stubs(:descent).returns(-567)
17
+ diff = task.updated_font_class.lines.to_a - task.font_class.lines.to_a
18
+ diff.should have(2).items
19
+ diff.first.should include 'ASCENT = 1234'
20
+ diff.last.should include 'DESCENT = -567'
21
+ end
22
+ end
23
+
24
+ describe "#run" do
25
+ it "writes the updated source code" do
26
+ task.stubs(:puts)
27
+ task.stubs(:updated_font_class).returns("updated source code")
28
+ task.expects(:open_file).with("lib/font_awesome/font.rb", "w").yields(mock{
29
+ expects(:write).with("updated source code")
30
+ })
31
+ task.run
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,20 @@
1
+ require "spec_helper"
2
+
3
+ describe UpdateSassTask do
4
+ subject(:task) { UpdateSassTask.new }
5
+
6
+ def mock_icon(name, hex_code)
7
+ stub(name: name, hex_code: stub(to_css: "\\#{hex_code}"))
8
+ end
9
+
10
+ describe "#run" do
11
+ it "writes scss placeholders for icon content" do
12
+ task.stubs(:puts)
13
+ FontAwesome::Icon.stubs(:all).returns([mock_icon("pizza", "f00d"), mock_icon("linux", "f055")])
14
+ task.expects(:open_file).with("app/assets/stylesheets/font-awesome/_icons.scss", "w").yields(mock{
15
+ expects(:write).with("%icon-pizza { content: '\\f00d'; }\n%icon-linux { content: '\\f055'; }\n")
16
+ })
17
+ task.run
18
+ end
19
+ end
20
+ end
data/tasks/gem_dir.rb ADDED
@@ -0,0 +1,12 @@
1
+ module GemDir
2
+ extend self
3
+
4
+ def expand_path(relative_path)
5
+ File.expand_path("../#{relative_path}", File.dirname(__FILE__))
6
+ end
7
+
8
+ def open_file(relative_path, mode="r", &block)
9
+ block = ->(file) { file.read } unless block_given?
10
+ File.open(expand_path(relative_path), mode, &block)
11
+ end
12
+ end
data/tasks/spec.rake ADDED
@@ -0,0 +1,3 @@
1
+ require "rspec/core/rake_task"
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
data/tasks/task.rb ADDED
@@ -0,0 +1,5 @@
1
+ require_relative "gem_dir"
2
+
3
+ class Task
4
+ include GemDir
5
+ end
@@ -0,0 +1,27 @@
1
+ namespace :update do
2
+
3
+ desc "Copy classic Font Awesome styles"
4
+ task :classic => "classic:all"
5
+
6
+ namespace :classic do
7
+
8
+ task :all => ["font_awesome:download", :sass, :ie7]
9
+
10
+ task :sass do
11
+ require_relative "update_classic_sass_task"
12
+ UpdateClassicSassTask.new.run
13
+ end
14
+
15
+ task :ie7 do
16
+ require "fileutils"
17
+
18
+ source = "Font-Awesome/css/font-awesome-ie7.css"
19
+ destination = "vendor/assets/stylesheets/font-awesome/ie7.css"
20
+
21
+ puts "* Updating #{destination}"
22
+ FileUtils.cp GemDir.expand_path(source), GemDir.expand_path(destination)
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,13 @@
1
+ namespace :update do
2
+
3
+ desc "Transfer font files to vendor/assets"
4
+ task :font => "font_awesome:download" do
5
+ require "fileutils"
6
+
7
+ source = "Font-Awesome/font"
8
+ destination = "vendor/assets/font"
9
+
10
+ puts "* Copying fonts to #{destination}"
11
+ FileUtils.cp_r "#{GemDir.expand_path(source)}/.", GemDir.expand_path(destination)
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ namespace :update do
2
+
3
+ desc "Update Font Awesome"
4
+ task :font_awesome => "font_awesome:download" do
5
+ puts "* Updating Font Awesome repo"
6
+ system("cd Font-Awesome && git pull")
7
+ end
8
+
9
+ namespace :font_awesome do
10
+
11
+ desc "Download Font Awesome"
12
+ task :download do
13
+ unless File.exists?(GemDir.expand_path("Font-Awesome"))
14
+ puts "* Cloning Font Awesome repo"
15
+ system("git clone git://github.com/FortAwesome/Font-Awesome.git")
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,9 @@
1
+ namespace :update do
2
+
3
+ desc "Generate FontAwesome::HexCode.HEX_CODES"
4
+ task :hex_codes => "font_awesome:download" do
5
+ require_relative "update_hex_codes_task"
6
+ UpdateHexCodesTask.new.run
7
+ end
8
+
9
+ end
@@ -0,0 +1,8 @@
1
+ namespace :update do
2
+
3
+ desc "Update font metrics"
4
+ task :metrics do
5
+ require_relative "update_metrics_task"
6
+ UpdateMetricsTask.new.run
7
+ end
8
+ end