Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 128 lines (105 sloc) 3.16 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
2c972f2 Fixes a number of issues, including superfluous fetches when packed or l...
Carlhuda authored
37 class GitError < BundlerError; status_code(11) ; end
67859e4 Moving in thor
Carlhuda authored
38
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
39 class << self
78a6b48 Rename vendor/lock.yml to Gemfile.lock
Carl Lerche authored
40 attr_writer :ui, :bundle_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
41
42 def configure
43 @configured ||= begin
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
44 configure_gem_home_and_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
45 true
46 end
47 end
434fb42 First pass at output
Carlhuda authored
48
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
49 def ui
50 @ui ||= UI.new
51 end
434fb42 First pass at output
Carlhuda authored
52
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
53 def bundle_path
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
54 @bundle_path ||= begin
55 path = settings[:path] || "#{Gem.user_home}/.bundle"
56 Pathname.new(path).expand_path(root)
57 end
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
58 end
59
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
60 def setup(*groups)
61 gemfile = default_gemfile
62 load(gemfile).setup(*groups)
63 end
ce350cc Get a simple bbl install working
Carlhuda authored
64
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
65 def load(gemfile = default_gemfile)
66 root = Pathname.new(gemfile).dirname
67 Environment.new root, definition(gemfile)
68 end
67859e4 Moving in thor
Carlhuda authored
69
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
70 def definition(gemfile = default_gemfile)
71 configure
72 root = Pathname.new(gemfile).dirname
78a6b48 Rename vendor/lock.yml to Gemfile.lock
Carl Lerche authored
73 lockfile = root.join("Gemfile.lock")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
74 if lockfile.exist?
75 Definition.from_lock(lockfile)
76 else
77 Definition.from_gemfile(gemfile)
78 end
88741e6 First pass at bbl lock
Carlhuda authored
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 home
82 Pathname.new(bundle_path).join("bundler")
83 end
f31835e More work towards awesomeness
Carlhuda authored
84
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
85 def install_path
86 home.join("gems")
87 end
0d2492d Add more stuff for git
Carl Lerche authored
88
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
89 def cache
90 home.join("cache")
91 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
92
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
93 def root
94 default_gemfile.dirname
95 end
96
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
97 def settings
98 @settings ||= Settings.new(root)
99 end
100
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
101 private
63b636b First pass at gemfile pack
Carlhuda authored
102
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
103 def default_gemfile
104 current = Pathname.new(Dir.pwd)
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
105
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
106 until current.root?
107 filename = current.join("Gemfile")
108 return filename if filename.exist?
109 current = current.parent
110 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
111
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
112 raise GemfileNotFound, "The default Gemfile was not found"
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
113 end
114
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
115 def configure_gem_home_and_path
116 if path = settings[:path]
117 ENV['GEM_HOME'] = File.expand_path(path, root)
118 ENV['GEM_PATH'] = ''
119 else
120 gem_home, gem_path = ENV["GEM_PATH"], ENV["GEM_PATH"]
121 ENV["GEM_PATH"] = [gem_home, gem_path].compact.join(File::PATH_SEPARATOR)
122 ENV["GEM_HOME"] = bundle_path.to_s
123 end
124
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
125 Gem.clear_paths
126 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
127 end
67859e4 Moving in thor
Carlhuda authored
128 end
Something went wrong with that request. Please try again.