scss_beautifier 0.1.8 → 0.1.10

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: cc623afd604466656fe65eba5a697b41bf713910
4
- data.tar.gz: 8102f621efbb425b9916e2dff6e6aaf8c9af538d
3
+ metadata.gz: 6a3d388c808d3e8d767fa538e2383c6f18aa385f
4
+ data.tar.gz: 30e41286c9a23ffb74c3f55faf32c17270af9b4c
5
5
  SHA512:
6
- metadata.gz: 94ae0713b700ead62c325ae961c01ab01b35c53e5150f1f316d05a4db9313dcb7fceb813e070f9d3338489e5f290b803336b8425cf54961053e30457dc229889
7
- data.tar.gz: 09a959b4a7062aae05e48e6d87cc6157045de294b6771d7d3fb488da7a36daccf460a7a5965ed053a36b6a5356876e46691a693a34376069fbd004af9e10fb40
6
+ metadata.gz: b7617a95f4d89c08655812ea0d770f0ca319d5d8e4fd438c474b31dd8441f57e2b1102dee18d18e77190836b7f75056324898e8f799ea835dc24fc07f81be3bd
7
+ data.tar.gz: b1492970c8027594c1f2d42b00c94dc0d72fedaf522358631b960fc8ca0e4a3f3f3b24c1b197598d32b8997bc6ebd0778fb0f6077b5639e124d9fec568bf258a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scss_beautifier (0.1.8)
4
+ scss_beautifier (0.1.10)
5
5
  sass (~> 3.4)
6
6
 
7
7
  GEM
@@ -1,3 +1,4 @@
1
+ tab_style: " "
1
2
  formatters:
2
3
 
3
4
  border_zero:
@@ -4,17 +4,25 @@ module SCSSBeautifier
4
4
  # Takes an array of arguments
5
5
  # Returns exit code
6
6
  def run(args)
7
- contents = File.read(ARGV.first)
7
+ options = Options.new.parse(args)
8
+
9
+ contents = File.read(args.first)
8
10
  engine = Sass::Engine.new(contents, cache: false, syntax: :scss)
9
11
 
10
12
  tree = engine.to_tree
11
- Config.new(DEFAULT).formatters.each do |formatter|
13
+ config = Config.new(options[:config] || DEFAULT)
14
+
15
+ config.formatters.each do |formatter|
12
16
  formatter.visit(tree)
13
17
  end
14
18
 
15
- puts SCSSBeautifier::Convert.visit(tree, {}, :scss)
16
-
19
+ output = SCSSBeautifier::Convert.visit(tree, {indent: config.tab_style}, :scss)
20
+ if options[:in_place]
21
+ File.write(args.first, output)
22
+ else
23
+ puts output
24
+ end
17
25
  end
18
26
 
19
27
  end
20
- end
28
+ end
@@ -17,5 +17,9 @@ module SCSSBeautifier
17
17
  SCSSBeautifier::Formatters.const_get(formatter.split("_").map(&:capitalize).join)
18
18
  end
19
19
  end
20
+
21
+ def tab_style
22
+ @config["tab_style"] || " "
23
+ end
20
24
  end
21
25
  end
@@ -8,6 +8,7 @@ class SCSSBeautifier::Formatters::PseudoElement < Sass::Tree::Visitors::Base
8
8
 
9
9
  def check_pseudo(node)
