scss_beautifier 0.1.18 → 0.1.19
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 +4 -4
- data/.gitignore +1 -1
- data/Gemfile.lock +1 -1
- data/data/default_config.yml +6 -4
- data/lib/scss_beautifier/cli.rb +5 -7
- data/lib/scss_beautifier/config.rb +17 -4
- data/lib/scss_beautifier/convert.rb +4 -3
- data/lib/scss_beautifier/formatters/property_sort_order.rb +1 -1
- data/lib/scss_beautifier/version.rb +1 -1
- data/tmp/dump.txt +1 -1
- data/web/Gemfile.lock +1 -1
- data/web/app.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfc62f9e86557db0032cb11266c1de36596272bf
|
4
|
+
data.tar.gz: 0257cd1dcb2b31494bd548e48a4ab0c31ecd899e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 270265eaa20862d367a6f75e94e38cfc87261b567455c3ece4221d54069c06288cd12b648b12b4fae9b1095784cccf194c9b329b9675026a5f04ae910880cd54
|
7
|
+
data.tar.gz: 3bc50250f856ea030a0f50063563af059fc8b298eb4ef003d3c4ad235cf5b68926972949bc2943c034e67f3f4d921a7c7414e3630093abf9ee0fd4474cfa7641
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/data/default_config.yml
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
options:
|
2
|
+
|
3
|
+
indent: " "
|
4
|
+
|
5
|
+
else_placement: "same_line"
|
6
|
+
|
2
7
|
formatters:
|
3
8
|
|
4
9
|
border_zero:
|
@@ -23,9 +28,6 @@ formatters:
|
|
23
28
|
enabled: true
|
24
29
|
sort_order: ["mixindef", "mixin", "prop", "rule", "extend"]
|
25
30
|
|
26
|
-
# else_placement:
|
27
|
-
# enabled: true
|
28
|
-
|
29
31
|
leading_zero:
|
30
32
|
enabled: true
|
31
33
|
|
data/lib/scss_beautifier/cli.rb
CHANGED
@@ -1,23 +1,21 @@
|
|
1
1
|
module SCSSBeautifier
|
2
2
|
class CLI
|
3
|
-
|
4
|
-
# Takes an array of arguments
|
5
|
-
# Returns exit code
|
3
|
+
|
6
4
|
def run(args)
|
7
5
|
options = Options.new.parse(args)
|
8
6
|
generate_configuration and return if options[:generate_config]
|
9
7
|
|
10
|
-
contents = File.read(args.first)
|
8
|
+
contents = args.first.nil? ? $stdin.read : File.read(args.first)
|
11
9
|
engine = Sass::Engine.new(contents, cache: false, syntax: :scss)
|
12
10
|
|
13
11
|
tree = engine.to_tree
|
14
|
-
config = Config.new(options[:config]
|
12
|
+
config = Config.new(options[:config])
|
15
13
|
|
16
14
|
config.formatters.each do |formatter|
|
17
15
|
formatter.send(:visit, tree)
|
18
16
|
end
|
19
17
|
|
20
|
-
output = SCSSBeautifier::Convert.visit(tree,
|
18
|
+
output = SCSSBeautifier::Convert.visit(tree, config.options, :scss)
|
21
19
|
if options[:in_place]
|
22
20
|
File.write(args.first, output)
|
23
21
|
else
|
@@ -28,7 +26,7 @@ module SCSSBeautifier
|
|
28
26
|
private
|
29
27
|
|
30
28
|
def generate_configuration
|
31
|
-
File.write(".scss-beautifier", File.read(DEFAULT))
|
29
|
+
File.write(".scss-beautifier", File.read(Config::DEFAULT))
|
32
30
|
end
|
33
31
|
|
34
32
|
end
|
@@ -2,13 +2,15 @@ require "yaml"
|
|
2
2
|
|
3
3
|
module SCSSBeautifier
|
4
4
|
class Config
|
5
|
+
DEFAULT = File.realpath(File.join(File.dirname(__FILE__), "..", "..", "data", "default_config.yml")).freeze
|
5
6
|
|
6
7
|
def initialize(config_location)
|
7
|
-
@config = parse_config(config_location)
|
8
|
+
@config = parse_config(config_location.to_s)
|
8
9
|
end
|
9
10
|
|
10
11
|
def parse_config(config_location)
|
11
|
-
|
12
|
+
config_contents = read_config(config_location)
|
13
|
+
YAML.load(config_contents)
|
12
14
|
end
|
13
15
|
|
14
16
|
def formatters
|
@@ -22,8 +24,19 @@ module SCSSBeautifier
|
|
22
24
|
enabled_formatters
|
23
25
|
end
|
24
26
|
|
25
|
-
def
|
26
|
-
|
27
|
+
def options
|
28
|
+
options_with_key_symbols = {}
|
29
|
+
@config["options"].each do |k, v|
|
30
|
+
options_with_key_symbols[:"#{k}"] = v
|
31
|
+
end
|
32
|
+
options_with_key_symbols
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def read_config(config_location)
|
38
|
+
location = File.exists?(config_location) ? config_location : DEFAULT
|
39
|
+
File.read(location)
|
27
40
|
end
|
28
41
|
|
29
42
|
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
class SCSSBeautifier::Convert < Sass::Tree::Visitors::Convert
|
2
2
|
def visit_if(node, &block)
|
3
|
-
if
|
3
|
+
if @options[:else_placement] == "same_line"
|
4
4
|
visit_if_no_newline(node, &block)
|
5
5
|
else
|
6
6
|
super(node)
|
7
7
|
end
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
|
+
# ElsePlacement on same_line
|
10
11
|
def visit_if_no_newline(node)
|
11
12
|
name =
|
12
13
|
if !@is_else
|
@@ -65,7 +66,7 @@ class SCSSBeautifier::Convert < Sass::Tree::Visitors::Convert
|
|
65
66
|
|
66
67
|
def visit_comment(node)
|
67
68
|
value = super
|
68
|
-
node.scss_beautifier_options[:inline] ? ' ' + value.lstrip
|
69
|
+
node.scss_beautifier_options[:inline] ? ' ' + value.lstrip.to_s : value
|
69
70
|
end
|
70
71
|
|
71
72
|
def inline_comment?(node, comment_node)
|
@@ -15,7 +15,7 @@ class SCSSBeautifier::Formatters::PropertySortOrder < SCSSBeautifier::Formatters
|
|
15
15
|
if hash_key == 'comment'
|
16
16
|
seen_comments << child
|
17
17
|
prev_grouping = prop_nodes.last
|
18
|
-
if prop_node_for(prev_grouping).line == child.line
|
18
|
+
if prev_grouping && prop_node_for(prev_grouping).line == child.line
|
19
19
|
prev_grouping << child
|
20
20
|
else
|
21
21
|
comment_array << child
|
data/tmp/dump.txt
CHANGED
@@ -48,7 +48,7 @@ https://github.com/sasstools/sass-lint/blob/master/docs/rules/id-name-format.md
|
|
48
48
|
https://github.com/sasstools/sass-lint/blob/master/docs/rules/mixin-name-format.md
|
49
49
|
|
50
50
|
https://github.com/sasstools/sass-lint/blob/master/docs/rules/no-warn.md
|
51
|
-
how do maps look like? newlines separation?
|
51
|
+
how do maps look like? newlines separation? (same with lists)
|
52
52
|
parenthesis around if statements?
|
53
53
|
|
54
54
|
|
data/web/Gemfile.lock
CHANGED
data/web/app.rb
CHANGED
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.
|
4
|
+
version: 0.1.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Tse
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sass
|