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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 865105745c3f2d3fb50fc610d8f6971159fc4f2fa45bb9c8fac3e3e2c5a3b1e3
4
- data.tar.gz: 5aad10ead21110a08016fb61154ecc720ecbcc5c8ad42647a1bc5e1676c0833e
3
+ metadata.gz: 2fd54a50bb304163508a2efe1c02aaeafead5bde9c99ec9d14be43af78e9a252
4
+ data.tar.gz: 0f78f5948d7b3f59990d167165af6aeaf5ace27cd1ef51bbdd655140c6ec71f8
5
5
  SHA512:
6
- metadata.gz: 180aad68a1b54483167924217eda171f1090ddd5c28eccd9043d2a18b73d19aaa6ef1c9913646719f39519ef82b3ac940457fa086d6f67f12909804e1c929a02
7
- data.tar.gz: 6d408f0b1cba8c2885b368fdc2334375de5e1cabf7958227288047c93895b1c3aaea6a7e4d597e4736ae3fe224ae57d17725357ffc9b6fe4fb438e5b6bc883f7
6
+ metadata.gz: 80d816005a9983387cd77c50ee5b2ec7f247e1695e53e35fc0d1462c6e8ea552bf532829fba822a8a39bf7701e33f82ba8d0f11370bd54425c98e4f7a8987356
7
+ data.tar.gz: 59dbcd9eee3fe1fbd1b695302d0204edb174d38ee646495245ce76354e47909f8a71745f7b39f4d228223ed347eeeadc40e0eeb590437e780e11c38a0bef00e8
@@ -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
- config_file = options[:config]
18
- config = Configuration.load_from(config_file)
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 :entry_point
6
+ attr_reader :path
7
7
 
8
- def initialize(config, entry_point = Dir.pwd)
8
+ def initialize(config, path)
9
9
  raise TypeError unless config.is_a? Configuration
10
- raise TypeError unless Dir.exist?(entry_point)
10
+ raise TypeError unless Dir.exist?(path)
11
11
  @config = config
12
- @entry_point = entry_point
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, entry_point) }
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, entry_point) }
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
 
@@ -1,4 +1,4 @@
1
1
  CodeFormatter::Configuration.new do |c|
2
- c.included_files = ['path/to/included/file.ext']
3
- c.excluded_files = ['path/to/excluded/file.ext']
2
+ c.included_files = ['path/to/included/file']
3
+ c.excluded_files = ['path/to/excluded/file']
4
4
  end
@@ -1,3 +1,3 @@
1
1
  module CodeFormatter
2
- VERSION = '0.0.13'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code-formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sroik