roger_autoprefixer 1.1.0 → 1.2.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,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZjQyZDUwZjJmYTM4NDRhZTM3OWMyOGQyM2Y3OGJmZmVjZWYwMzBjYg==
5
- data.tar.gz: !binary |-
6
- ZjA2OWY1NmY3NTJhYTQ4N2JiNDVmNjliNGJhYWJkOTllN2E2ZTlmZA==
2
+ SHA1:
3
+ metadata.gz: da46e420e9961eeffd59e7d82640cbb0c87eb09c
4
+ data.tar.gz: df74371bb7b8472f92c83273a52f1f3ad549aca1
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MDFhYjgzMDhmMjlhZDY1YjZkZjY5YzQ3MTA2MDJkY2VhNDBjY2FmY2U4Njdk
10
- NzkyMGYzOWJiOTVmNDY1OTIxZWU1MjlhZjJkNzczMjkxZThmOWVjNDI4ZjFk
11
- MTZjNTc2NzM5Y2NiNTkzZTBiYzFmOTY0OGU1ZmUzODk5YjM2ZDA=
12
- data.tar.gz: !binary |-
13
- MTEyOWJmYmI0YWVkNGNhZWIyOTI3ZmM2OTkxYjhlZGNlNGZlMjQyZGY3OWI2
14
- YTUyZmRmNDIyYmVkMTZmYjU4ZjVlNTMwN2Y1YTU5OWMzY2JhMWYyNDA4YmMx
15
- OGRiNjM5MmEzMTA4N2JhNWYxMmM2MjdiZDZiYzY4NzI4MzdiMTg=
6
+ metadata.gz: e086179d04e9b081019cf8bf264f6d5912cdaa6b098d2853c04066a4b17a47d062124241b75e84d1accaf6416e23634a68d44fba5ef25401ca7321795ebf6fe2
7
+ data.tar.gz: 0a9a0efa59ae63049b35aeb5734a3f26659948a0c5223267bafa04bc0213d7dd176b53302240ed7114f3b6040735c8fd042ec77376d9ea63bbfd0689325e5e89
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ Gemfile.lock
data/.rubocop.yml ADDED
@@ -0,0 +1,47 @@
1
+ LineLength:
2
+ Description: 'Limit lines to 100 characters.'
3
+ Max: 100
4
+ Enabled: true
5
+
6
+ StringLiterals:
7
+ EnforcedStyle: double_quotes
8
+ Enabled: true
9
+
10
+ Style/DotPosition:
11
+ EnforcedStyle: trailing
12
+ Enabled: true
13
+
14
+ Metrics/MethodLength:
15
+ CountComments: false # count full line comments?
16
+ Max: 20
17
+
18
+ Metrics/AbcSize:
19
+ Max: 20
20
+
21
+ Style/ClassAndModuleChildren:
22
+ EnforcedStyle: compact
23
+ Enabled: false
24
+
25
+ # By default, the rails cops are not run. Override in project or home
26
+ # directory .rubocop.yml files, or by giving the -R/--rails option.
27
+ AllCops:
28
+ RunRailsCops: false
29
+
30
+ # Disabled cops
31
+ Metrics/ClassLength:
32
+ Enabled: false
33
+
34
+ Metrics/ModuleLength:
35
+ Enabled: false
36
+
37
+ Style/EachWithObject:
38
+ Enabled: false
39
+
40
+ Style/AccessorMethodName:
41
+ Enabled: false
42
+
43
+ Lint/AssignmentInCondition:
44
+ Enabled: false
45
+
46
+ Style/SingleLineBlockParams:
47
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ sudo: false
3
+ rvm:
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in roger_autoprefixer.gemspec
4
+ gemspec
5
+
6
+ # Add default runtime for ExecJS
7
+ gem "therubyracer"
8
+
9
+ gem "pry"
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ require "rubocop/rake_task"
4
+
5
+ task default: [:test]
6
+
7
+ desc "Run rubocop"
8
+ task :rubocop do
9
+ RuboCop::RakeTask.new
10
+ end
11
+
12
+ Rake::TestTask.new do |t|
13
+ t.libs << "test"
14
+ t.test_files = FileList["test/*_test.rb"]
15
+ t.verbose = false
16
+ end
@@ -1,40 +1,41 @@
1
+ require File.dirname(__FILE__) + "/./transformer"
2
+ require "rack/response"
3
+
1
4
  module RogerAutoprefixer
5
+ # Middleware
6
+ # Rack middleware to transform from unprefixed css to css with vendor prefixes
2
7
  class Middleware
3
- # Middleware
4
- #
5
- # @option options [Array] :skip Array of regexp Skip certain URL's
6
- # @option options [Array] :browsers Browsers to do autporefixing for passed to AutoprefixerRails
7
- def initialize(app, options={})
8
+ # @option options [Array] :skip Array of regexp Skip certain URL's
9
+ # @option options [Array] :browsers Browsers to do autporefixing for passed to AutoprefixerRails
10
+ def initialize(app, options = {})
8
11
  @app = app
