diff --git a/.rubocop.yml b/.rubocop.yml index 63a41cf00..0837ced7a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,6 +6,7 @@ AllCops: - 'spec/**/*' - 'lib/fhir_models/fhir/**/*' - 'lib/fhir_models/fhirpath/evaluate.rb' + - 'lib/fhir_models/generated/**/*' - 'lib/**/*.rake' - 'tmp/**/*' - '*.gemspec' diff --git a/Gemfile b/Gemfile index 3f516d066..9bd327ec2 100644 --- a/Gemfile +++ b/Gemfile @@ -7,4 +7,4 @@ group :development, :test do gem 'debug' gem 'pry' gem 'pry-byebug' -end \ No newline at end of file +end diff --git a/dir_diff.rb b/dir_diff.rb index 8982b3927..5b293d1b8 100644 --- a/dir_diff.rb +++ b/dir_diff.rb @@ -4,13 +4,13 @@ options = {} OptionParser.new do |opts| opts.banner = "Usage: ruby #{__FILE__} [options] dir1 dir2" - opts.on("-n", "--name", "Print files in only one directory") do |n| + opts.on('-n', '--name', 'Print files in only one directory') do |n| options[:name] = n end - opts.on("-d", "--diff", "Print filenames with inconsistencies") do |d| + opts.on('-d', '--diff', 'Print filenames with inconsistencies') do |d| options[:diff] = d end - opts.on("-v", "--verbose", "Print file inconsistencies") do |v| + opts.on('-v', '--verbose', 'Print file inconsistencies') do |v| options[:verbose] = v end end.parse! @@ -18,7 +18,7 @@ def compare_directories(dir1, dir2, options) dir1_files = Dir.glob("#{dir1}/**/*").select { |f| File.file?(f) }.map { |f| f.gsub("#{dir1}/", '') }.sort dir2_files = Dir.glob("#{dir2}/**/*").select { |f| File.file?(f) }.map { |f| f.gsub("#{dir2}/", '') }.sort - + # find different files only_in_dir1 = dir1_files - dir2_files only_in_dir2 = dir2_files - dir1_files @@ -35,18 +35,18 @@ def compare_directories(dir1, dir2, options) common_files.each do |file| file1 = File.join(dir1, file) file2 = File.join(dir2, file) - unless FileUtils.compare_file(file1, file2) - puts "File #{file} differs" - puts Diffy::Diff.new(file1, file2, source: 'files', context: 1) if !options[:verbose].nil? - puts "\n" if !options[:verbose].nil? - end + next if FileUtils.compare_file(file1, file2) + + puts "File #{file} differs" + puts Diffy::Diff.new(file1, file2, source: 'files', context: 1) unless options[:verbose].nil? + puts "\n" unless options[:verbose].nil? end end if only_in_dir1.empty? && only_in_dir2.empty? && common_files.all? { |file| FileUtils.compare_file(File.join(dir1, file), File.join(dir2, file)) } - puts "Directories are identical." + puts 'Directories are identical.' elsif options[:diff].nil? - puts "Directories have unidentical files. Use -d (or --diff) to compare and -v (or --verbose) to see the differences" + puts 'Directories have unidentical files. Use -d (or --diff) to compare and -v (or --verbose) to see the differences' end end @@ -55,4 +55,4 @@ def compare_directories(dir1, dir2, options) puts "Usage: ruby #{__FILE__} [options] dir1 dir2" exit end -compare_directories(ARGV[0], ARGV[1], options) \ No newline at end of file +compare_directories(ARGV[0], ARGV[1], options)