Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 125 lines (103 sloc) 2.985 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
de65328 Bump up the version
Carl Lerche authored
7 VERSION = "0.9.0.pre3"
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'
17 autoload :Source, 'bundler/source'
18 autoload :Specification, 'bundler/specification'
434fb42 First pass at output
Carlhuda authored
19 autoload :UI, 'bundler/ui'
67859e4 Moving in thor
Carlhuda authored
20
de5054a Rescue all Bundler exceptions and exit with appropriate error code
Carlhuda authored
21 class BundlerError < StandardError
22 def self.status_code(code = nil)
23 return @code unless code
24 @code = code
25 end
26
27 def status_code
28 self.class.status_code
29 end
30 end
31
32 class GemfileNotFound < BundlerError; status_code(10) ; end
33 class GemNotFound < BundlerError; status_code(7) ; end
34 class VersionConflict < BundlerError; status_code(6) ; end
35 class GemfileError < BundlerError; status_code(4) ; end
67859e4 Moving in thor
Carlhuda authored
36
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
37 class << self
38 attr_accessor :ui, :bundle_path
39
40 def configure
41 @configured ||= begin
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
42 point_gem_home(env[:bundle_path])
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
43 true
44 end
45 end
434fb42 First pass at output
Carlhuda authored
46
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
47 def ui
48 @ui ||= UI.new
49 end
434fb42 First pass at output
Carlhuda authored
50
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
51 def bundle_path
52 @bundle_path ||= Pathname.new(env[:bundle_path] || Gem.dir)
53 end
54
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
55 def setup(*groups)
56 gemfile = default_gemfile
57 load(gemfile).setup(*groups)
58 end
ce350cc Get a simple bbl install working
Carlhuda authored
59
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
60 def load(gemfile = default_gemfile)
61 root = Pathname.new(gemfile).dirname
62 Environment.new root, definition(gemfile)
63 end
67859e4 Moving in thor
Carlhuda authored
64
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
65 def definition(gemfile = default_gemfile)
66 configure
67 root = Pathname.new(gemfile).dirname
68 lockfile = root.join("vendor/lock.yml")
69 if lockfile.exist?
70 Definition.from_lock(lockfile)
71 else
72 Definition.from_gemfile(gemfile)
73 end
88741e6 First pass at bbl lock
Carlhuda authored
74 end
f31835e More work towards awesomeness
Carlhuda authored
75
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
76 def home
77 Pathname.new(bundle_path).join("bundler")
78 end
f31835e More work towards awesomeness
Carlhuda authored
79
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
80 def install_path
81 home.join("gems")
82 end
0d2492d Add more stuff for git
Carl Lerche authored
83
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
84 def cache
85 home.join("cache")
86 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
87
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
88 def root
89 default_gemfile.dirname
90 end
91
92 private
63b636b First pass at gemfile pack
Carlhuda authored
93
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
94 def default_gemfile
95 current = Pathname.new(Dir.pwd)
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
96
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
97 until current.root?
98 filename = current.join("Gemfile")
99 return filename if filename.exist?
100 current = current.parent
101 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
102
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
103 raise GemfileNotFound, "The default Gemfile was not found"
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
104 end
105
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
106 def env
107 @env ||= begin
108 env = {}
109 file = "#{root}/.bundleconfig"
110 config = File.exist?(file) ? YAML.load_file(file) : {}
111 %w(BUNDLE_PATH).each do |key|
112 env[key.downcase.to_sym] = config[key] || ENV[key]
113 end
114 env
115 end
116 end
117
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
118 def point_gem_home(path)
119 return unless path
120 ENV['GEM_HOME'] = File.expand_path(path, root)
121 ENV['GEM_PATH'] = ''
122 Gem.clear_paths
123 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
124 end
67859e4 Moving in thor
Carlhuda authored
125 end
Something went wrong with that request. Please try again.