docomo_css 0.5.0 → 0.5.1
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.
- checksums.yaml +4 -4
- data/README.rdoc +6 -9
- data/lib/docomo_css.rb +1 -1
- data/lib/docomo_css/filter.rb +6 -0
- data/lib/docomo_css/stylesheet.rb +4 -0
- data/lib/docomo_css/version.rb +1 -1
- data/test/docomo_css/emeddable_style_test.rb +0 -1
- data/test/docomo_css/filter_test.rb +1 -1
- data/test/docomo_css/stylesheet_test.rb +11 -2
- data/test/test_helper.rb +7 -3
- metadata +3 -4
- data/lib/docomo_css/railtie.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1f350a22dbf0f516215c3c843ca575caf28ed14
|
4
|
+
data.tar.gz: a0fe97cb85a9f3107e5da118f86ec362b53a9461
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d498d8ae970fcfd1dbe372463db3e8fbe492ff3563717c6d62503e6890827fd20d824408a554efe7ee5f9b38291337be77d7bcefe1708de37d7432a7c36aa1d2
|
7
|
+
data.tar.gz: 76d9acf5bc4920d16e25b5c969cf6e194bd6a1a84369aea039e1b8441aa9ada365d20c0aedf897258d1d516945f0674bed36261526d28854983b93f5914924c5
|
data/README.rdoc
CHANGED
@@ -23,7 +23,7 @@ to
|
|
23
23
|
|
24
24
|
so you don't need to change any styling. If you were doing this manually before and don't want docomo_css to automatically update your html, use
|
25
25
|
|
26
|
-
docomo_css :
|
26
|
+
docomo_css inject_unsupported_style: false
|
27
27
|
|
28
28
|
== Install
|
29
29
|
|
@@ -31,8 +31,7 @@ so you don't need to change any styling. If you were doing this manually before
|
|
31
31
|
|
32
32
|
== Requirements
|
33
33
|
|
34
|
-
*
|
35
|
-
* Rails 3 or later
|
34
|
+
* Rails 4
|
36
35
|
|
37
36
|
== Usage
|
38
37
|
|
@@ -45,7 +44,7 @@ so you don't need to change any styling. If you were doing this manually before
|
|
45
44
|
# app/views/articles/index.html.erb
|
46
45
|
<html>
|
47
46
|
<head>
|
48
|
-
<%= stylesheet_link_tag 'foo', :
|
47
|
+
<%= stylesheet_link_tag 'foo', media: 'handheld, tty' %>
|
49
48
|
</head>
|
50
49
|
<body>
|
51
50
|
<div class="title">bar</div>
|
@@ -59,9 +58,7 @@ so you don't need to change any styling. If you were doing this manually before
|
|
59
58
|
|
60
59
|
# result
|
61
60
|
<html>
|
62
|
-
<head>
|
63
|
-
<%= stylesheet_link_tag 'foo', :media => 'handheld, tty' %>
|
64
|
-
</head>
|
61
|
+
<head></head>
|
65
62
|
<body>
|
66
63
|
<div class="title" style="color:red">bar</div>
|
67
64
|
</body>
|
@@ -74,8 +71,8 @@ Options for the value of this docomo_css are
|
|
74
71
|
|
75
72
|
== Author
|
76
73
|
|
77
|
-
Copyright (c) 2008 milk1000cc, released under the MIT license
|
74
|
+
Copyright (c) 2008-2014 milk1000cc & Paul McMahon, released under the MIT license
|
78
75
|
|
79
76
|
milk1000cc <mailto:info@milk1000.cc>
|
80
77
|
|
81
|
-
|
78
|
+
Paul McMahon <mailto:paul@mobalean.com>
|
data/lib/docomo_css.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'docomo_css/
|
1
|
+
require 'docomo_css/filter'
|
data/lib/docomo_css/filter.rb
CHANGED
@@ -3,6 +3,12 @@ require 'docomo_css/embeddable_style'
|
|
3
3
|
require 'nokogiri'
|
4
4
|
require 'tiny_css'
|
5
5
|
|
6
|
+
ActiveSupport.on_load(:action_controller) do
|
7
|
+
def self.docomo_filter(options = {})
|
8
|
+
after_action DocomoCss::Filter.new(options)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
6
12
|
module DocomoCss
|
7
13
|
class Filter
|
8
14
|
def initialize(options = {})
|
@@ -18,6 +18,10 @@ module DocomoCss
|
|
18
18
|
path = path.sub(/^#{ Rails.application.config.assets.prefix }/, '').
|
19
19
|
sub(/^\//, '')
|
20
20
|
|
21
|
+
if Rails.application.config.assets.digest
|
22
|
+
path = path.sub(/(.+)\-\w+(.+)/, '\1\2')
|
23
|
+
end
|
24
|
+
|
21
25
|
asset = Rails.application.assets.
|
22
26
|
find_asset(path, :bundle => !body_only?(query))
|
23
27
|
asset ? asset.to_s : nil
|
data/lib/docomo_css/version.rb
CHANGED
@@ -233,7 +233,7 @@ a:visited { color: blue; }
|
|
233
233
|
|
234
234
|
def test_asset_pipeline
|
235
235
|
css = open(File.expand_path('../public/actual.css', __dir__)) { |f| f.read }
|
236
|
-
mock_asset 'actual.css',
|
236
|
+
mock_asset 'actual.css', css
|
237
237
|
|
238
238
|
request = stub('request', :user_agent => 'DoCoMo/2.0 D905i(c100;TB;W24H17)')
|
239
239
|
response = stub("response") do
|
@@ -24,7 +24,7 @@ class DocomoCss::StylesheetTest < MiniTest::Test
|
|
24
24
|
|
25
25
|
def test_asset_css
|
26
26
|
css = "div.content { background-color: #999 }"
|
27
|
-
mock_asset 'mobile/application.css',
|
27
|
+
mock_asset 'mobile/application.css', css
|
28
28
|
|
29
29
|
href = "/assets/mobile/application.css?body=1"
|
30
30
|
stylesheet = DocomoCss::Stylesheet.new(href)
|
@@ -33,10 +33,19 @@ class DocomoCss::StylesheetTest < MiniTest::Test
|
|
33
33
|
|
34
34
|
def test_asset_css_without_body_param
|
35
35
|
css = "div.content { background-color: #999 }"
|
36
|
-
mock_asset 'mobile/application.css',
|
36
|
+
mock_asset 'mobile/application.css', css, bundle: true
|
37
37
|
|
38
38
|
href = "/assets/mobile/application.css"
|
39
39
|
stylesheet = DocomoCss::Stylesheet.new(href)
|
40
40
|
assert_equal css, stylesheet.asset_css
|
41
41
|
end
|
42
|
+
|
43
|
+
def test_asset_css_with_digest
|
44
|
+
css = "div.content { background-color: #999 }"
|
45
|
+
mock_asset 'mobile/application.css', css, digest: true
|
46
|
+
|
47
|
+
href = "/assets/mobile/application-c692ad4e67b1dc0d0ce.css?body=1"
|
48
|
+
stylesheet = DocomoCss::Stylesheet.new(href)
|
49
|
+
assert_equal css, stylesheet.asset_css
|
50
|
+
end
|
42
51
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
2
|
require 'mocha/mini_test'
|
3
|
+
require 'active_support'
|
3
4
|
|
4
5
|
Rails = Mocha::Mockery.instance.unnamed_mock
|
5
6
|
Rails.stubs(
|
@@ -11,11 +12,14 @@ module ActionController
|
|
11
12
|
Base.stubs(:asset_host => nil)
|
12
13
|
end
|
13
14
|
|
14
|
-
def mock_asset(path, bundle,
|
15
|
-
|
15
|
+
def mock_asset(path, css, bundle: false, digest: false)
|
16
|
+
assets_config = stub('assets_config', prefix: '/assets', digest: digest)
|
17
|
+
rails_config = stub('rails_config', assets: assets_config)
|
18
|
+
|
16
19
|
asset = stub('asset', to_s: css)
|
17
20
|
assets = stub('assets') do
|
18
21
|
expects(:find_asset).with(path, :bundle => bundle).returns(asset)
|
19
22
|
end
|
20
|
-
|
23
|
+
|
24
|
+
Rails.application.stubs :assets => assets, :config => rails_config
|
21
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docomo_css
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- milk1000cc
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-12-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -126,7 +126,6 @@ files:
|
|
126
126
|
- lib/docomo_css.rb
|
127
127
|
- lib/docomo_css/embeddable_style.rb
|
128
128
|
- lib/docomo_css/filter.rb
|
129
|
-
- lib/docomo_css/railtie.rb
|
130
129
|
- lib/docomo_css/stylesheet.rb
|
131
130
|
- lib/docomo_css/version.rb
|
132
131
|
- test/actual.html
|
@@ -158,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
157
|
version: '0'
|
159
158
|
requirements: []
|
160
159
|
rubyforge_project:
|
161
|
-
rubygems_version: 2.
|
160
|
+
rubygems_version: 2.4.5
|
162
161
|
signing_key:
|
163
162
|
specification_version: 4
|
164
163
|
summary: CSS inliner
|
data/lib/docomo_css/railtie.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'docomo_css/filter'
|
2
|
-
|
3
|
-
class DocomoCss::Railtie < Rails::Railtie
|
4
|
-
initializer "docomo_css.extend.action_controller" do
|
5
|
-
ActionController::Base.class_eval do
|
6
|
-
def self.docomo_filter(options = {} )
|
7
|
-
after_filter DocomoCss::Filter.new(options)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|