sass-media_query_combiner 0.0.3 → 0.0.4
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.
- data/CHANGELOG.md +6 -0
- data/lib/sass-media_query_combiner.rb +2 -40
- data/lib/sass/media_query_combiner/combiner.rb +40 -0
- data/lib/sass/media_query_combiner/version.rb +1 -1
- data/spec/lib/sass-media_query_combiner/combiner_spec.rb +14 -0
- data/spec/sass-media_query_combiner_spec.rb +0 -13
- metadata +5 -2
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.0.4 (2013-10-09)
|
2
|
+
|
3
|
+
* Internal refactor to allow
|
4
|
+
[sprockets-media_query_combiner](https://github.com/aaronjensen/sprockets-media_query_combiner)
|
5
|
+
to depend on this project.
|
6
|
+
|
1
7
|
## 0.0.3 (2013-10-09)
|
2
8
|
|
3
9
|
* Fix compiler hanging when using `@-webkit-keyframes` in media queries
|
@@ -1,48 +1,10 @@
|
|
1
1
|
require "sass/media_query_combiner/version"
|
2
|
+
require "sass/media_query_combiner/combiner"
|
2
3
|
require "sass"
|
3
4
|
|
4
|
-
module Sass
|
5
|
-
module MediaQueryCombiner
|
6
|
-
def self.combine(css)
|
7
|
-
queries = Hash.new { |hash, key| hash[key] = '' }
|
8
|
-
pretty = true
|
9
|
-
|
10
|
-
filtered_data = css.gsub(/
|
11
|
-
\n? # Optional newline
|
12
|
-
(?<query> # The media query parameters, this will be $1
|
13
|
-
@media # Start with @media
|
14
|
-
[^{]+ # One to many characters that are not {, we are guaranteed to have a space
|
15
|
-
)
|
16
|
-
{
|
17
|
-
(?<body> # The actual body, this will be $2
|
18
|
-
(?<braces> # Recursive capture group
|
19
|
-
(?:
|
20
|
-
[^{}]* # Anything that is not a brace
|
21
|
-
)
|
22
|
-
| # OR
|
23
|
-
(
|
24
|
-
{\g<braces>} # Recursively capture things within braces, this allows for balanced braces
|
25
|
-
)
|
26
|
-
)* # As many of these as we have
|
27
|
-
)
|
28
|
-
}
|
29
|
-
\n? # Optional newline
|
30
|
-
/mx) do |match|
|
31
|
-
queries[$1] << $2
|
32
|
-
pretty &&= /\n$/m === match
|
33
|
-
''
|
34
|
-
end
|
35
|
-
|
36
|
-
combined = queries.map { |query, body| "#{query}{#{body}}" }.
|
37
|
-
join(("\n\n" if pretty))
|
38
|
-
"#{filtered_data}#{"\n" if pretty}#{combined}\n"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
5
|
Sass::Engine.class_eval do
|
44
6
|
def render_with_combine
|
45
|
-
Sass::MediaQueryCombiner.combine(render_without_combine)
|
7
|
+
Sass::MediaQueryCombiner::Combiner.combine(render_without_combine)
|
46
8
|
end
|
47
9
|
alias_method :render_without_combine, :render
|
48
10
|
alias_method :render, :render_with_combine
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Sass
|
2
|
+
module MediaQueryCombiner
|
3
|
+
module Combiner
|
4
|
+
def self.combine(css)
|
5
|
+
queries = Hash.new { |hash, key| hash[key] = '' }
|
6
|
+
pretty = true
|
7
|
+
|
8
|
+
filtered_data = css.gsub(/
|
9
|
+
\n? # Optional newline
|
10
|
+
(?<query> # The media query parameters, this will be $1
|
11
|
+
@media # Start with @media
|
12
|
+
[^{]+ # One to many characters that are not {, we are guaranteed to have a space
|
13
|
+
)
|
14
|
+
{
|
15
|
+
(?<body> # The actual body, this will be $2
|
16
|
+
(?<braces> # Recursive capture group
|
17
|
+
(?:
|
18
|
+
[^{}]* # Anything that is not a brace
|
19
|
+
)
|
20
|
+
| # OR
|
21
|
+
(
|
22
|
+
{\g<braces>} # Recursively capture things within braces, this allows for balanced braces
|
23
|
+
)
|
24
|
+
)* # As many of these as we have
|
25
|
+
)
|
26
|
+
}
|
27
|
+
\n? # Optional newline
|
28
|
+
/mx) do |match|
|
29
|
+
queries[$1] << $2
|
30
|
+
pretty &&= /\n$/m === match
|
31
|
+
''
|
32
|
+
end
|
33
|
+
|
34
|
+
combined = queries.map { |query, body| "#{query}{#{body}}" }.
|
35
|
+
join(("\n\n" if pretty))
|
36
|
+
"#{filtered_data}#{"\n" if pretty}#{combined}\n"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'sass/media_query_combiner/combiner'
|
3
|
+
|
4
|
+
describe Sass::MediaQueryCombiner::Combiner do
|
5
|
+
it "should handle keyframes in media queries" do
|
6
|
+
Timeout::timeout(0.5) do
|
7
|
+
Sass::MediaQueryCombiner::Combiner.combine <<CSS
|
8
|
+
@media (min-width: 40em) {
|
9
|
+
@-webkit-keyframes whatever {}
|
10
|
+
}
|
11
|
+
CSS
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -43,16 +43,3 @@ b {
|
|
43
43
|
CSS
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
47
|
-
describe Sass::MediaQueryCombiner do
|
48
|
-
it "should handle keyframes in media queries" do
|
49
|
-
Timeout::timeout(0.5) do
|
50
|
-
Sass::MediaQueryCombiner.combine <<CSS
|
51
|
-
@media (min-width: 40em) {
|
52
|
-
@-webkit-keyframes whatever {}
|
53
|
-
}
|
54
|
-
CSS
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sass-media_query_combiner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Aaron Jensen
|
@@ -73,8 +73,10 @@ files:
|
|
73
73
|
- README.md
|
74
74
|
- Rakefile
|
75
75
|
- lib/sass-media_query_combiner.rb
|
76
|
+
- lib/sass/media_query_combiner/combiner.rb
|
76
77
|
- lib/sass/media_query_combiner/version.rb
|
77
78
|
- sass-media_query_combiner.gemspec
|
79
|
+
- spec/lib/sass-media_query_combiner/combiner_spec.rb
|
78
80
|
- spec/sass-media_query_combiner_spec.rb
|
79
81
|
- spec/spec_helper.rb
|
80
82
|
homepage: ''
|
@@ -95,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
97
|
- !ruby/object:Gem::Version
|
96
98
|
segments:
|
97
99
|
- 0
|
98
|
-
hash: -
|
100
|
+
hash: -4377433259710746294
|
99
101
|
version: '0'
|
100
102
|
none: false
|
101
103
|
requirements: []
|
@@ -105,5 +107,6 @@ signing_key:
|
|
105
107
|
specification_version: 3
|
106
108
|
summary: Sass plugin to combine all like media queries
|
107
109
|
test_files:
|
110
|
+
- spec/lib/sass-media_query_combiner/combiner_spec.rb
|
108
111
|
- spec/sass-media_query_combiner_spec.rb
|
109
112
|
- spec/spec_helper.rb
|