Sha256: 0d0a4db116d26a8b99ea0cc2249a772e4442f04b591090e2cef543d9a68e8250
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
# frozen_string_literal: true module RailsAppGenerator module Diff # Diff Processor class Processor attr_reader :lhs_path attr_reader :rhs_path DEFAULT_EXCLUSION = lambda do |_file, relative_file| relative_file.start_with?('tmp') || relative_file.start_with?('node_modules') || relative_file.start_with?('log') || relative_file == 'Gemfile.lock' end def initialize(lhs_path, rhs_path) @lhs_path = lhs_path @rhs_path = rhs_path end attr_writer :exclusion_handler def compare @info ||= RailsAppGenerator::Diff::CompareInfo.new( lhs_path, file_list(lhs_path), rhs_path, file_list(rhs_path) ) end def debug compare.debug end private def exclusion_handler @exclusion_handler ||= DEFAULT_EXCLUSION end def file_list(path) prefix_path = path.end_with?('/') ? path : "#{path}/" Dir.glob("#{path}/**/*") .reject { |file| File.directory?(file) || exclusion_handler.call(file, file.delete_prefix(prefix_path)) } .map { |file| file.delete_prefix(prefix_path) } end # def diff_exclusions(file) # file.include?('config/credentials.yml.enc') || # file.include?('master.key') # end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails_app_generator-0.1.2 | lib/rails_app_generator/diff/processor.rb |
rails_app_generator-0.1.1 | lib/rails_app_generator/diff/processor.rb |