middleman-autoprefixer 2.0.1 → 2.1.0
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.md +19 -4
- data/features/autoprefixer.feature +16 -0
- data/fixtures/default-app/source/index.html +12 -0
- data/fixtures/ignore-app/config.rb +1 -0
- data/fixtures/ignore-app/source/index.html +0 -0
- data/fixtures/ignore-app/source/stylesheets/nope.scss +4 -0
- data/fixtures/ignore-app/source/stylesheets/yep.scss +4 -0
- data/fixtures/inline-app/config.rb +1 -0
- data/fixtures/inline-app/source/index.html +12 -0
- data/lib/middleman-autoprefixer.rb +1 -1
- data/lib/middleman-autoprefixer/extension.rb +72 -6
- data/lib/middleman-autoprefixer/version.rb +1 -1
- data/middleman-autoprefixer.gemspec +5 -6
- metadata +22 -24
- data/lib/middleman-autoprefixer/processor.rb +0 -36
- data/lib/middleman_extension.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8e0dbefd3dbf52be4931785c1fbaae0d7581bdf
|
4
|
+
data.tar.gz: d0f3812a1266d1f4f0e2699e329234d49df519e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5a31ff16e80e345d3a58c8b6f08d16fe02f6221a4c632353d2a8fa1a407a4121dc86e4aa519090ef13f8e410313db01b8bb87555d4bd22d181630db2cb89af5
|
7
|
+
data.tar.gz: a3c9daaefdfc70169fb95b00bf25ca7116025e4c16b9f43f1242d065e3a364120dc486602c4be6f161fb674e131fc33f8dcd996705c4767f4da34bbb5d977bea
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
[](http://badge.fury.io/rb/middleman-autoprefixer) [](https://travis-ci.org/porada/middleman-autoprefixer) [](https://gemnasium.com/porada/middleman-autoprefixer) [](https://codeclimate.com/github/porada/middleman-autoprefixer)
|
1
|
+
[](http://badge.fury.io/rb/middleman-autoprefixer) [](https://travis-ci.org/porada/middleman-autoprefixer) [](https://gemnasium.com/porada/middleman-autoprefixer) [](https://codeclimate.com/github/porada/middleman-autoprefixer)
|
3
2
|
|
4
3
|
# Middleman::Autoprefixer
|
5
4
|
|
@@ -21,16 +20,32 @@ activate :autoprefixer
|
|
21
20
|
|
22
21
|
## Configuration
|
23
22
|
|
24
|
-
The extension has
|
23
|
+
The extension has 4 optionally configurable fields:
|
25
24
|
|
26
25
|
```ruby
|
27
26
|
activate :autoprefixer do |config|
|
28
27
|
config.browsers = ['last 2 versions', 'Explorer >= 9']
|
29
28
|
config.cascade = false
|
29
|
+
config.inline = true
|
30
|
+
config.ignore = ['hacks.css']
|
30
31
|
end
|
31
32
|
```
|
32
33
|
|
33
|
-
|
34
|
+
### browsers
|
35
|
+
|
36
|
+
The list of targeted browsers. Takes values and uses defaults accordingly to [Autoprefixer’s documentation](https://github.com/ai/autoprefixer#browsers).
|
37
|
+
|
38
|
+
### cascade
|
39
|
+
|
40
|
+
The visual cascade of prefixed properties: `true` or `false`. Uses the default value accordingly to [Autoprefixer’s documentation](https://github.com/ai/autoprefixer#visual-cascade).
|
41
|
+
|
42
|
+
### inline
|
43
|
+
|
44
|
+
Whether to prefix inline styles within HTML files: `true` or `false`. Disabled by default.
|
45
|
+
|
46
|
+
### ignore
|
47
|
+
|
48
|
+
The array of patterns or paths to exclude from prefixing. Empty by default.
|
34
49
|
|
35
50
|
## License
|
36
51
|
|
@@ -5,6 +5,8 @@ Feature: Postprocessing stylesheets with Autoprefixer in different configuration
|
|
5
5
|
When I go to "/stylesheets/page.css"
|
6
6
|
Then I should not see "-ms-border-radius"
|
7
7
|
And I should see "border-radius"
|
8
|
+
When I go to "/index.html"
|
9
|
+
Then I should see "-ms-border-radius"
|
8
10
|
|
9
11
|
Scenario: Passing options in a block
|
10
12
|
Given the Server is running at "block-app"
|
@@ -39,3 +41,17 @@ Feature: Postprocessing stylesheets with Autoprefixer in different configuration
|
|
39
41
|
-moz-box-sizing: border-box;
|
40
42
|
box-sizing: border-box;
|
41
43
|
"""
|
44
|
+
|
45
|
+
Scenario: Inline HTML
|
46
|
+
Given the Server is running at "inline-app"
|
47
|
+
When I go to "/index.html"
|
48
|
+
Then I should not see "-ms-border-radius"
|
49
|
+
And I should see "border-radius"
|
50
|
+
|
51
|
+
Scenario: Ignoring paths
|
52
|
+
Given the Server is running at "ignore-app"
|
53
|
+
When I go to "/stylesheets/yep.css"
|
54
|
+
Then I should see "-ms-border-radius"
|
55
|
+
When I go to "/stylesheets/nope.css"
|
56
|
+
Then I should not see "-ms-border-radius"
|
57
|
+
And I should see "border-radius"
|
@@ -0,0 +1 @@
|
|
1
|
+
activate :autoprefixer, ignore: ['yep.css']
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
activate :autoprefixer, inline: true
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'middleman-core'
|
2
2
|
|
3
3
|
require_relative 'middleman-autoprefixer/version'
|
4
|
-
require_relative 'middleman-autoprefixer/extension'
|
5
4
|
|
6
5
|
::Middleman::Extensions.register(:autoprefixer) do
|
6
|
+
require_relative 'middleman-autoprefixer/extension'
|
7
7
|
::Middleman::Autoprefixer::Extension
|
8
8
|
end
|
@@ -1,17 +1,83 @@
|
|
1
|
-
require_relative 'processor'
|
2
|
-
|
3
1
|
module Middleman
|
4
2
|
module Autoprefixer
|
5
3
|
class Extension < ::Middleman::Extension
|
6
|
-
option :browsers
|
7
|
-
option :cascade
|
4
|
+
option :browsers, nil, 'Supported browsers'
|
5
|
+
option :cascade, nil, 'Should it cascade'
|
6
|
+
option :inline, false, 'Whether to prefix CSS inline within HTML files'
|
7
|
+
option :ignore, [], 'Patterns to avoid prefixing'
|
8
8
|
|
9
|
-
def initialize(app,
|
9
|
+
def initialize(app, options={}, &block)
|
10
10
|
super
|
11
|
+
|
12
|
+
require 'middleman-core/util'
|
13
|
+
require 'autoprefixer-rails'
|
11
14
|
end
|
12
15
|
|
13
16
|
def after_configuration
|
14
|
-
|
17
|
+
# Setup Rack middleware to apply prefixes
|
18
|
+
app.use Rack, browsers: options[:browsers],
|
19
|
+
cascade: options[:cascade],
|
20
|
+
inline: options[:inline],
|
21
|
+
ignore: options[:ignore]
|
22
|
+
end
|
23
|
+
|
24
|
+
# Rack middleware to look for CSS and apply prefixes.
|
25
|
+
class Rack
|
26
|
+
INLINE_CSS_REGEX = /(<style[^>]*>\s*(?:\/\*<!\[CDATA\[\*\/\n)?)(.*?)((?:(?:\n\s*)?\/\*\]\]>\*\/)?\s*<\/style>)/m
|
27
|
+
|
28
|
+
# Init
|
29
|
+
# @param [Class] app
|
30
|
+
# @param [Hash] options
|
31
|
+
def initialize(app, options={})
|
32
|
+
@app = app
|
33
|
+
@browsers = options[:browsers]
|
34
|
+
@cascade = options[:cascade]
|
35
|
+
@inline = options[:inline]
|
36
|
+
@ignore = options[:ignore]
|
37
|
+
end
|
38
|
+
|
39
|
+
# Rack interface
|
40
|
+
# @param [Rack::Environmemt] env
|
41
|
+
# @return [Array]
|
42
|
+
def call(env)
|
43
|
+
status, headers, response = @app.call(env)
|
44
|
+
|
45
|
+
if inline_html_content?(env['PATH_INFO'])
|
46
|
+
prefixed = ::Middleman::Util.extract_response_text(response)
|
47
|
+
|
48
|
+
prefixed.gsub!(INLINE_CSS_REGEX) do
|
49
|
+
$1 << process($2) << $3
|
50
|
+
end
|
51
|
+
|
52
|
+
headers['Content-Length'] = ::Rack::Utils.bytesize(prefixed).to_s
|
53
|
+
response = [prefixed]
|
54
|
+
elsif standalone_css_content?(env['PATH_INFO'])
|
55
|
+
prefixed_css = process(::Middleman::Util.extract_response_text(response))
|
56
|
+
|
57
|
+
headers['Content-Length'] = ::Rack::Utils.bytesize(prefixed_css).to_s
|
58
|
+
response = [prefixed_css]
|
59
|
+
end
|
60
|
+
|
61
|
+
[status, headers, response]
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def process(css)
|
67
|
+
config = {}
|
68
|
+
config[:browsers] = Array(@browsers)
|
69
|
+
config[:cascade] = @cascade unless @cascade.nil?
|
70
|
+
|
71
|
+
::AutoprefixerRails.process(css, config).css
|
72
|
+
end
|
73
|
+
|
74
|
+
def inline_html_content?(path)
|
75
|
+
(path.end_with?('.html') || path.end_with?('.php')) && @inline
|
76
|
+
end
|
77
|
+
|
78
|
+
def standalone_css_content?(path)
|
79
|
+
path.end_with?('.css') && @ignore.none? { |ignore| ::Middleman::Util.path_match(ignore, path) }
|
80
|
+
end
|
15
81
|
end
|
16
82
|
end
|
17
83
|
end
|
@@ -6,8 +6,8 @@ require 'middleman-autoprefixer/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'middleman-autoprefixer'
|
8
8
|
spec.version = Middleman::Autoprefixer::VERSION
|
9
|
-
spec.authors = ['Dominik Porada']
|
10
|
-
spec.email = ['dominik@porada.co']
|
9
|
+
spec.authors = ['Dominik Porada', 'Thomas Reynolds']
|
10
|
+
spec.email = ['dominik@porada.co', 'me@tdreyno.com']
|
11
11
|
spec.summary = 'Autoprefixer integration with Middleman'
|
12
12
|
spec.homepage = 'https://github.com/porada/middleman-autoprefixer'
|
13
13
|
spec.license = 'MIT'
|
@@ -17,12 +17,11 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.require_paths = ['lib']
|
18
18
|
|
19
19
|
spec.add_dependency 'middleman-core', '>= 3.3.3'
|
20
|
-
spec.add_dependency '
|
21
|
-
spec.add_dependency 'autoprefixer-rails', '~> 2.1.0'
|
20
|
+
spec.add_dependency 'autoprefixer-rails', '~> 2.1.1'
|
22
21
|
|
23
22
|
spec.add_development_dependency 'middleman', '>= 3.3.3'
|
24
|
-
spec.add_development_dependency 'cucumber', '~> 1.3
|
25
|
-
spec.add_development_dependency 'aruba', '~> 0.
|
23
|
+
spec.add_development_dependency 'cucumber', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'aruba', '~> 0.6'
|
26
25
|
|
27
26
|
spec.add_development_dependency 'bundler', '>= 1.6'
|
28
27
|
spec.add_development_dependency 'rake', '>= 10.3'
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-autoprefixer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Porada
|
8
|
+
- Thomas Reynolds
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
+
date: 2014-07-25 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: middleman-core
|
@@ -24,34 +25,20 @@ dependencies:
|
|
24
25
|
- - ">="
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: 3.3.3
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: middleman-sprockets
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 3.3.3
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 3.3.3
|
41
28
|
- !ruby/object:Gem::Dependency
|
42
29
|
name: autoprefixer-rails
|
43
30
|
requirement: !ruby/object:Gem::Requirement
|
44
31
|
requirements:
|
45
32
|
- - "~>"
|
46
33
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.1.
|
34
|
+
version: 2.1.1
|
48
35
|
type: :runtime
|
49
36
|
prerelease: false
|
50
37
|
version_requirements: !ruby/object:Gem::Requirement
|
51
38
|
requirements:
|
52
39
|
- - "~>"
|
53
40
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.1.
|
41
|
+
version: 2.1.1
|
55
42
|
- !ruby/object:Gem::Dependency
|
56
43
|
name: middleman
|
57
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,28 +59,28 @@ dependencies:
|
|
72
59
|
requirements:
|
73
60
|
- - "~>"
|
74
61
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.3
|
62
|
+
version: '1.3'
|
76
63
|
type: :development
|
77
64
|
prerelease: false
|
78
65
|
version_requirements: !ruby/object:Gem::Requirement
|
79
66
|
requirements:
|
80
67
|
- - "~>"
|
81
68
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.3
|
69
|
+
version: '1.3'
|
83
70
|
- !ruby/object:Gem::Dependency
|
84
71
|
name: aruba
|
85
72
|
requirement: !ruby/object:Gem::Requirement
|
86
73
|
requirements:
|
87
74
|
- - "~>"
|
88
75
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
76
|
+
version: '0.6'
|
90
77
|
type: :development
|
91
78
|
prerelease: false
|
92
79
|
version_requirements: !ruby/object:Gem::Requirement
|
93
80
|
requirements:
|
94
81
|
- - "~>"
|
95
82
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
83
|
+
version: '0.6'
|
97
84
|
- !ruby/object:Gem::Dependency
|
98
85
|
name: bundler
|
99
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,6 +112,7 @@ dependencies:
|
|
125
112
|
description:
|
126
113
|
email:
|
127
114
|
- dominik@porada.co
|
115
|
+
- me@tdreyno.com
|
128
116
|
executables: []
|
129
117
|
extensions: []
|
130
118
|
extra_rdoc_files: []
|
@@ -152,11 +140,15 @@ files:
|
|
152
140
|
- fixtures/hash-app/source/index.html
|
153
141
|
- fixtures/hash-app/source/stylesheets/_link.sass
|
154
142
|
- fixtures/hash-app/source/stylesheets/page.scss
|
143
|
+
- fixtures/ignore-app/config.rb
|
144
|
+
- fixtures/ignore-app/source/index.html
|
145
|
+
- fixtures/ignore-app/source/stylesheets/nope.scss
|
146
|
+
- fixtures/ignore-app/source/stylesheets/yep.scss
|
147
|
+
- fixtures/inline-app/config.rb
|
148
|
+
- fixtures/inline-app/source/index.html
|
155
149
|
- lib/middleman-autoprefixer.rb
|
156
150
|
- lib/middleman-autoprefixer/extension.rb
|
157
|
-
- lib/middleman-autoprefixer/processor.rb
|
158
151
|
- lib/middleman-autoprefixer/version.rb
|
159
|
-
- lib/middleman_extension.rb
|
160
152
|
- middleman-autoprefixer.gemspec
|
161
153
|
homepage: https://github.com/porada/middleman-autoprefixer
|
162
154
|
licenses:
|
@@ -201,3 +193,9 @@ test_files:
|
|
201
193
|
- fixtures/hash-app/source/index.html
|
202
194
|
- fixtures/hash-app/source/stylesheets/_link.sass
|
203
195
|
- fixtures/hash-app/source/stylesheets/page.scss
|
196
|
+
- fixtures/ignore-app/config.rb
|
197
|
+
- fixtures/ignore-app/source/index.html
|
198
|
+
- fixtures/ignore-app/source/stylesheets/nope.scss
|
199
|
+
- fixtures/ignore-app/source/stylesheets/yep.scss
|
200
|
+
- fixtures/inline-app/config.rb
|
201
|
+
- fixtures/inline-app/source/index.html
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'autoprefixer-rails'
|
2
|
-
|
3
|
-
module Middleman
|
4
|
-
module Autoprefixer
|
5
|
-
class Processor < AutoprefixerRails::Processor
|
6
|
-
def initialize(options)
|
7
|
-
super *to_processor_arguments(options)
|
8
|
-
end
|
9
|
-
|
10
|
-
def postprocess(context, content)
|
11
|
-
begin
|
12
|
-
process(content).css
|
13
|
-
rescue ExecJS::ProgramError => error
|
14
|
-
if error.message =~ /Can't parse CSS/
|
15
|
-
content
|
16
|
-
else
|
17
|
-
raise error
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def configure(sprockets_env)
|
23
|
-
sprockets_env.register_postprocessor 'text/css', :autoprefixer, &method(:postprocess)
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def to_processor_arguments(options)
|
29
|
-
[
|
30
|
-
Array(options.browsers),
|
31
|
-
options.to_h.except(:browsers).reject { |_, value| value.nil? }
|
32
|
-
]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/lib/middleman_extension.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require_relative 'middleman-autoprefixer'
|