Skip to content

Commit

Permalink
install package for bundler's Gemfile
Browse files Browse the repository at this point in the history
  • Loading branch information
josh authored and defunkt committed Oct 21, 2009
1 parent 2529804 commit 695cbbd
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rip.rb
Expand Up @@ -56,6 +56,7 @@ def self.user_home
require 'rip/packages/git_package'
require 'rip/packages/http_package'
require 'rip/packages/gem_package'
require 'rip/packages/gemfile_package'
require 'rip/packages/dir_package'
require 'rip/packages/file_package'
require 'rip/packages/remote_gem_package'
84 changes: 84 additions & 0 deletions lib/rip/packages/gemfile_package.rb
@@ -0,0 +1,84 @@
module Rip
class GemfilePackage < Package
handles 'Gemfile'

class Environment
attr_reader :dependencies
attr_accessor :rubygems, :system_gems, :gem_path, :bindir

def initialize
@default_sources = []
@sources = []
@priority_sources = []
@dependencies = []
@rubygems = true
@system_gems = true
end
end

def initialize(source, *args)
package = Rip::Package.for('bundler')
installer = Installer.new
installer.install(package)

require 'bundler'

super
@source = File.expand_path(source)
end

def exists?
File.exists? source
end

def name
source.split('/').last
end

def version
nil
end

def actual_package
nil
end

def meta_package?
true
end

def cached?
false
end

def dependency_installed(dependency, success = true)
if !success
ui.puts "rip: already installed #{dependency}"
end
end

def fetch!
FileUtils.rm_rf cache_path
FileUtils.mkdir_p cache_path
FileUtils.cp source, File.join(cache_path, name)
end

def unpack!
fetch
end

def dependencies!
if File.exists? filename = File.join(cache_path, name)
environment = Environment.new
builder = Bundler::Dsl.new(environment)
builder.instance_eval(File.read(filename))

environment.dependencies.map { |dependency|
Package.for(dependency.name, dependency.version)
}
else
[]
end
end
end
end

0 comments on commit 695cbbd

Please sign in to comment.