Class: Source::VendoredGemsInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/gpm/source/files_providers/vendored_gems_installer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gemfile) ⇒ VendoredGemsInstaller

Returns a new instance of VendoredGemsInstaller.



6
7
8
9
# File 'lib/gpm/source/files_providers/vendored_gems_installer.rb', line 6

def initialize(gemfile)
  @gemfile = gemfile
  @installed = false
end

Instance Attribute Details

#gemfileObject (readonly)

Returns the value of attribute gemfile.



5
6
7
# File 'lib/gpm/source/files_providers/vendored_gems_installer.rb', line 5

def gemfile
  @gemfile
end

Instance Method Details

#directoryObject



10
11
12
# File 'lib/gpm/source/files_providers/vendored_gems_installer.rb', line 10

def directory
  File.dirname(@gemfile)
end

#install!Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gpm/source/files_providers/vendored_gems_installer.rb', line 13

def install!
  return if @installed
  delete_fields = ["RUBYOPT"]
  bundled_files = []

  old_env = ENV.to_hash
  Dir.chdir(directory) do
    ::Bundler.with_clean_env do
      delete_fields.each { |d| ENV.delete d}
      ENV["BUNDLE_GEMFILE"] = gemfile
      ENV["PWD"] = directory
      FileUtils.rm_rf('.bundle')
      ["bundle install","bundle install --deployment --verbose --without development test"].each do |c| # --standalone
        command_result = `#{c}`
        raise "#{c.inspect} failed:\n#{command_result}" unless $?.success?
      end
    end
  end
  old_env.each {|k,v| ENV[k] = v}
  @installed = true
end