scss_beautifier 0.1.17 → 0.1.18
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/Gemfile.lock +1 -1
- data/lib/scss_beautifier/cli.rb +7 -0
- data/lib/scss_beautifier/formatters/leading_zero.rb +3 -2
- data/lib/scss_beautifier/options.rb +15 -0
- data/lib/scss_beautifier/version.rb +1 -1
- data/web/Gemfile.lock +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: 0617d3cf196fbecb1bc0cc9f6e77b26e057a4578
|
4
|
+
data.tar.gz: 363ab371cd16d07b6c4071aedd97e55bd4e4fe3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cf142b7dd2dab6d97a82d8dac1404144c549cb65437e9b91f96ab6d2cbdd416e1b6678b1cbf4c864e9d1231d854d4fdc310bf446c39711535b5b2525c579547
|
7
|
+
data.tar.gz: 8f9164c52ff0de7d035c95ce510d35fd3add511b7cbe264dfdfa7a063159a7a35441697a8fa7b79d028ffffcd8427f23001b579a4bb9816d53c97ffe3686cb4f
|
data/Gemfile.lock
CHANGED
data/lib/scss_beautifier/cli.rb
CHANGED
@@ -5,6 +5,7 @@ module SCSSBeautifier
|
|
5
5
|
# Returns exit code
|
6
6
|
def run(args)
|
7
7
|
options = Options.new.parse(args)
|
8
|
+
generate_configuration and return if options[:generate_config]
|
8
9
|
|
9
10
|
contents = File.read(args.first)
|
10
11
|
engine = Sass::Engine.new(contents, cache: false, syntax: :scss)
|
@@ -24,5 +25,11 @@ module SCSSBeautifier
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
28
|
+
private
|
29
|
+
|
30
|
+
def generate_configuration
|
31
|
+
File.write(".scss-beautifier", File.read(DEFAULT))
|
32
|
+
end
|
33
|
+
|
27
34
|
end
|
28
35
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
class SCSSBeautifier::Formatters::LeadingZero < SCSSBeautifier::Formatters::Base
|
2
|
+
LEADING_ZERO_REGEX = /\b0+\./
|
2
3
|
# ExcludeZero Only
|
3
4
|
def visit_prop(node)
|
4
5
|
if Sass::Script::Tree::Literal === node.value && Sass::Script::Value::String === node.value.value
|
5
6
|
node_value = node.value.value
|
6
|
-
if node.value.value.to_s.match(
|
7
|
-
node.instance_variable_set(:@value, Sass::Script::Value::String.new(node.value.value.to_s.gsub(
|
7
|
+
if node.value.value.to_s.match(LEADING_ZERO_REGEX)
|
8
|
+
node.instance_variable_set(:@value, Sass::Script::Value::String.new(node.value.value.to_s.gsub(LEADING_ZERO_REGEX, '.')))
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|
@@ -12,17 +12,25 @@ module SCSSBeautifier
|
|
12
12
|
add_banner(opts)
|
13
13
|
add_config_option(opts)
|
14
14
|
add_in_place_option(opts)
|
15
|
+
add_generate_config_option(opts)
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
19
|
def parse(args)
|
19
20
|
@option_parser.parse!(args)
|
20
21
|
options[:path] = args.first if args.first
|
22
|
+
add_defaults
|
21
23
|
options
|
22
24
|
end
|
23
25
|
|
24
26
|
private
|
25
27
|
|
28
|
+
def add_defaults
|
29
|
+
if File.exists?(".scss-beautifier") && options[:config].nil?
|
30
|
+
options[:config] = ".scss-beautifier"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
26
34
|
def add_banner(opts)
|
27
35
|
opts.banner = unindent(<<-BANNER)
|
28
36
|
Beautify your SCSS code
|
@@ -44,6 +52,13 @@ module SCSSBeautifier
|
|
44
52
|
end
|
45
53
|
end
|
46
54
|
|
55
|
+
def add_generate_config_option(opts)
|
56
|
+
message = "generate a .scss-beautifier config with defaults"
|
57
|
+
opts.on("-g", "--gen-config", message) do |bool|
|
58
|
+
self.options[:generate_config] = bool
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
47
62
|
def unindent(str)
|
48
63
|
str.gsub(/^#{str.scan(/^[ ]+(?=\S)/).min}/, "")
|
49
64
|
end
|
data/web/Gemfile.lock
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.18
|
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-09-
|
12
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sass
|