font_awesome-sass-rails 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source :rubygems
2
2
 
3
3
  gem 'rails', '>= 3.1'
4
4
  gem 'compass', '>= 0.11'
data/README.md CHANGED
@@ -26,6 +26,21 @@ On IE7
26
26
  The assets contains the `font-awesome` stylesheet in: LESS, SASS, SCSS and CSS.
27
27
  The fonts are available in `assets/fonts`.
28
28
 
29
+ ## View helpers
30
+
31
+ ```ruby
32
+ awesome_icon name, *args, &block
33
+ ```
34
+
35
+ Usage examples:
36
+
37
+ ```ruby
38
+ awesome_icon(:ok).should == "<i class=\"icon-ok\"></i>"
39
+ awesome_icon(:ok, size: :large).should == "<i class=\"icon-ok icon-large\"></i>"
40
+ awesome_icon(:ok, 'Okay :)').should == "<i class=\"icon-ok\"></i>Okay :)"
41
+ awesome_icon(:ok) { 'Okay :)'}.should == "<i class=\"icon-ok\"></i>Okay :)"
42
+ ```
43
+
29
44
  ## Version
30
45
 
31
46
  Font Awesome 2.0 is currently included. Enjoy :)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.0.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "font_awesome-sass-rails"
8
- s.version = "2.0.1"
8
+ s.version = "2.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = "2012-09-03"
12
+ s.date = "2012-09-04"
13
13
  s.description = "Use Font Awesome in your Rails app :)"
14
14
  s.email = "kmandrup@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -30,6 +30,8 @@ Gem::Specification.new do |s|
30
30
  "lib/font_awesome-sass-rails.rb",
31
31
  "lib/font_awesome-sass/engine.rb",
32
32
  "lib/font_awesome-sass/version.rb",
33
+ "lib/font_awesome-sass/view_helper.rb",
34
+ "spec/font_awesome_sass/view_helper_spec.rb",
33
35
  "spec/spec_helper.rb",
34
36
  "vendor/assets/fonts/FontAwesome.ttf",
35
37
  "vendor/assets/fonts/fontawesome-webfont.eot",
@@ -1,3 +1,4 @@
1
+ require 'font_awesome-sass/view_helper'
1
2
  require 'font_awesome-sass/version'
2
3
  require 'font_awesome-sass/engine' if defined?(::Rails::Engine)
3
4
 
@@ -1,6 +1,9 @@
1
+ require 'font_awesome-sass/view_helper'
2
+
1
3
  module FontAwesomeSass
2
4
  module Rails
3
5
  class Engine < ::Rails::Engine
6
+ ActionView::Base.send :include, ::FontAwesomeSass::ViewHelper
4
7
  end
5
8
  end
6
9
  end
@@ -0,0 +1,16 @@
1
+ module FontAwesomeSass
2
+ module ViewHelper
3
+ def awesome_icon name, *args, &block
4
+ options = args.extract_options!
5
+ size = options[:size] if options
6
+ content = args.first unless args.blank?
7
+ content ||= capture(&block) if block_given?
8
+ content ||= ''
9
+
10
+ clazz = "icon-#{name}"
11
+ clazz << " icon-#{size}" if size.to_s == 'large'
12
+
13
+ content_tag(:i, nil, :class => clazz) + content.html_safe
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe FontAwesomeSass::ViewHelper do
4
+ include ControllerTestHelpers,
5
+ FontAwesomeSass::ViewHelper
6
+
7
+ describe ".awesome_icon :ok, 'Okay :)'" do
8
+ specify do
9
+ awesome_icon(:ok).should == "<i class=\"icon-ok\"></i>"
10
+ end
11
+ end
12
+
13
+ describe ".awesome_icon :ok, 'Okay :)'" do
14
+ specify do
15
+ awesome_icon(:ok, size: :large).should == "<i class=\"icon-ok icon-large\"></i>"
16
+ end
17
+ end
18
+
19
+ # <i class="icon-ok"></i>Okay :)
20
+ describe ".awesome_icon :ok, 'Okay :)'" do
21
+ specify do
22
+ awesome_icon(:ok, 'Okay :)').should == "<i class=\"icon-ok\"></i>Okay :)"
23
+ end
24
+ end
25
+
26
+ describe ".awesome_icon(:ok) {'Okay :)'}" do
27
+ specify do
28
+ awesome_icon(:ok) { 'Okay :)'}.should == "<i class=\"icon-ok\"></i>Okay :)"
29
+ end
30
+ end
31
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,42 @@
1
+ # coding: utf-8
2
+ require 'rubygems'
3
+ require 'rails'
4
+ require 'json'
5
+ require 'active_support'
6
+ require 'action_pack'
7
+ require 'action_view'
8
+ require 'action_controller'
9
+ require 'action_view/template'
10
+
1
11
  require 'rspec'
2
- require 'font-awesome-rails'
12
+ require 'font_awesome-sass-rails'
13
+
14
+ module ControllerTestHelpers
15
+
16
+ def self.included(base)
17
+ base.class_eval do
18
+
19
+ include ActionView::Helpers,
20
+ ActionView::Helpers::CaptureHelper,
21
+ ActionView::Helpers::JavaScriptHelper,
22
+ ActionView::Helpers::AssetTagHelper
23
+
24
+ # allow tabs.create to run by stubbing an output_buffer
25
+ attr_accessor :output_buffer
26
+ @output_buffer = ""
27
+
28
+ # stub content_for for testing
29
+ def content_for(name, content = nil, &block)
30
+ # this doesn't exist, and causes errors
31
+ @_content_for = {} unless defined? @_content_for
32
+ # we've got to initialize this, so we can concat to it
33
+ @_content_for[name] = '' if @_content_for[name].nil?
34
+ # now the rest is the same as in rails
35
+ content = capture(&block) if block_given?
36
+ @_content_for[name] << content if content
37
+ @_content_for[name] unless content
38
+ end
39
+ end
40
+ end
3
41
 
4
- RSpec.configure do |config|
5
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: font_awesome-sass-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-03 00:00:00.000000000 Z
12
+ date: 2012-09-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -160,6 +160,8 @@ files:
160
160
  - lib/font_awesome-sass-rails.rb
161
161
  - lib/font_awesome-sass/engine.rb
162
162
  - lib/font_awesome-sass/version.rb
163
+ - lib/font_awesome-sass/view_helper.rb
164
+ - spec/font_awesome_sass/view_helper_spec.rb
163
165
  - spec/spec_helper.rb
164
166
  - vendor/assets/fonts/FontAwesome.ttf
165
167
  - vendor/assets/fonts/fontawesome-webfont.eot
@@ -186,7 +188,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
186
188
  version: '0'
187
189
  segments:
188
190
  - 0
189
- hash: 2358890390228459109
191
+ hash: 1031219020780303374
190
192
  required_rubygems_version: !ruby/object:Gem::Requirement
191
193
  none: false
192
194
  requirements: