autoprefixer-rails 9.8.5 → 9.8.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +7 -6
- data/lib/autoprefixer-rails.rb +3 -3
- data/lib/autoprefixer-rails/processor.rb +20 -56
- data/lib/autoprefixer-rails/railtie.rb +11 -10
- data/lib/autoprefixer-rails/result.rb +2 -0
- data/lib/autoprefixer-rails/sprockets.rb +6 -4
- data/lib/autoprefixer-rails/version.rb +4 -2
- data/lib/rake/autoprefixer_tasks.rb +2 -0
- data/spec/app/Rakefile +3 -1
- data/spec/app/app/controllers/application_controller.rb +2 -0
- data/spec/app/app/controllers/css_controller.rb +2 -0
- data/spec/app/config.ru +3 -1
- data/spec/app/config/application.rb +4 -4
- data/spec/app/config/boot.rb +3 -1
- data/spec/app/config/environment.rb +3 -1
- data/spec/app/config/environments/test.rb +2 -0
- data/spec/app/config/initializers/secret_token.rb +2 -0
- data/spec/app/config/routes.rb +2 -0
- data/spec/autoprefixer_spec.rb +11 -9
- data/spec/processor_spec.rb +7 -5
- data/spec/rails_spec.rb +3 -1
- data/spec/railtie_spec.rb +2 -0
- data/spec/spec_helper.rb +4 -2
- data/vendor/autoprefixer.js +19047 -67005
- metadata +58 -12
- data/Rakefile +0 -53
- data/autoprefixer-rails.gemspec +0 -33
- data/spec/app/.browserslistrc +0 -4
- data/spec/app/.gitignore +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c62892692c2f07e5540401e9c50e334a459077a0ed6a992d7eacbe2c2d1878e
|
4
|
+
data.tar.gz: 70eb5e668e43435c65a78c4288476634eaf73167ca87da7f5cab93dbb39817d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7502d48faf64d234f680ed4ef7aca5cf884b82d0c204b816df9bc77271f30691ac4cf918bca34156ce6f1eef7a3c936fdbe56b0bd49302f65ee01bbc5b89d3af
|
7
|
+
data.tar.gz: bbd1399069a6142f3b02b42f12137c8d5e71572a6ccc6a387c18c18a204366a0215350f332fa21f70760f0345cb87221887049774f1604ab99cdba3fb34d8143
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 9.8.6.4
|
4
|
+
* Remove deprecation warnings.
|
5
|
+
|
6
|
+
## 9.8.6.3
|
7
|
+
* Fix deprecation warning for non-Rails environment.
|
8
|
+
|
9
|
+
## 9.8.6.2
|
10
|
+
* Print deprecation warning only once.
|
11
|
+
|
12
|
+
## 9.8.6.1
|
13
|
+
* Improve deprecated warnings.
|
14
|
+
|
15
|
+
## 9.8.6
|
16
|
+
* Fixed `env` option.
|
17
|
+
* Added deprecation warning.
|
18
|
+
|
3
19
|
## 9.8.5
|
4
20
|
* Improved Grid Layout warnings (by Daniel Tonon).
|
5
21
|
|
data/README.md
CHANGED
@@ -5,17 +5,18 @@
|
|
5
5
|
title="Autoprefixer logo by Anton Lovchikov">
|
6
6
|
|
7
7
|
[Autoprefixer] is a tool to parse CSS and add vendor prefixes to CSS rules
|
8
|
-
using values from the [Can I Use] database. This gem provides Ruby
|
9
|
-
integration with this JavaScript tool.
|
8
|
+
using values from the [Can I Use] database. This gem provides Ruby
|
9
|
+
and Ruby on Rails integration with this JavaScript tool.
|
10
10
|
|
11
11
|
<a href="https://evilmartians.com/?utm_source=autoprefixer-rails">
|
12
12
|
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54">
|
13
13
|
</a>
|
14
14
|
|
15
|
-
[Autoprefixer]:
|
16
|
-
[Can I Use]:
|
17
|
-
[
|
18
|
-
[ci]:
|
15
|
+
[Autoprefixer]: https://github.com/postcss/autoprefixer
|
16
|
+
[Can I Use]: http://caniuse.com/
|
17
|
+
[PostCSS]: https://postcss.org/
|
18
|
+
[ci-img]: https://travis-ci.org/ai/autoprefixer-rails.svg
|
19
|
+
[ci]: https://travis-ci.org/ai/autoprefixer-rails
|
19
20
|
|
20
21
|
## Differences
|
21
22
|
|
data/lib/autoprefixer-rails.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Ruby integration with Autoprefixer JS library, which parse CSS and adds
|
2
4
|
# only actual prefixed
|
3
5
|
module AutoprefixerRails
|
@@ -6,9 +8,7 @@ module AutoprefixerRails
|
|
6
8
|
# Add prefixes to `css`. See `Processor#process` for options.
|
7
9
|
def self.process(css, opts = {})
|
8
10
|
params = {}
|
9
|
-
if opts.key?(:overrideBrowserslist)
|
10
|
-
params[:overrideBrowserslist] = opts.delete(:overrideBrowserslist)
|
11
|
-
end
|
11
|
+
params[:overrideBrowserslist] = opts.delete(:overrideBrowserslist) if opts.key?(:overrideBrowserslist)
|
12
12
|
params[:browsers] = opts.delete(:browsers) if opts.key?(:browsers)
|
13
13
|
params[:cascade] = opts.delete(:cascade) if opts.key?(:cascade)
|
14
14
|
params[:remove] = opts.delete(:remove) if opts.key?(:remove)
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "pathname"
|
2
4
|
require "execjs"
|
3
5
|
require "json"
|
4
6
|
|
5
|
-
IS_SECTION = /^\s*\[(.+)\]\s
|
7
|
+
IS_SECTION = /^\s*\[(.+)\]\s*$/.freeze
|
6
8
|
|
7
9
|
module AutoprefixerRails
|
8
10
|
# Ruby to JS wrapper for Autoprefixer processor instance
|
@@ -20,23 +22,18 @@ module AutoprefixerRails
|
|
20
22
|
def process(css, opts = {})
|
21
23
|
opts = convert_options(opts)
|
22
24
|
|
23
|
-
apply_wrapper =
|
24
|
-
"(function(opts, pluginOpts) {" \
|
25
|
-
"return eval(process.apply(this, opts, pluginOpts));" \
|
26
|
-
"})"
|
27
|
-
|
28
25
|
plugin_opts = params_with_browsers(opts[:from]).merge(opts)
|
29
26
|
process_opts = {
|
30
27
|
from: plugin_opts.delete(:from),
|
31
28
|
to: plugin_opts.delete(:to),
|
32
|
-
map: plugin_opts.delete(:map)
|
29
|
+
map: plugin_opts.delete(:map)
|
33
30
|
}
|
34
31
|
|
35
32
|
begin
|
36
|
-
result = runtime.call(
|
33
|
+
result = runtime.call("autoprefixer.process", css, process_opts, plugin_opts)
|
37
34
|
rescue ExecJS::ProgramError => e
|
38
35
|
contry_error = "BrowserslistError: " \
|
39
|
-
"Country statistics
|
36
|
+
"Country statistics are not supported " \
|
40
37
|
"in client-side build of Browserslist"
|
41
38
|
if e.message == contry_error
|
42
39
|
raise "Country statistics is not supported in AutoprefixerRails. " \
|
@@ -51,18 +48,18 @@ module AutoprefixerRails
|
|
51
48
|
|
52
49
|
# Return, which browsers and prefixes will be used
|
53
50
|
def info
|
54
|
-
runtime.
|
51
|
+
runtime.call("autoprefixer.info", params_with_browsers)
|
55
52
|
end
|
56
53
|
|
57
54
|
# Parse Browserslist config
|
58
55
|
def parse_config(config)
|
59
|
-
sections = {"defaults" => []}
|
56
|
+
sections = { "defaults" => [] }
|
60
57
|
current = "defaults"
|
61
58
|
config.gsub(/#[^\n]*/, "")
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
.split(/\n/)
|
60
|
+
.map(&:strip)
|
61
|
+
.reject(&:empty?)
|
62
|
+
.each do |line|
|
66
63
|
if IS_SECTION =~ line
|
67
64
|
current = line.match(IS_SECTION)[1].strip
|
68
65
|
sections[current] ||= []
|
@@ -77,10 +74,10 @@ module AutoprefixerRails
|
|
77
74
|
|
78
75
|
def params_with_browsers(from = nil)
|
79
76
|
from ||= if defined?(Rails) && Rails.respond_to?(:root) && Rails.root
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
77
|
+
Rails.root.join("app/assets/stylesheets").to_s
|
78
|
+
else
|
79
|
+
"."
|
80
|
+
end
|
84
81
|
|
85
82
|
params = @params
|
86
83
|
if !params.key?(:browsers) && !params.key?(:overrideBrowserslist) && from
|
@@ -96,13 +93,6 @@ module AutoprefixerRails
|
|
96
93
|
params
|
97
94
|
end
|
98
95
|
|
99
|
-
# Convert params to JS string and add browsers from Browserslist config
|
100
|
-
def js_params
|
101
|
-
"{ " +
|
102
|
-
params_with_browsers.map { |k, v| "#{k}: #{v.inspect}"}.join(", ") +
|
103
|
-
" }"
|
104
|
-
end
|
105
|
-
|
106
96
|
# Convert ruby_options to jsOptions
|
107
97
|
def convert_options(opts)
|
108
98
|
converted = {}
|
@@ -152,43 +142,17 @@ module AutoprefixerRails
|
|
152
142
|
if ExecJS.runtime == ExecJS::Runtimes::Node
|
153
143
|
version = ExecJS.runtime.eval("process.version")
|
154
144
|
first = version.match(/^v(\d+)/)[1].to_i
|
155
|
-
if first < 6
|
156
|
-
raise "Autoprefixer doesn’t support Node #{version}. Update it."
|
157
|
-
end
|
145
|
+
raise "Autoprefixer doesn’t support Node #{version}. Update it." if first < 6
|
158
146
|
end
|
159
147
|
|
160
148
|
ExecJS.compile(build_js)
|
161
149
|
end
|
162
150
|
end
|
163
151
|
|
164
|
-
# Cache autoprefixer.js content
|
165
|
-
def read_js
|
166
|
-
@@js ||= begin
|
167
|
-
root = Pathname(File.dirname(__FILE__))
|
168
|
-
path = root.join("../../vendor/autoprefixer.js")
|
169
|
-
path.read
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
# Return processor JS with some extra methods
|
174
152
|
def build_js
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
# Return JS code for process method proxy
|
179
|
-
def process_proxy
|
180
|
-
<<-JS
|
181
|
-
var processor;
|
182
|
-
var process = function() {
|
183
|
-
var result = autoprefixer.process.apply(autoprefixer, arguments);
|
184
|
-
var warns = result.warnings().map(function (i) {
|
185
|
-
delete i.plugin;
|
186
|
-
return i.toString();
|
187
|
-
});
|
188
|
-
var map = result.map ? result.map.toString() : null;
|
189
|
-
return { css: result.css, map: map, warnings: warns };
|
190
|
-
};
|
191
|
-
JS
|
153
|
+
root = Pathname(File.dirname(__FILE__))
|
154
|
+
path = root.join("../../vendor/autoprefixer.js")
|
155
|
+
path.read
|
192
156
|
end
|
193
157
|
end
|
194
158
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "yaml"
|
2
4
|
|
3
5
|
begin
|
4
6
|
module AutoprefixedRails
|
5
|
-
class Railtie < ::Rails::Railtie
|
7
|
+
class Railtie < ::Rails::Railtie # :nodoc:
|
6
8
|
rake_tasks do |app|
|
7
9
|
require "rake/autoprefixer_tasks"
|
8
10
|
Rake::AutoprefixerTasks.new(config) if defined? app.assets
|
@@ -14,9 +16,7 @@ begin
|
|
14
16
|
end
|
15
17
|
else
|
16
18
|
initializer :setup_autoprefixer, group: :all do |app|
|
17
|
-
if defined?(app.assets) && !app.assets.nil?
|
18
|
-
AutoprefixerRails.install(app.assets, config)
|
19
|
-
end
|
19
|
+
AutoprefixerRails.install(app.assets, config) if defined?(app.assets) && !app.assets.nil?
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -27,13 +27,14 @@ begin
|
|
27
27
|
roots.each do |root|
|
28
28
|
file = File.join(root, "config/autoprefixer.yml")
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
next unless File.exist?(file)
|
31
|
+
|
32
|
+
parsed = ::YAML.load_file(file)
|
33
|
+
next unless parsed
|
34
|
+
|
35
|
+
params = parsed
|
34
36
|
|
35
|
-
|
36
|
-
end
|
37
|
+
break
|
37
38
|
end
|
38
39
|
|
39
40
|
params = params.symbolize_keys
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "pathname"
|
2
4
|
|
3
5
|
module AutoprefixerRails
|
@@ -30,10 +32,10 @@ module AutoprefixerRails
|
|
30
32
|
def self.install(env)
|
31
33
|
if ::Sprockets::VERSION.to_f < 4
|
32
34
|
env.register_postprocessor("text/css",
|
33
|
-
|
35
|
+
::AutoprefixerRails::Sprockets)
|
34
36
|
else
|
35
37
|
env.register_bundle_processor("text/css",
|
36
|
-
|
38
|
+
::AutoprefixerRails::Sprockets)
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
@@ -41,10 +43,10 @@ module AutoprefixerRails
|
|
41
43
|
def self.uninstall(env)
|
42
44
|
if ::Sprockets::VERSION.to_f < 4
|
43
45
|
env.unregister_postprocessor("text/css",
|
44
|
-
|
46
|
+
::AutoprefixerRails::Sprockets)
|
45
47
|
else
|
46
48
|
env.unregister_bundle_processor("text/css",
|
47
|
-
|
49
|
+
::AutoprefixerRails::Sprockets)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
data/spec/app/Rakefile
CHANGED
data/spec/app/config.ru
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("boot", __dir__)
|
2
4
|
|
3
5
|
require "action_controller/railtie"
|
4
6
|
require "sprockets/railtie"
|
5
7
|
|
6
|
-
if defined?(Bundler)
|
7
|
-
Bundler.require(*Rails.groups(assets: %w[development test]))
|
8
|
-
end
|
8
|
+
Bundler.require(*Rails.groups(assets: %w[development test])) if defined?(Bundler)
|
9
9
|
|
10
10
|
module App
|
11
11
|
class Application < Rails::Application
|
data/spec/app/config/boot.rb
CHANGED
data/spec/app/config/routes.rb
CHANGED
data/spec/autoprefixer_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "spec_helper"
|
2
4
|
|
3
5
|
describe AutoprefixerRails do
|
@@ -42,26 +44,26 @@ describe AutoprefixerRails do
|
|
42
44
|
end
|
43
45
|
|
44
46
|
it "generates separated source map" do
|
45
|
-
result = AutoprefixerRails.process(@css, map: {inline: false})
|
47
|
+
result = AutoprefixerRails.process(@css, map: { inline: false })
|
46
48
|
expect(result.map).to be_a(String)
|
47
49
|
end
|
48
50
|
|
49
51
|
it "uses file name in syntax errors", not_jruby: true do
|
50
|
-
expect
|
52
|
+
expect do
|
51
53
|
AutoprefixerRails.process("a {", from: "a.css")
|
52
|
-
|
54
|
+
end.to raise_error(/a.css:/)
|
53
55
|
end
|
54
56
|
|
55
57
|
it "includes sourcesContent by default" do
|
56
|
-
map = AutoprefixerRails.process("a{}", map: {inline: false}).map
|
58
|
+
map = AutoprefixerRails.process("a{}", map: { inline: false }).map
|
57
59
|
expect(map).to include("sourcesContent")
|
58
60
|
end
|
59
61
|
|
60
62
|
it "maps options from Ruby style" do
|
61
63
|
map = AutoprefixerRails.process("a{}", map: {
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
sources_content: false,
|
65
|
+
inline: false
|
66
|
+
}).map
|
65
67
|
|
66
68
|
expect(map).not_to include("sourcesContent")
|
67
69
|
end
|
@@ -86,9 +88,9 @@ describe AutoprefixerRails do
|
|
86
88
|
end
|
87
89
|
|
88
90
|
it "shows correct error on country statistics" do
|
89
|
-
expect
|
91
|
+
expect do
|
90
92
|
AutoprefixerRails.process("", overrideBrowserslist: "> 1% in US")
|
91
|
-
|
93
|
+
end.to raise_error(/Use Autoprefixer with webpack/)
|
92
94
|
end
|
93
95
|
|
94
96
|
context "Sprockets" do
|
data/spec/processor_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "spec_helper"
|
2
4
|
|
3
5
|
describe AutoprefixerRails::Processor do
|
@@ -5,9 +7,9 @@ describe AutoprefixerRails::Processor do
|
|
5
7
|
config = "# Comment\n ie 11\n \nie 8 # sorry\n[test ]\nios 8"
|
6
8
|
processor = AutoprefixerRails::Processor.new
|
7
9
|
expect(processor.parse_config(config)).to eql({
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
"defaults" => ["ie 11", "ie 8"],
|
11
|
+
"test" => ["ios 8"]
|
12
|
+
})
|
11
13
|
end
|
12
14
|
|
13
15
|
context "without Rails" do
|
@@ -17,9 +19,9 @@ describe AutoprefixerRails::Processor do
|
|
17
19
|
|
18
20
|
it "doesn't raise error during processing" do
|
19
21
|
processor = AutoprefixerRails::Processor.new
|
20
|
-
expect
|
22
|
+
expect do
|
21
23
|
processor.process("")
|
22
|
-
|
24
|
+
end.not_to raise_error
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|