docomo_css 0.0.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -31,7 +31,7 @@ begin
31
31
  s.homepage = "http://www.milk1000.cc/"
32
32
  s.authors = ["milk1000cc", "Paul McMahon"]
33
33
  s.add_dependency 'hpricot'
34
- s.add_dependency 'tiny_css'
34
+ s.add_dependency 'milk1000cc-tiny_css'
35
35
  end
36
36
  rescue LoadError
37
37
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.1
data/docomo_css.gemspec CHANGED
@@ -1,15 +1,12 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
5
2
 
6
3
  Gem::Specification.new do |s|
7
4
  s.name = %q{docomo_css}
8
- s.version = "0.0.2"
5
+ s.version = "0.2.0"
9
6
 
10
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
8
  s.authors = ["milk1000cc", "Paul McMahon"]
12
- s.date = %q{2010-09-15}
9
+ s.date = %q{2009-06-11}
13
10
  s.description = %q{Inlines CSS so that you can use external CSS with docomo handsets.}
14
11
  s.email = %q{info@milk1000.cc}
15
12
  s.extra_rdoc_files = [
@@ -25,15 +22,13 @@ Gem::Specification.new do |s|
25
22
  "init.rb",
26
23
  "lib/docomo_css.rb",
27
24
  "rails/init.rb",
28
- "test/actual.css",
29
- "test/actual.html",
30
25
  "test/docomo_css_test.rb",
31
- "test/expected.html"
32
26
  ]
27
+ s.has_rdoc = true
33
28
  s.homepage = %q{http://www.milk1000.cc/}
34
29
  s.rdoc_options = ["--charset=UTF-8"]
35
30
  s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.3.7}
31
+ s.rubygems_version = %q{1.3.1}
37
32
  s.summary = %q{CSS inliner}
