rename project_directory –> project_root_path, git_directory –> source_root_path

This commit is contained in:
Maxim Sorokin 2020-07-30 11:51:58 +03:00
parent 04c863cc14
commit 0eb6a299d7
3 changed files with 23 additions and 23 deletions

View File

@ -7,9 +7,9 @@ class SettingOption
def initialize
@options = OpenStruct.new
OptionParser.new do |opt|
opt.on('-p', '--project_directory STRING', 'The directory of project') { |option| @options.project_directory = option }
opt.on('-p', '--project_root_path STRING', 'The path of project directory') { |option| @options.project_root_path = option }
opt.on('-r', '--source_root_path STRING', 'The path of source directory ') { |option| @options.source_root_path = option }
opt.on('-s', '--swiftlint_executable_path STRING', 'The executable path of swiftlint') { |option| @options.swiftlint_executable_path = option }
opt.on('-g', '--git_directory STRING', 'The directory of git') { |option| @options.git_directory = option }
opt.on('-c', '--check_mode MODE', 'The mode of check is "fully" or "simplified"') { |option| @options.check_mode = option }
opt.on('-u', '--use_multiple BOOL', 'The flag indicates the use of multiple yaml swiftlint configurations') { |option| @options.use_multiple = option }
opt.on('-d', '--source_date DATE', 'The date of grouping files according touchin and old swiftlint rules') { |option| @options.source_date = option }
@ -24,8 +24,8 @@ class SettingOption
@options.use_multiple = 'false'
end
if @options.git_directory.to_s.nilOrEmpty?
@options.git_directory = @options.project_directory
if @options.source_root_path.to_s.nilOrEmpty?
@options.source_root_path = @options.project_root_path
end
if @options.touchin_swiftlint_yaml_path.to_s.nilOrEmpty?
@ -33,8 +33,8 @@ class SettingOption
end
end
def project_directory
@options.project_directory
def project_root_path
@options.project_root_path
end
def source_date
@ -53,8 +53,8 @@ class SettingOption
@options.use_multiple
end
def git_directory
@options.git_directory
def source_root_path
@options.source_root_path
end
def touchin_swiftlint_yaml_path

View File

@ -7,17 +7,17 @@ require_relative 'swift_file_manager.rb'
require_relative 'yaml_manager.rb'
class StrategyMaker
def initialize(project_directory, swiftlint_executable_path, touchin_swiftlint_yaml_path)
@project_directory = project_directory
@touchin_swiftlint_yaml_path = project_directory + touchin_swiftlint_yaml_path
@old_swiftlint_yaml_path = project_directory + '/.swiftlint.yml'
def initialize(project_root_path, swiftlint_executable_path, touchin_swiftlint_yaml_path)
@project_root_path = project_root_path
@touchin_swiftlint_yaml_path = project_root_path + touchin_swiftlint_yaml_path
@old_swiftlint_yaml_path = project_root_path + '/.swiftlint.yml'
@temporary_swiftlint_folder_name = project_directory + '/temporary_swiftlint'
@temporary_swiftlint_folder_name = project_root_path + '/temporary_swiftlint'
@touchin_swiftlint_yaml_temporary_path = @temporary_swiftlint_folder_name + '/.touchin_swiftlint.yml'
@old_swiftlint_yaml_temporary_path = @temporary_swiftlint_folder_name + '/.old_swiftlint.yml'
@swiftlint_autocorrect_command = swiftlint_executable_path + ' autocorrect --path ' + @project_directory + ' --config '
@swiftlint_lint_command = swiftlint_executable_path + ' --path ' + @project_directory + ' --config '
@swiftlint_autocorrect_command = swiftlint_executable_path + ' autocorrect --path ' + @project_root_path + ' --config '
@swiftlint_lint_command = swiftlint_executable_path + ' --path ' + @project_root_path + ' --config '
end
def run_fully_multiple_strategy(source_date)
@ -26,7 +26,7 @@ class StrategyMaker
exclude_files = unique_exclude_files(@touchin_swiftlint_yaml_manager, @old_swiftlint_yaml_manager)
swift_files = SwiftFileManager.new(exclude_files, source_date)
swift_files.find_list_file_paths(@project_directory)
swift_files.find_list_file_paths(@project_root_path)
total_touchin_excluded_files = exclude_files + swift_files.old_files
total_old_excluded_files = exclude_files + swift_files.new_files
@ -37,7 +37,7 @@ class StrategyMaker
run_multiple_strategy(@touchin_swiftlint_yaml_temporary_path, @old_swiftlint_yaml_temporary_path)
end
def run_simplified_multiple_strategy(source_date, git_directory)
def run_simplified_multiple_strategy(source_date, source_root_path)
included_files = GitСaretaker.get_modified_files
if included_files.nilOrEmpty?
@ -48,7 +48,7 @@ class StrategyMaker
create_yaml_managers_and_copy_temporary_files
exclude_files = unique_exclude_files(@touchin_swiftlint_yaml_manager, @old_swiftlint_yaml_manager)
included_files = included_files.map { |file_path| git_directory + file_path }
included_files = included_files.map { |file_path| source_root_path + file_path }
swift_file_manager = SwiftFileManager.new(exclude_files, source_date)
swift_file_manager.find_list_file_paths_from(included_files)
@ -80,7 +80,7 @@ class StrategyMaker
run_single_strategy(@touchin_swiftlint_yaml_path)
end
def run_simplified_single_strategy(git_directory)
def run_simplified_single_strategy(source_root_path)
included_files = GitСaretaker.get_modified_files
if included_files.nilOrEmpty?
@ -95,7 +95,7 @@ class StrategyMaker
swift_files = SwiftFileManager.new(touchin_excluded_files, '')
included_files = included_files.select { |file_name| not swift_files.is_excluded_file(file_name) }
included_files = included_files.map { |file_path| git_directory + file_path }
included_files = included_files.map { |file_path| source_root_path + file_path }
touchin_swiftlint_yaml_manager.update('excluded', [])
touchin_swiftlint_yaml_manager.update('included', included_files)

View File

@ -3,14 +3,14 @@ require_relative 'setting_option.rb'
require_relative 'strategy_maker.rb'
setting = SettingOption.new
strategy_maker = StrategyMaker.new(setting.project_directory, setting.swiftlint_executable_path, setting.touchin_swiftlint_yaml_path)
strategy_maker = StrategyMaker.new(setting.project_root_path, setting.swiftlint_executable_path, setting.touchin_swiftlint_yaml_path)
if setting.check_mode.eql? 'fully' and setting.use_multiple.true?
strategy_maker.run_fully_multiple_strategy(setting.source_date)
elsif setting.check_mode.eql? 'fully' and not setting.use_multiple.true?
strategy_maker.run_fully_single_strategy
elsif setting.check_mode.eql? 'simplified' and setting.use_multiple.true?
strategy_maker.run_simplified_multiple_strategy(setting.source_date, setting.git_directory)
strategy_maker.run_simplified_multiple_strategy(setting.source_date, setting.source_root_path)
elsif setting.check_mode.eql? 'simplified' and not setting.use_multiple.true?
strategy_maker.run_simplified_single_strategy(setting.git_directory)
strategy_maker.run_simplified_single_strategy(setting.source_root_path)
end