sass-media_query_combiner 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YWRjMjZiOTNiMzFiNDk1NGYzNGNmNjhhNzJkNzI5ZTM4OTc0ZmNjNA==
5
- data.tar.gz: !binary |-
6
- MzA1Nzg0MjI0MzE3Y2EwYTI1ZDA0MzgyMWY3MGU2ZDcwNGI1NjQ0Nw==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- ODk2NjA4NDNkZjBmZDM2ODkwMDFiMDk0MjIxMjFmYjEzMTkwYWFhNzlkNzBk
10
- NThmZTZmZmU1MDFjM2U5NTk1NGZiNzIwYWYwZDNhZDQ5NGE2NTEyYmU3Y2Vj
11
- OTM0MjIxNTczMGZhNDViNmMxMTcxY2QwN2E5MmI3ZDczNDdlNWQ=
12
- data.tar.gz: !binary |-
13
- MjdmNjk0YjIyNTcyYzk1NjNjYmM4OTg4YTZiZTJiMTVmMzY0NGJjZTE2Mjkz
14
- MThlNGI3NTBlYTIxZTBjMTdlMGQ4ODI1MzY5NzhjNmVhMDg3N2Y3MTI3NTdi
15
- ZDE2OWRjNzMzZDlhMmUyODAxZGQzYzA3NWJlMjZkNGJlZDQ1MDQ=
2
+ SHA1:
3
+ metadata.gz: d5336fadd067874f1617a9f8a5b9c97c89a94598
4
+ data.tar.gz: 2a970c01aab4299566178ae0a9008b2345238336
5
+ SHA512:
6
+ metadata.gz: fe173a3c9733d7615eee0b887e089b635e9c4912cf4399b6553282d7ddd183d481c1f8b607d0cff8362d3b63cbfbcfe8a07abdd34eaf697a6abc1ce27e8cafba
7
+ data.tar.gz: f0b1075b9dddfcbf64c93777aec6e6aa40e86cdd14101f652eb9a11833d391460b969a3baeec1f8d1881c4523517c90c75adfc64e905df62d7fbc19aeb530318
data/README.md CHANGED
@@ -8,7 +8,9 @@
8
8
  Combines all matching media queries while compiling your Sass.
9
9
 
10
10
  If you're using
