scss_beautifier 0.1.16 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f73fc34d46f5c23ba992bd5811f31e9700fca0cb
4
- data.tar.gz: 1367fe11e2d4a23778a2a337dcbbea70ab0078e2
3
+ metadata.gz: a9d5f273367280c4e6eab6f3531573de63b1cb7c
4
+ data.tar.gz: 74cd0b8adc662dd488297016c5528ec3a9363e0e
5
5
  SHA512:
6
- metadata.gz: 63b72aa241ee07e6f7c83c32c4bfc366d4635c3dbb6b7313b225930070d267df6be7cb77c31afcb21fe87411340892fdd7fc33236d8eed14ee611ae836cebc83
7
- data.tar.gz: dc2058530a0b6ed413950482ca60fef4ce4f883e8c312eb67059800a37c3717cb59fe0d18565b0fe163261cabb5826dc51428259a6ca4d25c83d886b37ac1e27
6
+ metadata.gz: aa37cb636e1b66f8def9c94cfea9fde573588005ae28aee6156779be16fd7dd627933da63ab7141191244d481ea8c07ec61fcd4004b86ed44f3ae5e8edc45e24
7
+ data.tar.gz: e51be58ffbe4dc6ef1e727938f6b4dc46de1e17fc00f92164bb2fcf8d7adc5f710f93ec8639ddab2f7d23451def959b9a211f177902472233e73c49287521b13
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scss_beautifier (0.1.16)
4
+ scss_beautifier (0.1.17)
5
5
  sass (~> 3.4)
6
6
 
7
7
  GEM
@@ -34,3 +34,12 @@ require "scss_beautifier/formatters/selector"
34
34
  require "scss_beautifier/formatters/shorthand"
35
35
  require "scss_beautifier/formatters/string_quotes"
36
36
  require "scss_beautifier/formatters/trailing_zero"
37
+
38
+ class Sass::Tree::Node
39
+ attr_accessor :scss_beautifier_options
40
+
41
+ def scss_beautifier_options
42
+ @scss_beautifier_options ||= {}
43
+ end
44
+
45
+ end
@@ -32,8 +32,8 @@ class SCSSBeautifier::Convert < Sass::Tree::Visitors::Convert
32
32
  # whitespace added.
33
33
  def visit_rule_level(nodes)
34
34
  Sass::Util.enum_cons(nodes + [nil], 2).map do |child, nxt|
35
- visit(child) +
36
- if nxt &&
35
+ child_value = visit(child)
36
+ spacing = if nxt &&
37
37
  (child.is_a?(Sass::Tree::CommentNode) && child.line + child.lines + 1 == nxt.line) ||
38
38
  (child.is_a?(Sass::Tree::ImportNode) && nxt.is_a?(Sass::Tree::ImportNode) &&
39
39
  child.line + 1 == nxt.line) ||
@@ -52,7 +52,24 @@ class SCSSBeautifier::Convert < Sass::Tree::Visitors::Convert
52
52
  "\n"
53
53
  end
54
54
  end
55
+ if inline_comment?(child, nxt)
56
+ child_value.rstrip!
57
+ spacing = ""
58
+ nxt.scss_beautifier_options[:inline] = true
59
+ elsif child.scss_beautifier_options[:inline]
60
+ spacing = ""
61
+ end
62
+ child_value + spacing
55
63
  end.join.rstrip + "\n"
56
64
  end
57
65
 
66
+ def visit_comment(node)
67
+ value = super
68
+ node.scss_beautifier_options[:inline] ? ' ' + value.lstrip! : value
69
+ end
70
+
71
+ def inline_comment?(node, comment_node)
72
+ comment_node.is_a?(Sass::Tree::CommentNode) && node.line == comment_node.line
73
+ end
74
+
58
75
  end
@@ -4,6 +4,8 @@ class SCSSBeautifier::Formatters::PropertySortOrder < SCSSBeautifier::Formatters
4
4
  visit_children(node)
5
5
  end
6
6
 
7
+ private
8
+
7
9
  def order_children(node)
8
10
  prop_nodes = []
9
11
  comment_array = []
@@ -12,7 +14,12 @@ class SCSSBeautifier::Formatters::PropertySortOrder < SCSSBeautifier::Formatters
12
14
  hash_key = child.class.node_name.to_s
13
15
  if hash_key == 'comment'
14
16
  seen_comments << child
15
- comment_array << child
17
+ prev_grouping = prop_nodes.last
18
+ if prop_node_for(prev_grouping).line == child.line
19
+ prev_grouping << child
20
+ else
21
+ comment_array << child
22
+ end
16
23
  elsif hash_key == 'prop'
17
24
  prop_nodes << comment_array.push(child)
18
25
  comment_array = []
@@ -22,7 +29,7 @@ class SCSSBeautifier::Formatters::PropertySortOrder < SCSSBeautifier::Formatters
22
29
  # account for remaining comments
23
30
  seen_comments -= comment_array
24
31
 
25
- prop_nodes.sort! { |x,y| x.last.name[0] <=> y.last.name[0] }
32
+ prop_nodes.sort! { |x,y| prop_node_for(x).name[0] <=> prop_node_for(y).name[0] }
26
33
  # Replace children being respective of other types of props/funcs/etc
27
34
  children = []
28
35
  node.children.each do |child|
@@ -35,4 +42,9 @@ class SCSSBeautifier::Formatters::PropertySortOrder < SCSSBeautifier::Formatters
35
42
  end
36
43
  node.children = children
37
44
  end
45
+
46
+ # In an Array of nodes, get the prop node
47
+ def prop_node_for(grouping)
48
+ grouping.find { |node| node.class.node_name == :prop }
49
+ end
38
50
  end
@@ -1,3 +1,3 @@
1
1
  module SCSSBeautifier
2
- VERSION = "0.1.16"
2
+ VERSION = "0.1.17"
3
3
  end
@@ -49,6 +49,7 @@ https://github.com/sasstools/sass-lint/blob/master/docs/rules/mixin-name-format.
49
49
 
50
50
  https://github.com/sasstools/sass-lint/blob/master/docs/rules/no-warn.md
51
51
  how do maps look like? newlines separation?
52
+ parenthesis around if statements?
52
53
 
53
54
 
54
55
  These are spacing rules that come out of the box:
@@ -5,7 +5,7 @@ GEM
5
5
  rack-protection (1.5.3)
6
6
  rack
7
7
  sass (3.4.22)
8
- scss_beautifier (0.1.14)
8
+ scss_beautifier (0.1.16)
9
9
  sass (~> 3.4)
10
10
  sinatra (1.4.7)
11
11
  rack (~> 1.5)
@@ -0,0 +1 @@
1
+ web: bundle exec rackup config.ru -p $PORT
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scss_beautifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Tse
@@ -129,6 +129,7 @@ files:
129
129
  - tmp/dump.txt
130
130
  - web/Gemfile
131
131
  - web/Gemfile.lock
132
+ - web/Procfile
132
133
  - web/app.rb
133
134
  - web/config.ru
134
135
  - web/public/imgs/gh.png