class Gemtoabox::Project

Attributes

pdir[RW]

Public Class Methods

new() click to toggle source
# File lib/gemtoabox.rb, line 10
    def initialize
      @pdir = Dir.mktmpdir
      FileUtils.mkdir("#{@pdir}/.bundle")
      config_text = "---
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'"
      File.open("#{@pdir}/.bundle/config", 'w') { |f| f.write(config_text) }
    end

Public Instance Methods

add_gemfile(path) click to toggle source
# File lib/gemtoabox.rb, line 19
def add_gemfile(path)
  gemfile_path = path
  gemfile_lock_path = "#{File.dirname(gemfile_path)}/Gemfile.lock"
  raise "Gemfile was not found in #{path}" unless File.exist? gemfile_path
  FileUtils.cp(gemfile_path, "#{self.pdir}/Gemfile")
  FileUtils.cp(gemfile_lock_path, "#{self.pdir}/Gemfile.lock")
end
extract_gems() click to toggle source
# File lib/gemtoabox.rb, line 27
def extract_gems
  Bundler.with_clean_env do
    Dir.chdir "#{self.pdir}"
    system "bundle install"
    system "bundle package"
  end

  "#{self.pdir}/vendor/cache"
end
rm_project() click to toggle source
# File lib/gemtoabox.rb, line 37
def rm_project
  FileUtils.rm_rf self.pdir
end