38
33
  s.test_files = [
39
34
  "test/docomo_css_test.rb"
@@ -41,18 +36,17 @@ Gem::Specification.new do |s|
41
36
 
42
37
  if s.respond_to? :specification_version then
43
38
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
- s.specification_version = 3
39
+ s.specification_version = 2
45
40
 
46
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
- s.add_runtime_dependency(%q<hpricot>, [">= 0"])
41
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
42
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
48
43
  s.add_runtime_dependency(%q<tiny_css>, [">= 0"])
49
44
  else
50
- s.add_dependency(%q<hpricot>, [">= 0"])
45
+ s.add_dependency(%q<nokogiri>, [">= 0"])
51
46
  s.add_dependency(%q<tiny_css>, [">= 0"])
52
47
  end
53
48
  else
54
- s.add_dependency(%q<hpricot>, [">= 0"])
49
+ s.add_dependency(%q<nokogiri>, [">= 0"])
55
50
  s.add_dependency(%q<tiny_css>, [">= 0"])
56
51
  end
57
52
  end
58
-
data/lib/docomo_css.rb CHANGED
@@ -15,9 +15,7 @@ module DocomoCss
15
15
 
16
16
  class DocomoCssFilter
17
17
  def after(controller)
18
- return unless controller.response.content_type =~ /application\/xhtml\+xml/
19
- return unless controller.request.user_agent =~ /docomo/i
20
- return if docomo_2_0_browser?(controller)
18
+ return unless controller.response.content_type == 'application/xhtml+xml'
21
19
  body = escape_numeric_character_reference controller.response.body
22
20
  body = embed_css remove_xml_declare(body)
23
21
  controller.response.body = unescape_numeric_character_reference body
@@ -106,11 +104,5 @@ module DocomoCss
106
104
  def pseudo_selectors(css)
107
105
  css.style.keys.grep(/a:(link|focus|visited)/)
108
106
  end
109
-
110
- private
111
-
112
- def docomo_2_0_browser?(controller)
113
- controller.request.user_agent =~ /DoCoMo\/2\.0 [^(]*\(c(\d+);/ && $1.to_i >= 500
114
- end
115
107
  end
116
108
  end
@@ -155,40 +155,15 @@ a:visited { color: blue; }
155
155
  assert_equal '', @filter.remove_xml_declare('<?xml?>')
156
156
  end
157
157
 
158
- def test_output_with_docomo_1_0_browser
159
- request = stub('request', :user_agent => 'DoCoMo/2.0 D905i(c100;TB;W24H17)')
158
+ def test_output
160
159
  response = stub("response") do
161
160
  expects(:content_type).returns('application/xhtml+xml')
162
161
  expects(:body).returns(File.open(File.join(File.dirname(__FILE__), 'actual.html'), 'rb'){ |f| f.read })
163
162
  expects(:body=).with(File.open(File.join(File.dirname(__FILE__), 'expected.html'), 'rb'){ |f| f.read })
164
163
  end
165
- controller = stub("controller", :response => response, :request => request)
164
+ controller = stub("controller", :response => response)
166
165
  @filter.stubs(:css_path).returns(File.join(File.dirname(__FILE__), 'actual.css'))
167
166
 
168
167
  @filter.after(controller)
169
168
  end
170
-
171
- def test_output_with_docomo_1_0_browser_and_utf8_charset
172
- request = stub('request', :user_agent => 'DoCoMo/2.0 D905i(c100;TB;W24H17)')
173
- response = stub("response") do
174
- expects(:content_type).returns('application/xhtml+xml; charset=utf-8')
175
- expects(:body).returns(File.open(File.join(File.dirname(__FILE__), 'actual.html'), 'rb'){ |f| f.read })
176
- expects(:body=).with(File.open(File.join(File.dirname(__FILE__), 'expected.html'), 'rb'){ |f| f.read })
177
- end
178
- controller = stub("controller", :response => response, :request => request)
179
- @filter.stubs(:css_path).returns(File.join(File.dirname(__FILE__), 'actual.css'))
180
-
181
- @filter.after(controller)
182
- end
183
-
184
- def test_output_with_docomo_2_0_browser
185
- request = stub('request', :user_agent => 'DoCoMo/2.0 N03B(c500;TB;W24H16)')
186
- response = stub("response") do
187
- expects(:content_type).returns('application/xhtml+xml')
188
- expects(:body).never
189
- end
190
- controller = stub("controller", :response => response, :request => request)
191
-
192
- @filter.after(controller)
193
- end
194
169
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docomo_css
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 0
9
8
  - 2
10
- version: 0.0.2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - milk1000cc
@@ -16,11 +16,11 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-09-15 00:00:00 +09:00
19
+ date: 2009-06-11 00:00:00 +09:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
- name: hpricot
23
+ name: nokogiri
24
24
  prerelease: false
25
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
26
  none: false
@@ -65,10 +65,7 @@ files:
65
65
  - init.rb
66
66
  - lib/docomo_css.rb
67
67
  - rails/init.rb
68
- - test/actual.css
69
- - test/actual.html
70
68
  - test/docomo_css_test.rb
71
- - test/expected.html
72
69
  has_rdoc: true
73
70
  homepage: http://www.milk1000.cc/
74
71
  licenses: []
@@ -101,7 +98,7 @@ requirements: []
101
98
  rubyforge_project:
102
99
  rubygems_version: 1.3.7
103
100
  signing_key:
104
- specification_version: 3
101
+ specification_version: 2
105
102
  summary: CSS inliner
106
103
  test_files:
107
104
  - test/docomo_css_test.rb
data/test/actual.css DELETED
@@ -1,4 +0,0 @@
1
- a:link { color: red; }
2
- a:focus { color: green; }
3
- a:visited { color: blue; }
4
- div.content { background-color: #999 }
data/test/actual.html DELETED
@@ -1,13 +0,0 @@
1
- <?xml version="1.0" encoding="Shift_JIS"?>
2
- <!DOCTYPE html PUBLIC "-//i-mode group (ja)//DTD XHTML i-XHTML(Locale/Ver.=ja/2.3) 1.0//EN" "i-xhtml_4ja_10.dtd">
3
- <html>
4
- <head>
5
- <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=Shift_JIS" />
6
- <link rel="stylesheet" href="/actual.css" />
7
- </head>
8
- <body>
9
- <div class="content">
10
- <a href="/">TOP</a>
11
- </div>
12
- </body>
13
- </html>
data/test/expected.html DELETED
@@ -1,27 +0,0 @@
1
- <?xml version="1.0" encoding="Shift_JIS"?>
2
- <!DOCTYPE html PUBLIC "-//i-mode group (ja)//DTD XHTML i-XHTML(Locale/Ver.=ja/2.3) 1.0//EN" "i-xhtml_4ja_10.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml">
4
- <head>
5
- <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=Shift_JIS" />
6
- <link rel="stylesheet" href="/actual.css" />
7
- <style type="text/css">
8
- <![CDATA[
9
- a:visited {
10
- color: blue;
11
- }
12
- a:link {
13
- color: red;
14
- }
15
- a:focus {
16
- color: green;
17
- }
18
-
19
- ]]>
20
- </style>
21
- </head>
22
- <body>
23
- <div class="content" style="background-color:#999">
24
- <a href="/">TOP</a>
25
- </div>
26
- </body>
27
- </html>