Use Bundler to manage vendor directory

Rather than having to manually keep track of what version each thing in
here is and copy files around by hand on update let's use Bundler's
standalone mode and careful use of `.gitignore` to help us do it.

This means a `bundle update --standalone` will allow us to update all
gems in vendor.

We could consider vendoring other gems this way in future but I'd
suggest only doing this for gems with no dependencies or at least gems
with no native extensions. The only gem this applies to that we
currently use is `ruby-prof` and I'm not convinced it's widely used
enough to warrant vendoring for everyone. Perhaps that's another
criteria: it should be functionality that's used by non-developer
commands and/or normal Homebrew usage.
This commit is contained in:
Mike McQuaid 2018-09-13 15:24:18 +01:00
parent 9a9f9c3e1c
commit d7eca0b57c
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
26 changed files with 53 additions and 8 deletions

9
.gitignore vendored
View File

@ -23,6 +23,15 @@
**/.bundle/cache **/.bundle/cache
**/vendor/bundle **/vendor/bundle
**/vendor/ruby **/vendor/ruby
**/vendor/bundle-standalone/ruby/*/cache
**/vendor/bundle-standalone/ruby/*/gems/*/*
**/vendor/bundle-standalone/ruby/*/specifications
# Unignore vendored gems
!**/vendor/bundle-standalone/ruby/*/gems/*/lib
# Ignore backports gem (we don't need all files)
**/vendor/bundle-standalone/ruby/*/gems/backports-*/lib
# Ignore `bin` contents (again). # Ignore `bin` contents (again).
/bin /bin

View File

@ -1,4 +1,4 @@
require "vendor/plist/plist" require "plist"
require "cask/artifact/abstract_artifact" require "cask/artifact/abstract_artifact"

View File

@ -1,5 +1,5 @@
# Contains backports from newer versions of Ruby # Contains backports from newer versions of Ruby
require_relative "../vendor/backports/string" require "backports/2.4.0/string/match"
class String class String
# String.chomp, but if result is empty: returns nil instead. # String.chomp, but if result is empty: returns nil instead.

View File

@ -5,3 +5,5 @@ HOMEBREW_LIBRARY_PATH = Pathname(__dir__).realpath
unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s) unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s)
$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.to_s) $LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.to_s)
end end
require "vendor/bundle-standalone/bundler/setup"

View File

@ -1,4 +1,4 @@
require "vendor/macho/macho" require "macho"
require "os/mac/architecture_list" require "os/mac/architecture_list"
module MachOShim module MachOShim

View File

@ -1,6 +1,6 @@
require "open3" require "open3"
require "ostruct" require "ostruct"
require "vendor/plist/plist" require "plist"
require "shellwords" require "shellwords"
require "extend/io" require "extend/io"

View File

@ -0,0 +1,4 @@
---
BUNDLE_PATH: "bundle-standalone"
BUNDLE_DISABLE_SHARED_GEMS: "true"
BUNDLE_BIN: "false"

5
Library/Homebrew/vendor/Gemfile vendored Normal file
View File

@ -0,0 +1,5 @@
source "https://rubygems.org"
gem "backports"
gem "plist"
gem "ruby-macho"

17
Library/Homebrew/vendor/Gemfile.lock vendored Normal file
View File

@ -0,0 +1,17 @@
GEM
remote: https://rubygems.org/
specs:
backports (3.8.0)
plist (3.3.0)
ruby-macho (2.0.0)
PLATFORMS
ruby
DEPENDENCIES
backports
plist
ruby-macho
BUNDLED WITH
1.16.4

View File

@ -0,0 +1,9 @@
require 'rbconfig'
# ruby 1.8.7 doesn't define RUBY_ENGINE
ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
ruby_version = RbConfig::CONFIG["ruby_version"]
path = File.expand_path('..', __FILE__)
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/backports-3.8.0/lib"
$:.unshift "#{path}/"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.3.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.0.0/lib"

View File

@ -1,4 +1,3 @@
# Taken from https://github.com/marcandre/backports/blob/v3.8.0/lib/backports/2.4.0/string/match.rb
unless String.method_defined? :match? unless String.method_defined? :match?
class String class String
def match?(*args) def match?(*args)

View File

@ -13,9 +13,9 @@ require 'base64'
require 'cgi' require 'cgi'
require 'stringio' require 'stringio'
require_relative 'plist/generator' require 'plist/generator'
require_relative 'plist/parser' require 'plist/parser'
require_relative 'plist/version' require 'plist/version'
module Plist module Plist
end end