csscss 1.3.0 → 1.3.1
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 +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +5 -2
- data/lib/csscss/cli.rb +2 -6
- data/lib/csscss/sass_include_extensions.rb +12 -11
- data/lib/csscss/version.rb +1 -1
- data/test/csscss/sass_include_extensions_test.rb +27 -4
- metadata +3 -3
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -29,7 +29,7 @@ Then you can run it in at the command line against CSS files.
|
|
29
29
|
|
30
30
|
{.contact .content .primary} and {article, #comments} share 5 rules
|
31
31
|
{.profile-picture}, {.screenshot img} and {a.blurb img} share 4 rules
|
32
|
-
{.work h2:first-child, .
|
32
|
+
{.work h2:first-child, .contact h2} and {body.home h2} share 4 rules
|
33
33
|
{article.blurb:hover} and {article:hover} share 3 rules
|
34
34
|
|
35
35
|
Run it in a verbose mode to see all the duplicated styles.
|
@@ -45,11 +45,14 @@ rulesets that have fewer matches.
|
|
45
45
|
|
46
46
|
$ csscss -n 10 -v path/to/style.css # ignores rulesets with < 10 matches
|
47
47
|
|
48
|
-
If you prefer writing in [
|
48
|
+
If you prefer writing in [Sass](http://sass-lang.com/), you can also parse your sass/scss files.
|
49
49
|
|
50
50
|
$ gem install sass
|
51
51
|
$ csscss path/to/style.scss
|
52
52
|
|
53
|
+
Sass users may be interested in the `--ignore-sass-mixins`
|
54
|
+
experimental flag that won't match duplicate declarations from including mixins.
|
55
|
+
|
53
56
|
If you prefer writing in [LESS](http://lesscss.org/), you can also parse your LESS files.
|
54
57
|
|
55
58
|
$ gem install less
|
data/lib/csscss/cli.rb
CHANGED
@@ -172,16 +172,12 @@ module Csscss
|
|
172
172
|
|
173
173
|
def load_sass_file(filename)
|
174
174
|
abort 'Must install the "sass" gem before parsing sass/scss files' unless gem_installed?("sass")
|
175
|
+
require "csscss/sass_include_extensions" if @ignore_sass_mixins
|
175
176
|
|
176
177
|
sass_options = {cache:false}
|
177
178
|
sass_options[:load_paths] = Compass.configuration.sass_load_paths if @compass
|
178
179
|
begin
|
179
|
-
|
180
|
-
if @ignore_sass_mixins
|
181
|
-
require "csscss/sass_include_extensions"
|
182
|
-
Csscss::SassMixinVisitor.visit(tree)
|
183
|
-
end
|
184
|
-
tree.render
|
180
|
+
Sass::Engine.for_file(filename, sass_options).render
|
185
181
|
rescue Sass::SyntaxError => e
|
186
182
|
if e.message =~ /compass/ && !@compass
|
187
183
|
puts "Enable --compass option to use compass's extensions"
|
@@ -1,19 +1,20 @@
|
|
1
1
|
require "sass"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
new.send(:visit, root)
|
7
|
-
end
|
3
|
+
Sass::Tree::MixinDefNode.class_eval do
|
4
|
+
def children
|
5
|
+
first_child = @children.first
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
# not sure why/how we can get here with empty children, but it
|
8
|
+
# causes issues
|
9
|
+
unless @children.empty? || (first_child.is_a?(Sass::Tree::CommentNode) && first_child.value.first =~ /CSSCSS START/)
|
10
|
+
begin_comment = Sass::Tree::CommentNode.new(["/* CSSCSS START MIXIN: #{name} */"], :normal)
|
11
|
+
end_comment = Sass::Tree::CommentNode.new(["/* CSSCSS END MIXIN: #{name} */"], :normal)
|
12
12
|
|
13
13
|
begin_comment.options = end_comment.options = {}
|
14
|
-
|
15
|
-
|
16
|
-
node.children.push(end_comment)
|
14
|
+
@children.unshift(begin_comment)
|
15
|
+
@children.push(end_comment)
|
17
16
|
end
|
17
|
+
|
18
|
+
@children
|
18
19
|
end
|
19
20
|
end
|
data/lib/csscss/version.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "test_helper"
|
2
|
+
require "tempfile"
|
2
3
|
require "csscss/sass_include_extensions"
|
3
4
|
|
4
5
|
module Csscss
|
5
6
|
describe "sass import extensions" do
|
6
|
-
it "should
|
7
|
+
it "should add comments before and after mixin properties" do
|
7
8
|
scss =<<-SCSS
|
8
9
|
@mixin foo {
|
9
10
|
font: {
|
@@ -37,9 +38,31 @@ h1 {
|
|
37
38
|
/* CSSCSS END MIXIN: bar */ }
|
38
39
|
CSS
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
Sass::Engine.new(scss, syntax: :scss, cache: false).render.must_equal(css)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should insert comments even with imported stylesheets" do
|
45
|
+
Tempfile.open(['foo', '.scss']) do |f|
|
46
|
+
f << <<-SCSS
|
47
|
+
@mixin foo {
|
48
|
+
outline: 1px;
|
49
|
+
}
|
50
|
+
|
51
|
+
h1 {
|
52
|
+
@include foo;
|
53
|
+
}
|
54
|
+
SCSS
|
55
|
+
f.close
|
56
|
+
|
57
|
+
css =<<-CSS
|
58
|
+
h1 {
|
59
|
+
/* CSSCSS START MIXIN: foo */
|
60
|
+
outline: 1px;
|
61
|
+
/* CSSCSS END MIXIN: foo */ }
|
62
|
+
CSS
|
63
|
+
|
64
|
+
Sass::Engine.new("@import '#{f.path}'", syntax: :scss, cache: false).render.must_equal(css)
|
65
|
+
end
|
43
66
|
end
|
44
67
|
end
|
45
68
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csscss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parslet
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
segments:
|
131
131
|
- 0
|
132
|
-
hash:
|
132
|
+
hash: -4485977171346278397
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
135
|
rubygems_version: 1.8.25
|