middleman-autoprefixer 1.0.1 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bc122b90ef1daf0fae615ab8afe11ed6b46d78b
4
- data.tar.gz: 85b53eb2ae0361cc7c73c81811ecff786f66b5ba
3
+ metadata.gz: 697ac4ef72021e86f320da0507a6c286cdc9ac39
4
+ data.tar.gz: 5b6260b627ef3e540b8bf7a7f6f17e3872ddddd5
5
5
  SHA512:
6
- metadata.gz: ab86bda2a41445f282b5e79a12ebd3cfec3dedb1ed7a56b34316809c6eb9ae7a03cab22d822330a9e25e5c82c575b946a88139421f95c4024b0c89ead6f98378
7
- data.tar.gz: 4f2a16bca4964a51478457f92ceefc54c39c033c9a0fbcf61ce8b739f3ccbccfde129ca6de0633069f2e76288088af339a4115faf68097200d3131930ff2ca26
6
+ metadata.gz: ebd61b6ebb36d00e598ca156e1d4b48faf313a22a2734df4ea4dee7cecfce3a9a1161a1462f037bf451404691f5dcb26f2aae16565115a8847adbd2a814e743c
7
+ data.tar.gz: 051bd3eb5f1fa41d168d8ff1638fc49f0d0465496cb88853ef4189a8a1ea71f7b017470634e7afad9b3b1cc7e2626c4a5a6ed93de55a6d58afb33db479c267fc
data/.travis.yml CHANGED
@@ -1,9 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 1.9.3
3
4
  - 2.0.0
4
5
  - 2.1.0
5
6
  script:
6
- - bundle install --jobs=4
7
+ - bundle install
7
8
  - bundle exec rake test
8
9
  - bundle exec rake install
9
10
  - middleman version
data/README.md CHANGED
@@ -15,10 +15,21 @@ gem 'middleman-autoprefixer'
15
15
  After installation, activate the extension in `config.rb`:
16
16
 
17
17
  ```ruby
18
- activate :autoprefixer, browsers: ['last 2 versions', 'Explorer >= 9']
18
+ activate :autoprefixer
19
19
  ```
20
20
 
