diff --git a/.gitignore b/.gitignore index 8147219c1..34ff2c165 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store *.gem *.rbc .bundle @@ -6,6 +7,7 @@ coverage InstalledFiles lib/bundler/man log +*.log pkg rdoc spec/reports @@ -30,6 +32,7 @@ Gemfile.lock bethtest/ *bethtest* +*bethtemp* *dogfood* bin/ db/test/change_migration_strategy/pact_broker_database.sqlite3 diff --git a/pact_broker.gemspec b/pact_broker.gemspec index f83ca3b69..aa1c8cd70 100644 --- a/pact_broker.gemspec +++ b/pact_broker.gemspec @@ -3,6 +3,28 @@ lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'pact_broker/version' +def gem_files + if Dir.exist?(".git") + `git ls-files`.split($/) + else + root_path = File.dirname(__FILE__) + all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") } + all_files.reject! { |file| [".", ".."].include?(File.basename(file)) || File.directory?(file)} + gitignore_path = File.join(root_path, ".gitignore") + gitignore = File.readlines(gitignore_path) + gitignore.map! { |line| line.chomp.strip } + gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ } + + all_files.reject do |file| + gitignore.any? do |ignore| + file.start_with?(ignore) || + File.fnmatch(ignore, file, File::FNM_PATHNAME) || + File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME) + end + end + end +end + Gem::Specification.new do |gem| gem.name = "pact_broker" gem.version = PactBroker::VERSION @@ -14,7 +36,7 @@ Gem::Specification.new do |gem| gem.required_ruby_version = '>= 2.2.0' - gem.files = `git ls-files`.split($/) + gem.files = gem_files gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"]