@@ -661,6 +661,16 @@ def root
661661 "#{ srcdir } /lib"
662662 end
663663 end
664+
665+ class UnpackedGem < self
666+ def collect
667+ base = @srcdir or return [ ]
668+ Dir . glob ( "**/*" , File ::FNM_DOTMATCH , base : base ) . select do |n |
669+ case File . basename ( n ) ; when "." , ".." ; next ; end
670+ !File . directory? ( File . join ( base , n ) )
671+ end
672+ end
673+ end
664674 end
665675 end
666676
@@ -772,32 +782,34 @@ def ensure_writable_dir(dir)
772782 $installed_list. puts ( d +"/" ) if $installed_list
773783 end
774784 end
785+
786+ def load_plugin
787+ # Suppress warnings for constant re-assignment
788+ verbose , $VERBOSE = $VERBOSE, nil
789+ super
790+ ensure
791+ $VERBOSE = verbose
792+ end
775793 end
776794end
777795
778796def load_gemspec ( file , base = nil )
779797 file = File . realpath ( file )
780798 code = File . read ( file , encoding : "utf-8:-" )
781799
782- files = [ ]
783- Dir . glob ( "**/*" , File ::FNM_DOTMATCH , base : base ) do |n |
784- case File . basename ( n ) ; when "." , ".." ; next ; end
785- next if File . directory? ( File . join ( base , n ) )
786- files << n . dump
787- end if base
788800 code . gsub! ( /(?:`git[^\` ]*`|%x\[ git[^\] ]*\] )\. split(\( [^\) ]*\) )?/m ) do
789- "[" + files . join ( ", " ) + " ]"
801+ "[]"
790802 end
791803 code . gsub! ( /IO\. popen\( .*git.*?\) / ) do
792- "[" + files . join ( ", " ) + " ] || itself"
804+ "[] || itself"
793805 end
794806
795807 spec = eval ( code , binding , file )
796808 unless Gem ::Specification === spec
797809 raise TypeError , "[#{ file } ] isn't a Gem::Specification (#{ spec . class } instead)."
798810 end
799811 spec . loaded_from = base ? File . join ( base , File . basename ( file ) ) : file
800- spec . files . reject! { | n | n . end_with? ( ".gemspec" ) or n . start_with? ( ".git" ) }
812+ spec . files . clear
801813 spec . date = RUBY_RELEASE_DATE
802814
803815 spec
@@ -1135,6 +1147,7 @@ class << (w = [])
11351147 # the newly installed ruby.
11361148 ENV . delete ( 'RUBYOPT' )
11371149
1150+ collector = RbInstall ::Specs ::FileCollector ::UnpackedGem
11381151 File . foreach ( "#{ srcdir } /gems/bundled_gems" ) do |name |
11391152 next if /^\s *(?:#|$)/ =~ name
11401153 next unless /^(\S +)\s +(\S +).*/ =~ name
@@ -1153,7 +1166,8 @@ class << (w = [])
11531166 skipped [ gem_name ] = "gemspec not found"
11541167 next
11551168 end
1156- spec = load_gemspec ( path , "#{ srcdir } /.bundle/gems/#{ gem_name } " )
1169+ base = "#{ srcdir } /.bundle/gems/#{ gem_name } "
1170+ spec = load_gemspec ( path , base )
11571171 unless spec . platform == Gem ::Platform ::RUBY
11581172 skipped [ gem_name ] = "not ruby platform (#{ spec . platform } )"
11591173 next
@@ -1168,6 +1182,10 @@ class << (w = [])
11681182 next
11691183 end
11701184 spec . extension_dir = "#{ extensions_dir } /#{ spec . full_name } "
1185+
1186+ # Override files with the actual files included in the gem
1187+ spec . files = collector . new ( path , base , nil ) . collect
1188+
11711189 package = RbInstall ::DirPackage . new spec
11721190 ins = RbInstall ::UnpackedInstaller . new ( package , options )
11731191 puts "#{ INDENT } #{ spec . name } #{ spec . version } "
0 commit comments