tophat 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,22 +16,18 @@ module TopHat
16
16
  end
17
17
 
18
18
  def app_id
19
- output = @app_id ? tag(:meta, :property => 'fb:app_id', :content => @app_id) : ""
20
- output << '\n' unless output.blank?
21
- output
19
+ tag(:meta, :property => 'fb:app_id', :content => @app_id) + "\n".html_safe if @app_id
22
20
  end
23
21
 
24
22
  def admins
25
- output = @admins ? tag(:meta, :property => 'fb:admins', :content => [*@admins].join(',')) : ""
26
- output << '\n' unless output.blank?
27
- output
23
+ tag(:meta, :property => 'fb:admins', :content => [*@admins].join(',')) + "\n".html_safe if @admins
28
24
  end
29
25
 
30
26
  def render_graph_data
31
- output = ""
27
+ output = ActiveSupport::SafeBuffer.new
32
28
  @graph_data.each do |key, value|
33
29
  output << tag(:meta, :property => "og:#{key}", :content => value)
34
- output << '\n' if @graph_data.size > 1
30
+ output << "\n".html_safe if @graph_data.size > 1
35
31
  end
36
32
  output
37
33
  end
@@ -96,7 +92,7 @@ module TopHat
96
92
  else
97
93
  TopHat.current['open_graph_generator'] ||= OpenGraphGenerator.new
98
94
  TopHat.current['open_graph_generator'].merge(TopHat.current['open_graph_defaults'])
99
- output = ""
95
+ output = ActiveSupport::SafeBuffer.new
100
96
  output << TopHat.current['open_graph_generator'].app_id
101
97
  output << TopHat.current['open_graph_generator'].admins
102
98
  output << TopHat.current['open_graph_generator'].render_graph_data if TopHat.current['open_graph_generator'].has_graph_data?
@@ -76,9 +76,11 @@ module TopHat
76
76
 
77
77
  browser_version = version.blank? ? "" : " #{version}"
78
78
 
79
- output = "<!--[if #{operator}#{browser}#{browser_version}]>\n"
79
+ output = ActiveSupport::SafeBuffer.new("<!--[if #{operator}#{browser}#{browser_version}]>")
80
+ output << "\n".html_safe
80
81
  output << yield if block_given?
81
- output << "\n<![endif]-->"
82
+ output << "\n".html_safe
83
+ output << "<![endif]-->".html_safe
82
84
  end
83
85
 
84
86
  end
@@ -12,13 +12,13 @@ module TopHat
12
12
  end
13
13
 
14
14
  def render
15
- output = ""
15
+ output = ActiveSupport::SafeBuffer.new
16
16
  output << tag(:meta, :name => 'twitter:card', :value => @type)
17
17
  @card_data.each do |key, value|
18
- output << '\n'
18
+ output << "\n".html_safe
19
19
  output << tag(:meta, :name => "twitter:#{key}", :value => value)
20
20
  end
21
- output << '\n' unless @card_data.empty?
21
+ output << "\n".html_safe unless @card_data.empty?
22
22
  output
23
23
  end
24
24
 
@@ -1,3 +1,3 @@
1
1
  module TopHat
2
- VERSION = '1.7.1'
2
+ VERSION = '1.7.2'
3
3
  end
@@ -19,36 +19,3 @@ RSpec.configure do |config|
19
19
  TopHat.reset
20
20
  end
21
21
  end
22
-
23
- require 'action_controller/vendor/html-scanner'
24
-
25
- module HTML
26
- class Node
27
- def ==(node)
28
- return false unless self.class == node.class && children.size == node.children.size
29
-
30
- equivalent = true
31
-
32
- children.size.times do |i|
33
- equivalent &&= children.include?(node.children[i])
34
- end
35
-
36
- equivalent
37
- end
38
- end
39
- end
40
-
41
- RSpec::Matchers.define :be_dom_equivalent_to do |expected|
42
- match do |actual|
43
- expected_dom = HTML::Document.new(expected).root
44
- actual_dom = HTML::Document.new(actual).root
45
-
46
- expected_dom == actual_dom
47
- end
48
-
49
- failure_message_for_should do |actual|
50
- "expected #{actual} would be dom equivalent to #{expected}"
51
- end
52
-
53
- end
54
-
@@ -40,14 +40,14 @@ describe TopHat::OpenGraphHelper do
40
40
  context "as a string" do
41
41
  it "generates a site admin tag" do
42
42
  @template.opengraph(:admins => '123,124')
43
- @template.opengraph.should be_dom_equivalent_to('<meta content="123,124" property="fb:admins" />\n')
43
+ @template.opengraph.should include('<meta content="123,124" property="fb:admins" />')
44
44
  end
45
45
  end
46
46
 
47
47
  context "as an array" do
48
48
  it "generates a site admin tag" do
49
49
  @template.opengraph(:admins => [123, 124])
50
- @template.opengraph.should be_dom_equivalent_to('<meta content="123,124" property="fb:admins" />\n')
50
+ @template.opengraph.should include('<meta content="123,124" property="fb:admins" />')
51
51
  end
52
52
  end
53
53
  end
@@ -55,19 +55,19 @@ describe TopHat::OpenGraphHelper do
55
55
  context "app_id when configured" do
56
56
  it "generates an app_id meta tag" do
57
57
  @template.opengraph(:app_id => 'MyApp')
58
- @template.opengraph.should be_dom_equivalent_to('<meta content="MyApp" property="fb:app_id" />\n')
58
+ @template.opengraph.should include('<meta content="MyApp" property="fb:app_id" />')
59
59
  end
60
60
  end
61
61
 
62
62
  context "additional open graph properties" do
63
63
  it "generates opengraph meta tags" do
