@@ -3,6 +3,28 @@ lib = File.expand_path('../lib', __FILE__)
3
3
$LOAD_PATH. unshift ( lib ) unless $LOAD_PATH. include? ( lib )
4
4
require 'pact_broker/version'
5
5
6
+ def gem_files
7
+ if Dir . exist? ( ".git" )
8
+ `git ls-files` . split ( $/)
9
+ else
10
+ root_path = File . dirname ( __FILE__ )
11
+ all_files = Dir . chdir ( root_path ) { Dir . glob ( "**/{*,.*}" ) }
12
+ all_files . reject! { |file | [ "." , ".." ] . include? ( File . basename ( file ) ) || File . directory? ( file ) }
13
+ gitignore_path = File . join ( root_path , ".gitignore" )
14
+ gitignore = File . readlines ( gitignore_path )
15
+ gitignore . map! { |line | line . chomp . strip }
16
+ gitignore . reject! { |line | line . empty? || line =~ /^(#|!)/ }
17
+
18
+ all_files . reject do |file |
19
+ gitignore . any? do |ignore |
20
+ file . start_with? ( ignore ) ||
21
+ File . fnmatch ( ignore , file , File ::FNM_PATHNAME ) ||
22
+ File . fnmatch ( ignore , File . basename ( file ) , File ::FNM_PATHNAME )
23
+ end
24
+ end
25
+ end
26
+ end
27
+
6
28
Gem ::Specification . new do |gem |
7
29
gem . name = "pact_broker"
8
30
gem . version = PactBroker ::VERSION
@@ -14,7 +36,7 @@ Gem::Specification.new do |gem|
14
36
15
37
gem . required_ruby_version = '>= 2.2.0'
16
38
17
- gem . files = `git ls-files` . split ( $/ )
39
+ gem . files = gem_files
18
40
gem . executables = gem . files . grep ( %r{^bin/} ) . map { |f | File . basename ( f ) }
19
41
gem . test_files = gem . files . grep ( %r{^(test|spec|features)/} )
20
42
gem . require_paths = [ "lib" ]
0 commit comments