slimmer 1.1.45 → 1.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/slimmer.rb CHANGED
@@ -22,6 +22,7 @@ module Slimmer
22
22
  autoload :AdminTitleInserter, 'slimmer/admin_title_inserter'
23
23
  autoload :SectionInserter, 'slimmer/section_inserter'
24
24
  autoload :TagMover, 'slimmer/tag_mover'
25
+ autoload :ConditionalCommentMover, 'slimmer/conditional_comment_mover'
25
26
  autoload :FooterRemover, 'slimmer/footer_remover'
26
27
  autoload :BodyInserter, 'slimmer/body_inserter'
27
28
  autoload :BodyClassCopier, 'slimmer/body_class_copier'
@@ -0,0 +1,17 @@
1
+ module Slimmer
2
+ class ConditionalCommentMover
3
+ def filter(src, dest)
4
+ src.xpath('//comment()').each do |comment|
5
+ if match_conditional_comments(comment)
6
+ dest.at_xpath('/html/head') << comment
7
+ end
8
+ end
9
+ end
10
+
11
+ def match_conditional_comments(str)
12
+ str.to_s =~ /<!--\[[A-Za-z0-9 ]+\]>(.*)<!\[endif\]-->/m
13
+ end
14
+ end
15
+ end
16
+
17
+
data/lib/slimmer/skin.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Slimmer
2
2
  class Skin
3
- attr_accessor :use_cache, :template_cache, :asset_host, :prefix, :logger, :strict, :options
3
+ attr_accessor :use_cache, :template_cache, :asset_host, :logger, :strict, :options
4
4
 
5
5
  # TODO: Extract the cache to something we can pass in instead of using
6
6
  # true/false and an in-memory cache.
@@ -8,7 +8,6 @@ module Slimmer
8
8
  @options = options
9
9
  @asset_host = options[:asset_host]
10
10
  @template_cache = {}
11
- @prefix = options[:prefix]
12
11
  @use_cache = options[:use_cache] || false
13
12
  @logger = options[:logger] || NullLogger.instance
14
13
  @strict = options[:strict] || (%w{development test}.include?(ENV['RACK_ENV']))
@@ -126,6 +125,7 @@ module Slimmer
126
125
  processors = [
127
126
  TitleInserter.new(),
128
127
  TagMover.new(),
128
+ ConditionalCommentMover.new(),
129
129
  BodyInserter.new(options[:wrapper_id] || 'wrapper'),
130
130
  BodyClassCopier.new,
131
131
  HeaderContextInserter.new(),
@@ -1,3 +1,3 @@
1
1
  module Slimmer
2
- VERSION = '1.1.45'
2
+ VERSION = '1.1.47'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require "test_helper"
2
2
 
3
- module GoogleAnalyticsTest
3
+ module SearchPathSetterTest
4
4
 
5
5
  DOCUMENT_WITH_SEARCH = <<-END
6
6
  <html>
data/test/skin_test.rb CHANGED
@@ -24,15 +24,6 @@ class SkinTest < MiniTest::Unit::TestCase
24
24
  assert_same first_access, second_access
25
25
  end
26
26
 
27
- def test_should_interpolate_values_for_prefix
28
- skin = Slimmer::Skin.new asset_host: "http://example.local/", use_cache: false, prefix: "this-is-the-prefix"
29
- expected_url = "http://example.local/templates/example.html.erb"
30
- stub_request(:get, expected_url).to_return :body => "<p><%= prefix %></p>"
31
-
32
- template = skin.template 'example'
33
- assert_equal "<p>this-is-the-prefix</p>", template
34
- end
35
-
36
27
  def test_should_raise_appropriate_exception_when_template_not_found
37
28
  skin = Slimmer::Skin.new asset_host: "http://example.local/"
38
29
  expected_url = "http://example.local/templates/example.html.erb"
@@ -78,6 +78,7 @@ module TypicalUsage
78
78
  <meta name="x-section-name" content="This section">
79
79
  <meta name="x-section-link" content="/this_section">
80
80
  <script src="blah.js"></script>
81
+ <!--[if lt IE 9]><link href="app-ie.css" rel="stylesheet" type="text/css"><![endif]-->
81
82
  <link href="app.css" rel="stylesheet" type="text/css">
82
83
  </head>
83
84
  <body class="body_class">
@@ -106,6 +107,11 @@ module TypicalUsage
106
107
  assert_rendered_in_template "head link[href='app.css']"
107
108
  end
108
109
 
110
+ def test_should_move_conditional_comments_into_the_head
111
+ element = Nokogiri::HTML.parse(last_response.body).at_xpath('//comment()')
112
+ assert_match /app-ie\.css/, element.to_s, 'Not found conditional comment in output'
113
+ end
114
+
109
115
  def test_should_copy_the_class_of_the_body_element
110
116
  assert_rendered_in_template "body.body_class"
111
117
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: slimmer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.45
5
+ version: 1.1.47
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Griffiths
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2012-07-13 00:00:00 Z
14
+ date: 2012-07-27 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: nokogiri
@@ -144,7 +144,7 @@ dependencies:
144
144
  requirements:
145
145
  - - ~>
146
146
  - !ruby/object:Gem::Version
147
- version: 1.0.0
147
+ version: 1.1.1
148
148
  type: :development
149
149
  prerelease: false
150
150
  version_requirements: *id012
@@ -168,6 +168,7 @@ files:
168
168
  - lib/slimmer/test.rb
169
169
  - lib/slimmer/footer_remover.rb
170
170
  - lib/slimmer/skin.rb
171
+ - lib/slimmer/conditional_comment_mover.rb
171
172
  - lib/slimmer/section_inserter.rb
172
173
  - lib/slimmer/title_inserter.rb
173
174
  - lib/slimmer/search_path_setter.rb
@@ -209,7 +210,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
210
  requirements:
210
211
  - - ">="
211
212
  - !ruby/object:Gem::Version
212
- hash: -538766457930191624
213
+ hash: 1631614823969087882
213
214
  segments:
214
215
  - 0
215
216
  version: "0"
@@ -218,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
219
  requirements:
219
220
  - - ">="
220
221
  - !ruby/object:Gem::Version
221
- hash: -538766457930191624
222
+ hash: 1631614823969087882
222
223
  segments:
223
224
  - 0
224
225
  version: "0"