scss_beautifier 0.1.17 → 0.1.18

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: a9d5f273367280c4e6eab6f3531573de63b1cb7c
4
- data.tar.gz: 74cd0b8adc662dd488297016c5528ec3a9363e0e
3
+ metadata.gz: 0617d3cf196fbecb1bc0cc9f6e77b26e057a4578
4
+ data.tar.gz: 363ab371cd16d07b6c4071aedd97e55bd4e4fe3a
5
5
  SHA512:
6
- metadata.gz: aa37cb636e1b66f8def9c94cfea9fde573588005ae28aee6156779be16fd7dd627933da63ab7141191244d481ea8c07ec61fcd4004b86ed44f3ae5e8edc45e24
7
- data.tar.gz: e51be58ffbe4dc6ef1e727938f6b4dc46de1e17fc00f92164bb2fcf8d7adc5f710f93ec8639ddab2f7d23451def959b9a211f177902472233e73c49287521b13
6
+ metadata.gz: 1cf142b7dd2dab6d97a82d8dac1404144c549cb65437e9b91f96ab6d2cbdd416e1b6678b1cbf4c864e9d1231d854d4fdc310bf446c39711535b5b2525c579547
7
+ data.tar.gz: 8f9164c52ff0de7d035c95ce510d35fd3add511b7cbe264dfdfa7a063159a7a35441697a8fa7b79d028ffffcd8427f23001b579a4bb9816d53c97ffe3686cb4f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scss_beautifier (0.1.17)
4
+ scss_beautifier (0.1.18)
5
5
  sass (~> 3.4)
6
6
 
7
7
  GEM
@@ -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(/\b0\./)
7
- node.instance_variable_set(:@value, Sass::Script::Value::String.new(node.value.value.to_s.gsub(/\b0/, '')))
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
@@ -1,3 +1,3 @@
1
1
  module SCSSBeautifier
2
- VERSION = "0.1.17"
2
+ VERSION = "0.1.18"
3
3
  end
@@ -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.16)
8
+ scss_beautifier (0.1.17)
9
9
  sass (~> 3.4)
10
10
  sinatra (1.4.7)
11
11
  rack (~> 1.5)
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.17
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-02 00:00:00.000000000 Z
12
+ date: 2016-09-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sass