Skip to content

HTTPS clone URL

Subversion checkout URL

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