21
- The optional `browsers` field takes a string or array of strings accordingly to [Autoprefixer’s documentation](https://github.com/ai/autoprefixer#browsers).
21
+ ## Configuration
22
+
23
+ The extension has 2 optionally configurable fields:
24
+
25
+ ```ruby
26
+ activate :autoprefixer do |config|
27
+ config.browsers = ['last 2 versions', 'Explorer >= 9']
28
+ config.cascade = false
29
+ end
30
+ ```
31
+
32
+ Both fields take values (and use defaults) accordingly to [Autoprefixer’s](https://github.com/ai/autoprefixer#browsers) [documentation](https://github.com/ai/autoprefixer#visual-cascade).
22
33
 
23
34
  ## License
24
35
 
@@ -1,13 +1,39 @@
1
- Feature: Postprocessing stylesheets with Autoprefixer
1
+ Feature: Postprocessing stylesheets with Autoprefixer in different configurations
2
2
 
3
- Scenario: Options are passed in a block
3
+ Scenario: Using defaults
4
+ Given the Server is running at "default-app"
5
+ When I go to "/stylesheets/page.css"
6
+ Then I should not see "-ms-border-radius"
7
+ And I should see "border-radius"
8
+
9
+ Scenario: Passing options in a block
4
10
  Given the Server is running at "block-app"
5
11
  When I go to "/stylesheets/page.css"
6
12
  Then I should see "-webkit-linear-gradient"
7
- Then I should see "-moz-linear-gradient"
13
+ And I should see "-moz-linear-gradient"
8
14
 
9
- Scenario: Options are passed in a hash
15
+ Scenario: Passing options in a hash
10
16
  Given the Server is running at "hash-app"
11
17
  When I go to "/stylesheets/page.css"
12
18
  Then I should see "-webkit-transition"
13
- Then I should not see "-moz-transition"
19
+ And I should not see "-moz-transition"
20
+
21
+ Scenario: Cascading is on
22
+ Given the Server is running at "cascading-on-app"
23
+ When I go to "/stylesheets/page.css"
24
+ Then I should see:
25
+ """
26
+ -webkit-box-sizing: border-box;
27
+ -moz-box-sizing: border-box;
28
+ box-sizing: border-box;
29
+ """
30
+
31
+ Scenario: Cascading is off
32
+ Given the Server is running at "cascading-off-app"
33
+ When I go to "/stylesheets/page.css"
34
+ Then I should see:
35
+ """
36
+ -webkit-box-sizing: border-box;
37
+ -moz-box-sizing: border-box;
38
+ box-sizing: border-box;
39
+ """
@@ -1,3 +1,4 @@
1
1
  activate :autoprefixer do |config|
2
2
  config.browsers = ['Chrome 25', 'Firefox 15']
3
+ config.cascade = true
3
4
  end
@@ -0,0 +1,5 @@
1
+ activate :autoprefixer, browsers: ['Safari 5', 'Firefox 15'], cascade: false
2
+
3
+ compass_config do |config|
4
+ config.output_style = :expanded
5
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ * {
2
+ box-sizing: border-box;
3
+ }
@@ -0,0 +1,8 @@
1
+ activate :autoprefixer do |config|
2
+ config.browsers = ['Safari 5', 'Firefox 15']
3
+ config.cascade = true
4
+ end
5
+
6
+ compass_config do |config|
7
+ config.output_style = :expanded
8
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ * {
2
+ box-sizing: border-box;
3
+ }
@@ -0,0 +1 @@
1
+ activate :autoprefixer
File without changes
@@ -0,0 +1,4 @@
1
+ input {
2
+ -ms-border-radius: 5px;
3
+ border-radius: 5px;
4
+ }
@@ -1 +1 @@
1
- activate :autoprefixer, browsers: 'Safari 6'
1
+ activate :autoprefixer, browsers: 'Safari 6', cascade: false
@@ -1,27 +1,15 @@
1
- require 'ostruct'
2
- require 'autoprefixer-rails'
1
+ require_relative 'options'
2
+ require_relative 'processor'
3
3
 
4
4
  module Middleman
5
5
  module Autoprefixer
6
- class Options < OpenStruct; end
7
-
8
6
  class << self
9
- def registered(app, options_hash={}, &block)
7
+ def registered(app, options_hash = {}, &block)
10
8
  @@options = Options.new(options_hash)
11
9
  yield @@options if block_given?
12
10
 
13
- browsers = Array(@@options.browsers)
14
- browsers = nil if browsers.empty?
15
-
16
11
  app.after_configuration do
17
- autoprefixer = AutoprefixerRails::Processor.new(browsers)
18
- sprockets.register_postprocessor 'text/css', :autoprefixer do |_, data|
19
- begin
20
- autoprefixer.process(data).css
21
- rescue
22
- data
23
- end
24
- end
12
+ Processor.new(*@@options.params).configure(sprockets)
25
13
  end
26
14
  end
27
15
  alias :included :registered
@@ -0,0 +1,25 @@
1
+ module Middleman
2
+ module Autoprefixer
3
+ class Options
4
+ attr_writer :browsers
5
+ attr_reader :config
6
+
7
+ def initialize(options_hash = {})
8
+ @browsers = options_hash[:browsers]
9
+ @config = options_hash.slice(:cascade)
10
+ end
11
+
12
+ def browsers
13
+ Array(@browsers)
14
+ end
15
+
16
+ def cascade=(value)
17
+ @config.merge!(cascade: value)
18
+ end
19
+
20
+ def params
21
+ [browsers, config]
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ require 'autoprefixer-rails'
2
+
3
+ module Middleman
4
+ module Autoprefixer
5
+ class Processor < AutoprefixerRails::Processor
6
+ def postprocess(context, content)
7
+ begin
8
+ process(content).css
9
+ rescue ExecJS::ProgramError => error
10
+ if error.message =~ /Can't parse CSS/
11
+ content
12
+ else
13
+ raise error
14
+ end
15
+ end
16
+ end
17
+
18
+ def configure(sprockets_env)
19
+ sprockets_env.register_postprocessor 'text/css', :autoprefixer, &method(:postprocess)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Autoprefixer
3
- VERSION = '1.0.1'
3
+ VERSION = '1.1.0'.freeze
4
4
  end
5
5
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.require_paths = ['lib']
18
18
 
19
19
  spec.add_dependency 'middleman', '~> 3.2.0'
20
- spec.add_dependency 'autoprefixer-rails', '~> 1.1.0'
20
+ spec.add_dependency 'autoprefixer-rails', '~> 1.1.20140302'
21
21
 
22
22
  spec.add_development_dependency 'bundler', '~> 1.5.3'
23
23
  spec.add_development_dependency 'rake', '~> 10.1.1'
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-autoprefixer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Porada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-23 00:00:00.000000000 Z
11
+ date: 2014-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: autoprefixer-rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.1.0
33
+ version: 1.1.20140302
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.1.0
40
+ version: 1.1.20140302
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.5.3
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.5.3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 10.1.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 10.1.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: cucumber
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.3.10
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.3.10
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: aruba
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.5.4
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.5.4
97
97
  description:
@@ -101,8 +101,8 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - .gitignore
105
- - .travis.yml
104
+ - ".gitignore"
105
+ - ".travis.yml"
106
106
  - Gemfile
107
107
  - README.md
108
108
  - Rakefile
@@ -111,12 +111,23 @@ files:
111
111
  - fixtures/block-app/config.rb
112
112
  - fixtures/block-app/source/index.html
113
113
  - fixtures/block-app/source/stylesheets/page.scss
114
+ - fixtures/cascading-off-app/config.rb
115
+ - fixtures/cascading-off-app/source/index.html
116
+ - fixtures/cascading-off-app/source/stylesheets/page.scss
117
+ - fixtures/cascading-on-app/config.rb
118
+ - fixtures/cascading-on-app/source/index.html
119
+ - fixtures/cascading-on-app/source/stylesheets/page.scss
120
+ - fixtures/default-app/config.rb
121
+ - fixtures/default-app/source/index.html
122
+ - fixtures/default-app/source/stylesheets/page.scss
114
123
  - fixtures/hash-app/config.rb
115
124
  - fixtures/hash-app/source/index.html
116
125
  - fixtures/hash-app/source/stylesheets/_link.sass
117
126
  - fixtures/hash-app/source/stylesheets/page.scss
118
127
  - lib/middleman-autoprefixer.rb
119
128
  - lib/middleman-autoprefixer/extension.rb
129
+ - lib/middleman-autoprefixer/options.rb
130
+ - lib/middleman-autoprefixer/processor.rb
120
131
  - lib/middleman-autoprefixer/version.rb
121
132
  - lib/middleman_extension.rb
122
133
  - middleman-autoprefixer.gemspec
@@ -130,12 +141,12 @@ require_paths:
130
141
  - lib
131
142
  required_ruby_version: !ruby/object:Gem::Requirement
132
143
  requirements:
133
- - - '>='
144
+ - - ">="
134
145
  - !ruby/object:Gem::Version
135
146
  version: '0'
136
147
  required_rubygems_version: !ruby/object:Gem::Requirement
137
148
  requirements:
138
- - - '>='
149
+ - - ">="
139
150
  - !ruby/object:Gem::Version
140
151
  version: '0'
141
152
  requirements: []
@@ -150,6 +161,15 @@ test_files:
150
161
  - fixtures/block-app/config.rb
151
162
  - fixtures/block-app/source/index.html
152
163
  - fixtures/block-app/source/stylesheets/page.scss
164
+ - fixtures/cascading-off-app/config.rb
165
+ - fixtures/cascading-off-app/source/index.html
166
+ - fixtures/cascading-off-app/source/stylesheets/page.scss
167
+ - fixtures/cascading-on-app/config.rb
168
+ - fixtures/cascading-on-app/source/index.html
169
+ - fixtures/cascading-on-app/source/stylesheets/page.scss
170
+ - fixtures/default-app/config.rb
171
+ - fixtures/default-app/source/index.html
172
+ - fixtures/default-app/source/stylesheets/page.scss
153
173
  - fixtures/hash-app/config.rb
154
174
  - fixtures/hash-app/source/index.html
155
175
  - fixtures/hash-app/source/stylesheets/_link.sass