11
- Rails 3.1+ or Sprockets, you should use [sprockets-media_query_combiner](https://github.com/aaronjensen/sprockets-media_query_combiner)
11
+ Rails 3.1+ or Sprockets, you should use [sprockets-media_query_combiner](https://github.com/aaronjensen/sprockets-media_query_combiner).
12
+
13
+ For node pipelines try [node-css-mqpacker](https://github.com/hail2u/node-css-mqpacker).
12
14
 
13
15
  For example:
14
16
 
@@ -9,4 +9,14 @@ Sass::Engine.class_eval do
9
9
  alias_method :render_without_combine, :render
10
10
  alias_method :render, :render_with_combine
11
11
  alias_method :to_css, :render_with_combine
12
+
13
+ def render_with_sourcemap_with_combine(*args)
14
+ rendered, sourcemap = render_with_sourcemap_without_combine(*args)
15
+
16
+ rendered = Sass::MediaQueryCombiner::Combiner.combine(rendered)
17
+
18
+ return rendered, sourcemap
19
+ end
20
+ alias_method :render_with_sourcemap_without_combine, :render_with_sourcemap
21
+ alias_method :render_with_sourcemap, :render_with_sourcemap_with_combine
12
22
  end
@@ -5,6 +5,8 @@ module Sass
5
5
  queries = Hash.new { |hash, key| hash[key] = '' }
6
6
  pretty = true
7
7
 
8
+ css, source_map_url = extract_source_map_url(css)
9
+
8
10
  filtered_data = css.gsub(/
9
11
  \n? # Optional newline
10
12
  (?<query> # The media query parameters, this will be $1
@@ -32,7 +34,18 @@ module Sass
32
34
 
33
35
  combined = queries.map { |query, body| "#{query}{#{body}}" }.
34
36
  join(("\n\n" if pretty))
35
- "#{filtered_data}#{"\n" if pretty}#{combined}\n"
37
+ "#{filtered_data}#{"\n" if pretty}#{combined}#{source_map_url}\n"
38
+ end
39
+
40
+ def self.extract_source_map_url(css)
41
+ source_map_url = ''
42
+
43
+ css = css.gsub(/\n*\/\*# sourceMappingURL=.* \*\/$/m) do |match|
44
+ source_map_url = match
45
+ ''
46
+ end
47
+
48
+ return css, source_map_url
36
49
  end
37
50
  end
38
51
  end
@@ -1,5 +1,5 @@
1
1
  module Sass
2
2
  module MediaQueryCombiner
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
@@ -22,10 +22,37 @@ b
22
22
  color: yellow
23
23
  SASS
24
24
 
25
+
25
26
  it "should work with sass" do
26
27
  # NOTE: the weird interpolated space in there is required to match.
27
28
  # My editor strips out trailing whitespace, so that's how I get it to stay.
28
- Sass::Engine.new(sass).render.should == <<CSS
29
+ expected_output = <<CSS
30
+ h3 {
31
+ color: orange; }
32
+ b {
33
+ color: yellow; }
34
+
35
+ @media (max-width: 480px) {
36
+ h1 {
37
+ color: red; }#{" "}
38
+ h2 {
39
+ color: blue; } }
40
+
41
+ @media (max-width: 980px) {
42
+ h4 {
43
+ color: black; } }
44
+ CSS
45
+
46
+ Sass::Engine.new(sass).render.should == expected_output
47
+ end
48
+
49
+ it "should work with sourcemaps" do
50
+ options = {
51
+ filename: "out.css",
52
+ sourcemap_filename: "out.css.map"
53
+ }
54
+
55
+ expected_output = <<CSS
29
56
  h3 {
30
57
  color: orange; }
31
58
  b {
@@ -40,7 +67,12 @@ b {
40
67
  @media (max-width: 980px) {
41
68
  h4 {
42
69
  color: black; } }
70
+
71
+ /*# sourceMappingURL=out.css.map */
43
72
  CSS
73
+
74
+ output, _ = Sass::Engine.new(sass, options).render_with_sourcemap("out.css.map")
75
+ output.should == expected_output
44
76
  end
45
77
 
46
78
  it "should work with debug_info: true" do
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-media_query_combiner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Jensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-15 00:00:00.000000000 Z
11
+ date: 2015-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass
15
- prerelease: false
16
15
  requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
- - - ! '>='
17
+ - - ">="
19
18
  - !ruby/object:Gem::Version
20
19
  version: 3.2.0
20
+ type: :runtime
21
+ prerelease: false
21
22
  version_requirements: !ruby/object:Gem::Requirement
22
23
  requirements:
23
- - - ! '>='
24
+ - - ">="
24
25
  - !ruby/object:Gem::Version
25
26
  version: 3.2.0
26
- type: :runtime
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
- prerelease: false
30
29
  requirement: !ruby/object:Gem::Requirement
31
30
  requirements:
32
- - - ! '>='
31
+ - - ">="
33
32
  - !ruby/object:Gem::Version
34
33
  version: '0'
34
+ type: :development
35
+ prerelease: false
35
36
  version_requirements: !ruby/object:Gem::Requirement
36
37
  requirements:
37
- - - ! '>='
38
+ - - ">="
38
39
  - !ruby/object:Gem::Version
39
40
  version: '0'
40
- type: :development
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
- prerelease: false
44
43
  requirement: !ruby/object:Gem::Requirement
45
44
  requirements:
46
- - - ! '>='
45
+ - - ">="
47
46
  - !ruby/object:Gem::Version
48
47
  version: '0'
48
+ type: :development
49
+ prerelease: false
49
50
  version_requirements: !ruby/object:Gem::Requirement
50
51
  requirements:
51
- - - ! '>='
52
+ - - ">="
52
53
  - !ruby/object:Gem::Version
53
54
  version: '0'
54
- type: :development
55
55
  description: Automatically combine media queries
56
56
  email:
57
57
  - aaronjensen@gmail.com
@@ -59,7 +59,7 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - .gitignore
62
+ - ".gitignore"
63
63
  - CHANGELOG.md
64
64
  - Gemfile
65
65
  - LICENSE.txt
@@ -82,17 +82,17 @@ require_paths:
82
82
  - lib
83
83
  required_ruby_version: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - ! '>='
85
+ - - ">="
86
86
  - !ruby/object:Gem::Version
87
87
  version: 1.9.2
88
88
  required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - ! '>='
90
+ - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubyforge_project:
95
- rubygems_version: 2.0.6
95
+ rubygems_version: 2.2.2
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: Sass plugin to combine all like media queries