9
12
  @options = {
10
- :skip => [],
11
- :browsers => nil
13
+ skip: [],
14
+ browsers: nil
12
15
  }.update(options)
13
16
  end
14
17
 
15
18
  def call(env)
16
19
  status, headers, body = @app.call(env)
17
-
18
- if status == 200 && headers["Content-Type"].to_s.include?("text/css") && !@options[:skip].detect{|r| r.match(env["PATH_INFO"]) }
20
+
21
+ if status == 200 && headers["Content-Type"].to_s.include?("text/css") && !@options[:skip].detect { |r| r.match(env["PATH_INFO"]) }
19
22
  body_str = []
20
- body.each{|f| body_str << f }
23
+ body.each { |f| body_str << f }
21
24
  body_str = body_str.join
22
-
25
+
23
26
  # This is a dirty little hack to always enforce UTF8
24
27
  body_str.force_encoding("UTF-8")
25
28
 
26
29
  prefixer_options = {
27
- :from => env["PATH_INFO"]
30
+ from: env["PATH_INFO"]
28
31
  }
29
32
 
30
- if @options[:browsers]
31
- prefixer_options[:browsers] = @options[:browsers]
32
- end
33
-
34
- Rack::Response.new(AutoprefixerRails.process(body_str, prefixer_options).css, status, headers).finish
33
+ prefixer_options[:browsers] = @options[:browsers] if @options[:browsers]
34
+
35
+ Rack::Response.new(Transformer.instance.transform(body_str, prefixer_options), status, headers).finish
35
36
  else
36
37
  [status, headers, body]
37
38
  end
38
39
  end
39
40
  end
40
- end
41
+ end
@@ -5,13 +5,13 @@ module RogerAutoprefixer
5
5
  # @option options [Array] :match An array of shell globs, defaults to ["stylesheets/**/*.scss"]
6
6
  # @option options [Array] :skip An array of regexps which will be skipped, defaults to [/_.*\.scss\Z/], Attention! Skipped files will be deleted as well!
7
7
  # @option options [Array] :browsers Browsers to do autporefixing for passed to AutoprefixerRails
8
- def call(release, options={})
8
+ def call(release, options = {})
9
9
  options = {
10
- :match => ["stylesheets/**/*.css"],
11
- :skip => [],
12
- :browsers => nil
10
+ match: ["stylesheets/**/*.css"],
11
+ skip: [],
12
+ browsers: nil
13
13
  }.update(options)
14
-
14
+
15
15
  match = options.delete(:match)
16
16
  skip = options.delete(:skip)
17
17
 
@@ -21,21 +21,21 @@ module RogerAutoprefixer
21
21
  if options[:browsers]
22
22
  prefixer_options[:browsers] = options[:browsers]
23
23
  end
24
-
24
+
25
25
  # Prefix CSS files
26
26
  files = release.get_files(match)
27
27
  files.each do |f|
28
- if !skip.detect{|r| r.match(f) }
29
- release.log(self, "Processing: #{f}")
28
+ if !skip.detect { |r| r.match(f) }
29
+ release.log(self, "Processing: #{f}")
30
30
  # Compile SCSS
31
31
  content = File.read(f)
32
32
  File.open(f, "w") do |fh|
33
- fh.write AutoprefixerRails.process(content, prefixer_options.dup.update({:from => f})).css
33
+ fh.write AutoprefixerRails.process(content, prefixer_options.dup.update(from: f)).css
34
34
  end
35
- end
35
+ end
36
36
  end
37
- end
37
+ end
38
38
  end
39
39
  end
40
40
 
41
- Roger::Release::Processors.register(:autoprefixer, RogerAutoprefixer::Processor)
41
+ Roger::Release::Processors.register(:autoprefixer, RogerAutoprefixer::Processor)
@@ -0,0 +1,21 @@
1
+ require "singleton"
2
+ require 'autoprefixer-rails'
3
+
4
+ # The transformer will take care of thread safe transformation of css without
5
+ # vendor prefixes -> css with vendor prefixes using autoprefixer.
6
+ # We need this to prevent deadlock in the V8 engine.
7
+ class Transformer
8
+ include Singleton
9
+
10
+ def initialize
11
+ @mutex = Mutex.new
12
+ end
13
+
14
+ def transform(code, options)
15
+ prefixer = nil
16
+ @mutex.synchronize do
17
+ prefixer = AutoprefixerRails.process(code, options)
18
+ end
19
+ prefixer.css
20
+ end
21
+ end
@@ -1,9 +1,6 @@
1
1
  module RogerAutoprefixer
2
2
  end
3
3
 
4
- # Dependencies
5
- require 'autoprefixer-rails'
6
-
7
4
  # Load modules
8
5
  require File.dirname(__FILE__) + "/roger_autoprefixer/middleware"
