csscss 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.3.1 - 4/20/2013 ##
2
+
3
+ * Fixes --ignore-sass-mixins bug with @importing
4
+
1
5
  ## 1.3.0 - 4/20/2013 ##
2
6
 
3
7
  * Adds --require switch for user configuration
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- csscss (1.3.0)
4
+ csscss (1.3.1)
5
5
  colorize
6
6
  parslet (~> 1.5)
7
7
 
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, .archive h2:first-child, .missing h2:first-child, .about h2, .contact h2} and {body.home h2} share 4 rules
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 [sass](http://sass-lang.com/), you can also parse your sass/scss files.
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
- tree = Sass::Engine.for_file(filename, sass_options).to_tree
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
- module Csscss
4
- class SassMixinVisitor < Sass::Tree::Visitors::Base
5
- def self.visit(root)
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
- def visit_mixindef(node)
10
- begin_comment = Sass::Tree::CommentNode.new(["/* CSSCSS START MIXIN: #{node.name} */"], :normal)
11
- end_comment = Sass::Tree::CommentNode.new(["/* CSSCSS END MIXIN: #{node.name} */"], :normal)
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
- node.children.unshift(begin_comment)
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
@@ -1,3 +1,3 @@
1
1
  module Csscss
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.1"
3
3
  end
@@ -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 do something" do
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
- tree = Sass::Engine.new(scss, syntax: :scss).to_tree
41
- Csscss::SassMixinVisitor.visit(tree)
42
- tree.render.must_equal(css)
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.0
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-20 00:00:00.000000000 Z
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: 2367732181301313903
132
+ hash: -4485977171346278397
133
133
  requirements: []
134
134
  rubyforge_project:
135
135
  rubygems_version: 1.8.25