64
64
  @template.opengraph { title 'The Great Gatsby' }
65
- @template.opengraph.should be_dom_equivalent_to('<meta content="The Great Gatsby" property="og:title" />')
65
+ @template.opengraph.should include('<meta content="The Great Gatsby" property="og:title" />')
66
66
  end
67
67
 
68
68
  it "allows use of the tag 'type'" do
69
69
  @template.opengraph { type 'sports_team' }
70
- @template.opengraph.should be_dom_equivalent_to('<meta content="sports_team" property="og:type" />')
70
+ @template.opengraph.should include('<meta content="sports_team" property="og:type" />')
71
71
  end
72
72
 
73
73
  it "supports multiple tags" do
@@ -75,7 +75,10 @@ describe TopHat::OpenGraphHelper do
75
75
  title 'Austin Powers: International Man of Mystery'
76
76
  type 'movie'
77
77
  }
78
- @template.opengraph.should be_dom_equivalent_to('<meta content="movie" property="og:type" />\n<meta content="Austin Powers: International Man of Mystery" property="og:title" />\n')
78
+ output = @template.opengraph
79
+
80
+ output.should include('<meta content="movie" property="og:type" />')
81
+ output.should include('<meta content="Austin Powers: International Man of Mystery" property="og:title" />')
79
82
  end
80
83
 
81
84
  end
@@ -86,7 +89,12 @@ describe TopHat::OpenGraphHelper do
86
89
  title 'Rain Man'
87
90
  type 'movie'
88
91
  }
89
- @template.opengraph.should be_dom_equivalent_to('<meta content="MyApp" property="fb:app_id" />\n<meta content="123,1234" property="fb:admins" />\n<meta content="movie" property="og:type" />\n<meta content="Rain Man" property="og:title" />\n')
92
+ output = @template.opengraph
93
+
94
+ output.should include('<meta content="MyApp" property="fb:app_id" />')
95
+ output.should include('<meta content="123,1234" property="fb:admins" />')
96
+ output.should include('<meta content="movie" property="og:type" />')
97
+ output.should include('<meta content="Rain Man" property="og:title" />')
90
98
  end
91
99
 
92
100
  it "generates all tags when app_id and admins passed as part of rendering" do
@@ -94,7 +102,12 @@ describe TopHat::OpenGraphHelper do
94
102
  title 'Rain Man'
95
103
  type 'movie'
96
104
  }
97
- @template.opengraph(:app_id => 'MyApp', :admins => [123, 1234]).should be_dom_equivalent_to('<meta content="MyApp" property="fb:app_id" />\n<meta content="123,1234" property="fb:admins" />\n<meta content="movie" property="og:type" />\n<meta content="Rain Man" property="og:title" />\n')
105
+ output = @template.opengraph(:app_id => 'MyApp', :admins => [123, 1234])
106
+
107
+ output.should include('<meta content="MyApp" property="fb:app_id" />')
108
+ output.should include('<meta content="123,1234" property="fb:admins" />')
109
+ output.should include('<meta content="movie" property="og:type" />')
110
+ output.should include('<meta content="Rain Man" property="og:title" />')
98
111
  end
99
112
  end
100
113
 
@@ -104,8 +117,10 @@ describe TopHat::OpenGraphHelper do
104
117
  graph.title 'Rain Man'
105
118
  graph.type 'movie'
106
119
  }
120
+ output = @template.opengraph
107
121
 
108
- @template.opengraph.should be_dom_equivalent_to('<meta content="movie" property="og:type" />\n<meta content="Rain Man" property="og:title" />\n')
122
+ output.should include('<meta content="movie" property="og:type" />')
123
+ output.should include('<meta content="Rain Man" property="og:title" />')
109
124
  end
110
125
  end
111
126
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tophat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-10 00:00:00.000000000Z
12
+ date: 2012-08-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
16
- requirement: &2153060100 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153060100
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rake
27
- requirement: &2153053760 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *2153053760
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rspec
38
- requirement: &2153053300 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *2153053300
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: yard
49
- requirement: &2153052840 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *2153052840
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: rdiscount
60
- requirement: &2153052420 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '0'
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *2153052420
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: simplecov
71
- requirement: &2153051980 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: '0'
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *2153051980
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: rails
82
- requirement: &2153051440 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ! '>='
@@ -87,10 +117,15 @@ dependencies:
87
117
  version: 3.0.0
88
118
  type: :development
89
119
  prerelease: false
90
- version_requirements: *2153051440
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: 3.0.0
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: guard-rspec
93
- requirement: &2153051020 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
131
  - - ! '>='
@@ -98,7 +133,12 @@ dependencies:
98
133
  version: '0'
99
134
  type: :development
100
135
  prerelease: false
101
- version_requirements: *2153051020
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
102
142
  description: Simple view helpers for your layouts
103
143
  email:
104
144
  - steve.agalloco@gmail.com
@@ -148,15 +188,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
188
  - - ! '>='
149
189
  - !ruby/object:Gem::Version
150
190
  version: '0'
191
+ segments:
192
+ - 0
193
+ hash: 1182497879789537042
151
194
  required_rubygems_version: !ruby/object:Gem::Requirement
152
195
  none: false
153
196
  requirements:
154
197
  - - ! '>='
155
198
  - !ruby/object:Gem::Version
156
199
  version: '0'
200
+ segments:
201
+ - 0
202
+ hash: 1182497879789537042
157
203
  requirements: []
158
204
  rubyforge_project:
159
- rubygems_version: 1.8.10
205
+ rubygems_version: 1.8.24
160
206
  signing_key:
161
207
  specification_version: 3
162
208
  summary: Simple view helpers for your layouts