9
- require File.dirname(__FILE__) + "/roger_autoprefixer/processor"
6
+ require File.dirname(__FILE__) + "/roger_autoprefixer/processor"
@@ -2,23 +2,29 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "roger_autoprefixer"
5
- s.version = "1.1.0"
6
-
5
+ s.version = "1.2.0"
6
+
7
7
  s.authors = ["Flurin Egger"]
8
- s.email = ["info@digitpaint.nl", "flurin@digitpaint.nl"]
8
+ s.email = ["info@digitpaint.nl", "flurin@digitpaint.nl"]
9
9
  s.homepage = "http://github.com/digitpaint/roger_autoprefixer"
10
10
  s.summary = "Rack middleware and processor for using autoprefixer with Roger."
11
11
  s.licenses = ["MIT"]
12
12
 
13
13
  s.date = Time.now.strftime("%Y-%m-%d")
14
-
14
+
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- s.require_paths = ["lib"]
19
-
20
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ if s.respond_to? :required_rubygems_version=
21
+ s.required_rubygems_version = Gem::Requirement.new(">= 0")
22
+ end
21
23
 
22
24
  s.add_dependency("roger", [">= 0.11.0"])
23
25
  s.add_dependency("autoprefixer-rails", [">= 5.0.0"])
26
+
27
+ s.add_development_dependency "rake", "~> 10.0"
28
+ s.add_development_dependency "test-unit", "~> 3.1.2"
29
+ s.add_development_dependency "rubocop", "~> 0.31.0"
24
30
  end
@@ -0,0 +1,3 @@
1
+ .blaat {
2
+ display: flex;
3
+ }
@@ -0,0 +1,26 @@
1
+ require "test_helper"
2
+ require "rack"
3
+ require_relative "../lib/roger_autoprefixer/middleware"
4
+
5
+ module RogerAutoprefixer
6
+ class MiddlewareTest < ::Test::Unit::TestCase
7
+ def build_stack(file, options = {})
8
+ fixture = File.read(File.dirname(__FILE__) + "/fixtures/" + file)
9
+
10
+ # Always respond with the file contents in this little app
11
+ app = proc {
12
+ [200, {
13
+ "Content-Type" => "text/css"
14
+ }, [fixture]] }
15
+
16
+ stack = Middleware.new(app, options)
17
+ Rack::MockRequest.new(stack)
18
+ end
19
+
20
+ def test_middleware_processor
21
+ response = build_stack("flex.css").get("/javascripts/src/test.js")
22
+ assert response.body.include?("-webkit-flex;")
23
+ assert_equal response.status, 200
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ require "test/unit"
2
+ require "roger_autoprefixer"
3
+ require "pry"
metadata CHANGED
@@ -1,43 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roger_autoprefixer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flurin Egger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-01 00:00:00.000000000 Z
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roger
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.11.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: 0.11.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
33
  version: 5.0.0
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
40
  version: 5.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.1.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.31.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.31.0
41
83
  description:
42
84
  email:
43
85
  - info@digitpaint.nl
@@ -46,13 +88,22 @@ executables: []
46
88
  extensions: []
47
89
  extra_rdoc_files: []
48
90
  files:
91
+ - ".gitignore"
92
+ - ".rubocop.yml"
93
+ - ".travis.yml"
49
94
  - CHANGELOG.md
95
+ - Gemfile
50
96
  - LICENSE
51
97
  - README.md
98
+ - Rakefile
52
99
  - lib/roger_autoprefixer.rb
53
100
  - lib/roger_autoprefixer/middleware.rb
54
101
  - lib/roger_autoprefixer/processor.rb
102
+ - lib/roger_autoprefixer/transformer.rb
55
103
  - roger_autoprefixer.gemspec
104
+ - test/fixtures/flex.css
105
+ - test/middleware_test.rb
106
+ - test/test_helper.rb
56
107
  homepage: http://github.com/digitpaint/roger_autoprefixer
57
108
  licenses:
58
109
  - MIT
@@ -63,18 +114,21 @@ require_paths:
63
114
  - lib
64
115
  required_ruby_version: !ruby/object:Gem::Requirement
65
116
  requirements:
66
- - - ! '>='
117
+ - - ">="
67
118
  - !ruby/object:Gem::Version
68
119
  version: '0'
69
120
  required_rubygems_version: !ruby/object:Gem::Requirement
70
121
  requirements:
71
- - - ! '>='
122
+ - - ">="
72
123
  - !ruby/object:Gem::Version
73
124
  version: '0'
74
125
  requirements: []
75
126
  rubyforge_project:
76
- rubygems_version: 2.1.5
127
+ rubygems_version: 2.4.5
77
128
  signing_key:
78
129
  specification_version: 4
79
130
  summary: Rack middleware and processor for using autoprefixer with Roger.
80
- test_files: []
131
+ test_files:
132
+ - test/fixtures/flex.css
133
+ - test/middleware_test.rb
134
+ - test/test_helper.rb