csscss 1.3.1 → 1.3.2
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 +7 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +9 -0
- data/CONTRIBUTING.md +53 -0
- data/CONTRIBUTORS.md +2 -0
- data/Gemfile.lock +4 -4
- data/README.md +7 -0
- data/lib/csscss/cli.rb +1 -4
- data/lib/csscss/parser/css.rb +13 -16
- data/lib/csscss/version.rb +1 -1
- data/test/csscss/parser/common_test.rb +8 -0
- data/test/csscss/parser/css_test.rb +80 -4
- metadata +11 -18
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0813cfe3a3c5ea373702b3e9a666ab1f7c89a99d
|
4
|
+
data.tar.gz: e0c6d6a8927eaf0486c3345cea4829fb0845d85f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 232d3550de49a5f655cab3f68981f3d8b58bfd4c7465a8aee565d0f3e27b7a282c611a5434ce4283d6daa34c1f4e5ef62c143e676a2b2f041b0bed2da3cce8fa
|
7
|
+
data.tar.gz: 8e1ea90d3ef93a39dc721ac4e19463dc9fd248f4dc888602a05f4a370a5d4da1ac742e33031d08c32fdf3d532f53d6fe7443493cb7ec7f90d1cfbe784797402b
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0-p195
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 1.3.2 - 6/22/2013 ##
|
2
|
+
|
3
|
+
* Fixes attribute parsing bug that includes comments with braces
|
4
|
+
* Fixes parsing bug with empty media selectors #67
|
5
|
+
* Fixes parsing bug with quoted brackets #72
|
6
|
+
* Fixes parsing bug with nested media queries #73
|
7
|
+
* Removes --compass-with-config deprecation
|
8
|
+
* Adds a CONTRIBUTING.md file with instructions
|
9
|
+
|
1
10
|
## 1.3.1 - 4/20/2013 ##
|
2
11
|
|
3
12
|
* Fixes --ignore-sass-mixins bug with @importing
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Contributing to csscss
|
2
|
+
|
3
|
+
First of all: Thanks!
|
4
|
+
|
5
|
+
## Bugs & Feature Requests
|
6
|
+
|
7
|
+
You can file bugs on the [issues
|
8
|
+
tracker](https://github.com/zmoazeni/csscss/issues), and tag them with
|
9
|
+
'bug'. Feel free to discuss features there, too.
|
10
|
+
|
11
|
+
## Good report structure
|
12
|
+
|
13
|
+
Please include the following four things in your report:
|
14
|
+
|
15
|
+
1. The smallest CSS snippet to explain the problem.
|
16
|
+
2. What you did.
|
17
|
+
3. What you expected to happen.
|
18
|
+
4. What happened instead.
|
19
|
+
|
20
|
+
The more information the better.
|
21
|
+
|
22
|
+
## Contributing Code
|
23
|
+
|
24
|
+
It's easy to contribute code to csscss:
|
25
|
+
|
26
|
+
1. Fork csscss.
|
27
|
+
2. Create a topic branch - `git checkout -b my_branch`
|
28
|
+
3. Push to your branch - `git push origin my_branch`
|
29
|
+
4. Make sure the code follows the contributing guidelines below.
|
30
|
+
5. Create a [Pull Request](http://help.github.com/pull-requests/) from your
|
31
|
+
branch.
|
32
|
+
6. That's it!
|
33
|
+
|
34
|
+
## First Time OSS Contributors
|
35
|
+
|
36
|
+
Submitting your first pull request can be a little daunting. If this is
|
37
|
+
your first Open Source contribution, please mention it in your pull
|
38
|
+
request and I'll help guide you through the process.
|
39
|
+
|
40
|
+
## Contributing Guidelines
|
41
|
+
|
42
|
+
* Make sure your code follows typical [ruby
|
43
|
+
conventions](https://github.com/bbatsov/ruby-style-guide).
|
44
|
+
* Make sure the test suite is green. A simple `bundle exec rake test`
|
45
|
+
will run all the tests.
|
46
|
+
* Include a CHANGELOG entry with your change. Add an `(Unreleased)`
|
47
|
+
section at the top if one doesn't exist.
|
48
|
+
* Try to keep the git commits squashed and concise. Keep tests and code
|
49
|
+
changes together in the same commit. Keep only logical changes together
|
50
|
+
in a single commit.
|
51
|
+
* I strongly encourage [well written git commit
|
52
|
+
messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
53
|
+
* Make sure all whitespace is trimmed from the end of lines.
|
data/CONTRIBUTORS.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
csscss (1.3.
|
4
|
+
csscss (1.3.2)
|
5
5
|
colorize
|
6
6
|
parslet (~> 1.5)
|
7
7
|
|
@@ -17,12 +17,12 @@ GEM
|
|
17
17
|
chunky_png (~> 1.2)
|
18
18
|
fssm (>= 0.2.7)
|
19
19
|
sass (~> 3.1)
|
20
|
-
debugger (1.
|
20
|
+
debugger (1.6.0)
|
21
21
|
columnize (>= 0.3.1)
|
22
22
|
debugger-linecache (~> 1.2.0)
|
23
|
-
debugger-ruby_core_source (~> 1.2.
|
23
|
+
debugger-ruby_core_source (~> 1.2.1)
|
24
24
|
debugger-linecache (1.2.0)
|
25
|
-
debugger-ruby_core_source (1.2.
|
25
|
+
debugger-ruby_core_source (1.2.2)
|
26
26
|
fssm (0.2.10)
|
27
27
|
less (2.3.1)
|
28
28
|
commonjs (~> 0.2.6)
|
data/README.md
CHANGED
@@ -63,6 +63,13 @@ LESS requires an additional javascript runtime.
|
|
63
63
|
rubies, and [therubyrhino](https://rubygems.org/gems/therubyrhino) on
|
64
64
|
jruby.
|
65
65
|
|
66
|
+
## Why doesn't csscss automatically remove duplications for me? ##
|
67
|
+
|
68
|
+
I have been asked this a lot, but csscss is intentionally designed this
|
69
|
+
way. Check out [this
|
70
|
+
post](http://connectionrequired.com/blog/2013/04/why-csscss-doesnt-remove-duplication-for-you/)
|
71
|
+
for my reasoning.
|
72
|
+
|
66
73
|
## I found bugs ##
|
67
74
|
|
68
75
|
This is still a new and evolving project. I heartily welcome feedback.
|
data/lib/csscss/cli.rb
CHANGED
@@ -98,10 +98,7 @@ module Csscss
|
|
98
98
|
enable_compass if @compass = compass
|
99
99
|
end
|
100
100
|
|
101
|
-
opts.on("--compass-with-config config", "Enable compass extensions when parsing sass/scss and pass config file"
|
102
|
-
"DEPRECATED: use --compass --require path/to/config.rb instead."
|
103
|
-
) do |config|
|
104
|
-
deprecate("Use --compass --require #{config} instead of --compass-with-config #{config}")
|
101
|
+
opts.on("--compass-with-config config", "Enable compass extensions when parsing sass/scss and pass config file") do |config|
|
105
102
|
@compass = true
|
106
103
|
enable_compass(config)
|
107
104
|
end
|
data/lib/csscss/parser/css.rb
CHANGED
@@ -12,26 +12,22 @@ module Csscss
|
|
12
12
|
class Parser < Parslet::Parser
|
13
13
|
include Common
|
14
14
|
|
15
|
-
rule(:
|
16
|
-
|
17
|
-
}
|
18
|
-
|
19
|
-
rule(:css_space?) {
|
20
|
-
comment.repeat(1) | space?
|
15
|
+
rule(:raw_comment) {
|
16
|
+
space? >> str('/*') >> (str('*/').absent? >> any).repeat >> str('*/') >> space?
|
21
17
|
}
|
18
|
+
rule(:comment) { raw_comment.as(:comment) }
|
22
19
|
|
23
20
|
rule(:blank_attribute) { str(";") >> space? }
|
24
21
|
|
22
|
+
rule(:attribute_value) { any_quoted { any } | (str('/*').absent? >> match["^;}"]) | raw_comment }
|
23
|
+
|
25
24
|
rule(:attribute) {
|
26
25
|
match["^:{}"].repeat(1).as(:property) >>
|
27
26
|
str(":") >>
|
28
|
-
(
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
any.present?
|
33
|
-
end
|
34
|
-
}).as(:value) >>
|
27
|
+
(
|
28
|
+
(stri("data:").absent? >> attribute_value) |
|
29
|
+
(stri("data:").present? >> attribute_value.repeat(1) >> str(";") >> attribute_value.repeat(1))
|
30
|
+
).repeat(1).as(:value) >>
|
35
31
|
str(";").maybe >>
|
36
32
|
space?
|
37
33
|
}
|
@@ -70,7 +66,8 @@ module Csscss
|
|
70
66
|
str("@") >>
|
71
67
|
match["^{}"].repeat(1) >>
|
72
68
|
str("{") >>
|
73
|
-
|
69
|
+
space? >>
|
70
|
+
(comment | ruleset | nested_ruleset).repeat(1) >>
|
74
71
|
str("}") >>
|
75
72
|
space?
|
76
73
|
).as(:nested_ruleset)
|
@@ -98,8 +95,8 @@ module Csscss
|
|
98
95
|
end
|
99
96
|
|
100
97
|
class Transformer < Parslet::Transform
|
101
|
-
rule(nested_ruleset:
|
102
|
-
rulesets
|
98
|
+
rule(nested_ruleset: subtree(:rulesets)) { |context|
|
99
|
+
context[:rulesets].flatten
|
103
100
|
}
|
104
101
|
|
105
102
|
rule(import: simple(:import)) { [] }
|
data/lib/csscss/version.rb
CHANGED
@@ -139,6 +139,14 @@ module Csscss::Parser
|
|
139
139
|
@parser.url.must_parse "url(data:image/svg+xml;base64,IMGDATAGOESHERE4/5/h/1+==)"
|
140
140
|
@parser.url.must_parse "url('data:image/svg+xml;base64,IMGDATAGOESHERE4/5/h/1+==')"
|
141
141
|
end
|
142
|
+
|
143
|
+
it "parses specials characters" do
|
144
|
+
@parser.between('"', '"') { @parser.symbol("{") }.must_parse '"{"'
|
145
|
+
@parser.between('"', '"') { @parser.symbol("}") }.must_parse '"}"'
|
146
|
+
@parser.between('"', '"') { @parser.symbol("%") }.must_parse '"%"'
|
147
|
+
@parser.double_quoted { @parser.symbol("{") }.must_parse %("{")
|
148
|
+
@parser.single_quoted { @parser.symbol('{') }.must_parse %('{')
|
149
|
+
end
|
142
150
|
end
|
143
151
|
end
|
144
152
|
end
|
@@ -23,14 +23,14 @@ module Csscss::Parser
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "parses comments" do
|
26
|
-
@parser.
|
27
|
-
@parser.
|
26
|
+
@parser.comment.must_parse "/* foo */"
|
27
|
+
@parser.comment.must_parse %$
|
28
28
|
/* foo
|
29
29
|
* bar
|
30
30
|
*/
|
31
31
|
$
|
32
32
|
|
33
|
-
@parser.
|
33
|
+
@parser.comment.repeat(1).must_parse %$
|
34
34
|
/* foo */
|
35
35
|
/* bar */
|
36
36
|
$
|
@@ -63,11 +63,13 @@ module Csscss::Parser
|
|
63
63
|
*/
|
64
64
|
.bar { border: 1px solid black /* sdflk */ }
|
65
65
|
.baz { background: white /* sdflk */ }
|
66
|
+
.baz2 { background: white /* {sdflk} */ }
|
66
67
|
$
|
67
68
|
|
68
69
|
trans(css).must_equal([
|
69
70
|
rs(sel(".bar"), [dec("border", "1px solid black /* sdflk */")]),
|
70
|
-
rs(sel(".baz"), [dec("background", "white /* sdflk */")])
|
71
|
+
rs(sel(".baz"), [dec("background", "white /* sdflk */")]),
|
72
|
+
rs(sel(".baz2"), [dec("background", "white /* {sdflk} */")])
|
71
73
|
])
|
72
74
|
end
|
73
75
|
|
@@ -117,6 +119,15 @@ module Csscss::Parser
|
|
117
119
|
}
|
118
120
|
}
|
119
121
|
|
122
|
+
@media only screen {
|
123
|
+
@-webkit-keyframes webkitSiblingBugfix {
|
124
|
+
from { position: relative; }
|
125
|
+
to { position: relative; }
|
126
|
+
}
|
127
|
+
|
128
|
+
a { position: relative }
|
129
|
+
}
|
130
|
+
|
120
131
|
h1 {
|
121
132
|
outline: 1px;
|
122
133
|
}
|
@@ -125,10 +136,34 @@ module Csscss::Parser
|
|
125
136
|
trans(css).must_equal([
|
126
137
|
rs(sel("#foo"), [dec("background-color", "black")]),
|
127
138
|
rs(sel("#bar"), [dec("display", "none")]),
|
139
|
+
rs(sel("from"), [dec("position", "relative")]),
|
140
|
+
rs(sel("to"), [dec("position", "relative")]),
|
141
|
+
rs(sel("a"), [dec("position", "relative")]),
|
128
142
|
rs(sel("h1"), [dec("outline", "1px")])
|
129
143
|
])
|
130
144
|
end
|
131
145
|
|
146
|
+
it "recognizes empty @media queries with no spaces" do
|
147
|
+
css = %$
|
148
|
+
@media (min-width: 768px) and (max-width: 979px) {}
|
149
|
+
$
|
150
|
+
|
151
|
+
trans(css).must_equal([
|
152
|
+
rs(sel("@media (min-width: 768px) and (max-width: 979px)"), []),
|
153
|
+
])
|
154
|
+
end
|
155
|
+
|
156
|
+
it "recognizes empty @media queries with spaces" do
|
157
|
+
css = %$
|
158
|
+
@media (min-width: 768px) and (max-width: 979px) {
|
159
|
+
}
|
160
|
+
$
|
161
|
+
|
162
|
+
trans(css).must_equal([
|
163
|
+
rs(sel("@media (min-width: 768px) and (max-width: 979px)"), []),
|
164
|
+
])
|
165
|
+
end
|
166
|
+
|
132
167
|
it "ignores @import statements" do
|
133
168
|
css = %$
|
134
169
|
@import "foo.css";
|
@@ -210,6 +245,47 @@ module Csscss::Parser
|
|
210
245
|
dec("display", "block")])
|
211
246
|
])
|
212
247
|
end
|
248
|
+
|
249
|
+
it "parses attributes with special characters" do
|
250
|
+
css = %$
|
251
|
+
|
252
|
+
#menu a::before {
|
253
|
+
content: "{";
|
254
|
+
left: -6px;
|
255
|
+
}
|
256
|
+
|
257
|
+
#menu a::after {
|
258
|
+
content: "}";
|
259
|
+
right: -6px;
|
260
|
+
}
|
261
|
+
|
262
|
+
#menu a::weird {
|
263
|
+
content: "@";
|
264
|
+
up: -2px;
|
265
|
+
}
|
266
|
+
|
267
|
+
#menu a::after_all {
|
268
|
+
content: '{';
|
269
|
+
right: -6px;
|
270
|
+
}
|
271
|
+
|
272
|
+
$
|
273
|
+
|
274
|
+
trans(css).must_equal([
|
275
|
+
rs(sel("#menu a::before"), [dec("content", '"{"'),
|
276
|
+
dec("left", "-6px")
|
277
|
+
]),
|
278
|
+
rs(sel("#menu a::after"), [dec("content", '"}"'),
|
279
|
+
dec("right", "-6px")
|
280
|
+
]),
|
281
|
+
rs(sel("#menu a::weird"), [dec("content", '"@"'),
|
282
|
+
dec("up", "-2px")
|
283
|
+
]),
|
284
|
+
rs(sel("#menu a::after_all"), [dec("content", "'{'"),
|
285
|
+
dec("right", "-6px")
|
286
|
+
])
|
287
|
+
])
|
288
|
+
end
|
213
289
|
end
|
214
290
|
end
|
215
291
|
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csscss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
5
|
-
prerelease:
|
4
|
+
version: 1.3.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Zach Moazeni
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-06-22 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: parslet
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,17 +27,15 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: colorize
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description: csscss will parse any CSS files you give it and let you know which rulesets
|
@@ -53,8 +48,10 @@ extensions: []
|
|
53
48
|
extra_rdoc_files: []
|
54
49
|
files:
|
55
50
|
- .gitignore
|
51
|
+
- .ruby-version
|
56
52
|
- .travis.yml
|
57
53
|
- CHANGELOG.md
|
54
|
+
- CONTRIBUTING.md
|
58
55
|
- CONTRIBUTORS.md
|
59
56
|
- Gemfile
|
60
57
|
- Gemfile.lock
|
@@ -111,30 +108,26 @@ files:
|
|
111
108
|
- test/test_helper.rb
|
112
109
|
homepage: http://zmoazeni.github.io/csscss/
|
113
110
|
licenses: []
|
111
|
+
metadata: {}
|
114
112
|
post_install_message:
|
115
113
|
rdoc_options: []
|
116
114
|
require_paths:
|
117
115
|
- lib
|
118
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
117
|
requirements:
|
121
|
-
- -
|
118
|
+
- - '>='
|
122
119
|
- !ruby/object:Gem::Version
|
123
120
|
version: '1.9'
|
124
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
122
|
requirements:
|
127
|
-
- -
|
123
|
+
- - '>='
|
128
124
|
- !ruby/object:Gem::Version
|
129
125
|
version: '0'
|
130
|
-
segments:
|
131
|
-
- 0
|
132
|
-
hash: -4485977171346278397
|
133
126
|
requirements: []
|
134
127
|
rubyforge_project:
|
135
|
-
rubygems_version:
|
128
|
+
rubygems_version: 2.0.3
|
136
129
|
signing_key:
|
137
|
-
specification_version:
|
130
|
+
specification_version: 4
|
138
131
|
summary: A CSS redundancy analyzer that analyzes redundancy.
|
139
132
|
test_files:
|
140
133
|
- test/csscss/json_reporter_test.rb
|