Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 118 lines (96 sloc) 2.812 kB
63b636b First pass at gemfile pack
Carlhuda authored
1 require 'fileutils'
ce350cc Get a simple bbl install working
Carlhuda authored
2 require 'pathname'
88741e6 First pass at bbl lock
Carlhuda authored
3 require 'yaml'
152a50a Rename gemfile back to bundler
Carl Lerche authored
4 require 'bundler/rubygems'
ce350cc Get a simple bbl install working
Carlhuda authored
5
152a50a Rename gemfile back to bundler
Carl Lerche authored
6 module Bundler
eb714d0 Bump the version
Carl Lerche authored
7 VERSION = "0.9.0.pre5"
67859e4 Moving in thor
Carlhuda authored
8
152a50a Rename gemfile back to bundler
Carl Lerche authored
9 autoload :Definition, 'bundler/definition'
10 autoload :Dependency, 'bundler/dependency'
11 autoload :Dsl, 'bundler/dsl'
12 autoload :Environment, 'bundler/environment'
13 autoload :Index, 'bundler/index'
14 autoload :Installer, 'bundler/installer'
15 autoload :RemoteSpecification, 'bundler/remote_specification'
16 autoload :Resolver, 'bundler/resolver'
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
17 autoload :Settings, 'bundler/settings'
152a50a Rename gemfile back to bundler
Carl Lerche authored
18 autoload :Source, 'bundler/source'
19 autoload :Specification, 'bundler/specification'
434fb42 First pass at output
Carlhuda authored
20 autoload :UI, 'bundler/ui'
67859e4 Moving in thor
Carlhuda authored
21
de5054a Rescue all Bundler exceptions and exit with appropriate error code
Carlhuda authored
22 class BundlerError < StandardError
23 def self.status_code(code = nil)
24 return @code unless code
25 @code = code
26 end
27
28 def status_code
29 self.class.status_code
30 end
31 end
32
33 class GemfileNotFound < BundlerError; status_code(10) ; end
34 class GemNotFound < BundlerError; status_code(7) ; end
35 class VersionConflict < BundlerError; status_code(6) ; end
36 class GemfileError < BundlerError; status_code(4) ; end
67859e4 Moving in thor
Carlhuda authored
37
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
38 class << self
78a6b48 Rename vendor/lock.yml to Gemfile.lock
Carl Lerche authored
39 attr_writer :ui, :bundle_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
40
41 def configure
42 @configured ||= begin
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
43 point_gem_home(settings[:path])
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
44 true
45 end
46 end
434fb42 First pass at output
Carlhuda authored
47
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
48 def ui
49 @ui ||= UI.new
50 end
434fb42 First pass at output
Carlhuda authored
51
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
52 def bundle_path
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
53 @bundle_path ||= Pathname.new(settings[:path] || Gem.dir).expand_path(root)
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
54 end
55
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
56 def setup(*groups)
57 gemfile = default_gemfile
58 load(gemfile).setup(*groups)
59 end
ce350cc Get a simple bbl install working
Carlhuda authored
60
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
61 def load(gemfile = default_gemfile)
62 root = Pathname.new(gemfile).dirname
63 Environment.new root, definition(gemfile)
64 end
67859e4 Moving in thor
Carlhuda authored
65
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
66 def definition(gemfile = default_gemfile)
67 configure
68 root = Pathname.new(gemfile).dirname
78a6b48 Rename vendor/lock.yml to Gemfile.lock
Carl Lerche authored
69 lockfile = root.join("Gemfile.lock")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
70 if lockfile.exist?
71 Definition.from_lock(lockfile)
72 else
73 Definition.from_gemfile(gemfile)
74 end
88741e6 First pass at bbl lock
Carlhuda authored
75 end
f31835e More work towards awesomeness
Carlhuda authored
76
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
77 def home
78 Pathname.new(bundle_path).join("bundler")
79 end
f31835e More work towards awesomeness
Carlhuda authored
80
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
81 def install_path
82 home.join("gems")
83 end
0d2492d Add more stuff for git
Carl Lerche authored
84
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
85 def cache
86 home.join("cache")
87 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
88
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
89 def root
90 default_gemfile.dirname
91 end
92
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
93 def settings
94 @settings ||= Settings.new(root)
95 end
96
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
97 private
63b636b First pass at gemfile pack
Carlhuda authored
98
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
99 def default_gemfile
100 current = Pathname.new(Dir.pwd)
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
101
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
102 until current.root?
103 filename = current.join("Gemfile")
104 return filename if filename.exist?
105 current = current.parent
106 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
107
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
108 raise GemfileNotFound, "The default Gemfile was not found"
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
109 end
110
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
111 def point_gem_home(path)
112 return unless path
113 ENV['GEM_HOME'] = File.expand_path(path, root)
114 ENV['GEM_PATH'] = ''
115 Gem.clear_paths
116 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
117 end
67859e4 Moving in thor
Carlhuda authored
118 end
Something went wrong with that request. Please try again.