10
10
  node.rule = Sass::Util.strip_string_array(node.rule.map { |r|
11
+ return r unless r.is_a?(String)
11
12
  require_double_colon = PSEUDO_ELEMENTS.index(r.split(":").last)
12
13
 
13
14
  colon_type = require_double_colon ? '::' : ':'
@@ -1,7 +1,7 @@
1
1
  class SCSSBeautifier::Formatters::Selector < Sass::Tree::Visitors::Base
2
2
  def visit_rule(node)
3
3
  node.rule = node.rule.each do |rule|
4
- rule.gsub!(/,/, ",\n")
4
+ rule.gsub!(/,/, ",\n") if rule.is_a?(String)
5
5
  end
6
6
  node.send(:try_to_parse_non_interpolated_rules)
7
7
  end
@@ -1,6 +1,6 @@
1
1
  require "optparse"
2
2
 
3
- module Lintrunner
3
+ module SCSSBeautifier
4
4
  class Options
5
5
 
6
6
  attr_reader :options
@@ -8,81 +8,39 @@ module Lintrunner
8
8
  def initialize
9
9
  @options = {}
10
10
  @option_parser = OptionParser.new do |opts|
11
+ opts.version = SCSSBeautifier::VERSION
11
12
  add_banner(opts)
12
13
  add_config_option(opts)
13
- add_context_option(opts)
14
- add_include_path_option(opts)
15
- add_reporter_option(opts)
16
- add_ignore_option(opts)
17
- add_colorize_option(opts)
14
+ add_in_place_option(opts)
18
15
  end
19
16
  end
20
17
 
21
18
  def parse(args)
22
19
  @option_parser.parse!(args)
23
- add_defaults
24
20
  options[:path] = args.first if args.first
25
21
  options
26
22
  end
27
23
 
28
24
  private
29
25
 
30
- def add_defaults
31
- options[:config] ||= ".lintrunner_config"
32
- options[:context] ||= Dir.pwd
33
- options[:include_paths] = Array(options[:include_paths]) << options[:context]
34
- options[:include_paths].uniq!
35
- options[:reporter] ||= "text"
36
- options[:path] = Dir.pwd
37
- options[:ignore] ||= []
38
- end
39
-
40
26
  def add_banner(opts)
41
27
  opts.banner = unindent(<<-BANNER)
42
- Run multiple linters with various runners
28
+ Beautify your SCSS code
43
29
  Usage: #{opts.program_name} [options] [path]
44
30
  BANNER
45
31
  end
46
32
 
47
33
  def add_config_option(opts)
48
- message = "the configuration file for lintrunner (default: .lintrunner_config)"
34
+ message = "the configuration file"
49
35
  opts.on("-c", "--config config", message, String) do |config|
50
36
  self.options[:config] = config
51
37
  end
52
38
  end
53
39
 
54
- def add_context_option(opts)
55
- message = "the path on which lintrunner will execute in (default: current path)"
56
- opts.on("-x", "--context path", message, String) do |path|
57
- self.options[:context] = Pathname.new(path).realpath.to_s
58
- end
59
- end
60
-
61
- def add_include_path_option(opts)
62
- message = "the paths to add to load paths (the context is in the load path)"
63
- opts.on("--include_path path1,...", message, Array) do |paths|
64
- self.options[:include_paths] = paths
65
- end
66
- end
67
-
68
- def add_reporter_option(opts)
69
- message = "the reporter that lintrunner uses to report results"
70
- opts.on("--reporter reporter", message, String) do |reporter|
71
- self.options[:reporter] = reporter
72
- end
73
- end
74
-
75
- def add_ignore_option(opts)
76
- message = "the messages to ignore for this lintrunner execution"
77
- opts.on("--ignore messages", message, Array) do |messages|
78
- self.options[:ignore] = messages
79
- end
80
- end
81
-
82
- def add_colorize_option(opts)
83
- message = "force colorized setting for output"
84
- opts.on("--colorize", "--[no-]colorize", message) do |bool|
85
- Rainbow.enabled = bool
40
+ def add_in_place_option(opts)
41
+ message = "whether to overwrite the file or not"
42
+ opts.on("-i", "--in-place", message) do |bool|
43
+ self.options[:in_place] = bool
86
44
  end
87
45
  end
88
46
 
@@ -1,3 +1,3 @@
1
1
  module SCSSBeautifier
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.10"
3
3
  end
@@ -11,6 +11,7 @@ require "sass"
11
11
 
12
12
  require "scss_beautifier/version"
13
13
  require "scss_beautifier/cli"
14
+ require "scss_beautifier/options"
14
15
  require "scss_beautifier/config"
15
16
 
16
17
  # Our custom SCSS to SCSS converter
data/tmp/dump.txt CHANGED
@@ -35,6 +35,8 @@ https://github.com/sasstools/sass-lint/blob/master/docs/rules/brace-style.md - i
35
35
  https://github.com/sasstools/sass-lint/blob/master/docs/rules/class-name-format.md
36
36
  https://github.com/sasstools/sass-lint/blob/master/docs/rules/empty-args.md
37
37
 
38
+ Use interpolation over + when you want a string in the end (#{$degree}deg vs $degree + deg)
39
+
38
40
  whoa never seen these rules
39
41
  https://github.com/sasstools/sass-lint/blob/master/docs/rules/force-attribute-nesting.md
40
42
  https://github.com/sasstools/sass-lint/blob/master/docs/rules/force-element-nesting.md
@@ -46,6 +48,7 @@ https://github.com/sasstools/sass-lint/blob/master/docs/rules/id-name-format.md
46
48
  https://github.com/sasstools/sass-lint/blob/master/docs/rules/mixin-name-format.md
47
49
 
48
50
  https://github.com/sasstools/sass-lint/blob/master/docs/rules/no-warn.md
51
+ how do maps look like? newlines separation?
49
52
 
50
53
 
51
54
  These are spacing rules that come out of the box:
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.8
4
+ version: 0.1.10
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-08-30 00:00:00.000000000 Z
12
+ date: 2016-08-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sass