code-formatter 0.0.13 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/code_formatter/cli.rb +4 -3
- data/lib/code_formatter/formatters/formatter.rb +4 -4
- data/lib/code_formatter/formatters/swift_format_formatter.rb +2 -2
- data/lib/code_formatter/formatters/swift_lint_formatter.rb +2 -2
- data/lib/code_formatter/resources/sample_config.config +2 -2
- data/lib/code_formatter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fd54a50bb304163508a2efe1c02aaeafead5bde9c99ec9d14be43af78e9a252
|
4
|
+
data.tar.gz: 0f78f5948d7b3f59990d167165af6aeaf5ace27cd1ef51bbdd655140c6ec71f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80d816005a9983387cd77c50ee5b2ec7f247e1695e53e35fc0d1462c6e8ea552bf532829fba822a8a39bf7701e33f82ba8d0f11370bd54425c98e4f7a8987356
|
7
|
+
data.tar.gz: 59dbcd9eee3fe1fbd1b695302d0204edb174d38ee646495245ce76354e47909f8a71745f7b39f4d228223ed347eeeadc40e0eeb590437e780e11c38a0bef00e8
|
data/lib/code_formatter/cli.rb
CHANGED
@@ -13,10 +13,11 @@ module CodeFormatter
|
|
13
13
|
|
14
14
|
desc 'format', 'format code with configuration'
|
15
15
|
option :config, default: Initializer.initialized_config, aliases: '-c', type: :string, desc: 'configuration file'
|
16
|
+
option :path, default: Dir.pwd, aliases: '-p', type: :string, desc: 'destination path'
|
16
17
|
def format
|
17
|
-
|
18
|
-
|
19
|
-
formatters = [SwiftFormatFormatter.new(config), SwiftLintFormatter.new(config)]
|
18
|
+
config = Configuration.load_from(options[:config])
|
19
|
+
path = options[:path]
|
20
|
+
formatters = [SwiftFormatFormatter.new(config, path), SwiftLintFormatter.new(config, path)]
|
20
21
|
formatters.each(&:format)
|
21
22
|
end
|
22
23
|
end
|
@@ -3,13 +3,13 @@ require_relative '../environment'
|
|
3
3
|
module CodeFormatter
|
4
4
|
class Formatter
|
5
5
|
attr_reader :config
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :path
|
7
7
|
|
8
|
-
def initialize(config,
|
8
|
+
def initialize(config, path)
|
9
9
|
raise TypeError unless config.is_a? Configuration
|
10
|
-
raise TypeError unless Dir.exist?(
|
10
|
+
raise TypeError unless Dir.exist?(path)
|
11
11
|
@config = config
|
12
|
-
@
|
12
|
+
@path = path
|
13
13
|
end
|
14
14
|
|
15
15
|
def format
|
@@ -41,12 +41,12 @@ module CodeFormatter
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def included_file?(file)
|
44
|
-
included_files = config.included_files.map { |f| File.expand_path(f,
|
44
|
+
included_files = config.included_files.map { |f| File.expand_path(f, path) }
|
45
45
|
included_files.any? { |f| file.start_with?(f) }
|
46
46
|
end
|
47
47
|
|
48
48
|
def excluded_file?(file)
|
49
|
-
excluded_files = config.excluded_files.map { |f| File.expand_path(f,
|
49
|
+
excluded_files = config.excluded_files.map { |f| File.expand_path(f, path) }
|
50
50
|
excluded_files.any? { |f| file.start_with?(f) }
|
51
51
|
end
|
52
52
|
|
@@ -11,8 +11,8 @@ module CodeFormatter
|
|
11
11
|
end
|
12
12
|
|
13
13
|
create_config do |file|
|
14
|
-
`swiftlint autocorrect --config #{file.path}`
|
15
|
-
`swiftlint --config #{file.path}`
|
14
|
+
`swiftlint autocorrect --path #{path} --config #{file.path}`
|
15
|
+
`swiftlint --path #{path} --config #{file.path}`
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|