bundler 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

@@ -2,6 +2,7 @@
2
2
 
3
3
  Github: http://github.com/wycats/bundler
4
4
  Mailing list: http://groups.google.com/group/ruby-bundler
5
+ IRC: #carlhuda on freenode
5
6
 
6
7
  ## Intro
7
8
 
@@ -110,7 +111,7 @@ run it with the `gem exec` command. For example:
110
111
  Yet another way is to manually require the environment file first. This is
111
112
  located in `[bundle_path]/environments/default.rb`. For example:
112
113
 
113
- ruby -r vendor/gems/environments/default.rb my_ruby_script.rb
114
+ ruby -r vendor/gems/environment.rb my_ruby_script.rb
114
115
 
115
116
  ### Using Bundler with Rails today
116
117
 
@@ -134,7 +135,7 @@ to follow.
134
135
 
135
136
  * At the top of `config/boot.rb`, add the following line:
136
137
 
137
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'environments', 'default'))
138
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'environment'))
138
139
 
139
140
  In theory, this should be enough to get going.
140
141
 
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'spec/rake/spectask'
6
6
 
7
7
  spec = Gem::Specification.new do |s|
8
8
  s.name = "bundler"
9
- s.version = "0.3.1"
9
+ s.version = "0.4.0"
10
10
  s.author = "Yehuda Katz"
11
11
  s.email = "wycats@gmail.com"
12
12
  s.homepage = "http://github.com/wycats/bundler"
@@ -16,6 +16,8 @@ spec = Gem::Specification.new do |s|
16
16
  s.has_rdoc = true
17
17
  s.extra_rdoc_files = ["README.markdown", "LICENSE"]
18
18
 
19
+ s.required_rubygems_version = ">= 1.3.5"
20
+
19
21
  s.require_path = 'lib'
20
22
  s.files = %w(LICENSE README.markdown Rakefile) + Dir.glob("lib/**/*")
21
23
  end
@@ -14,7 +14,7 @@ require "bundler/resolver"
14
14
  require "bundler/manifest_file"
15
15
  require "bundler/manifest"
16
16
  require "bundler/dependency"
17
- require "bundler/runtime"
17
+ require "bundler/dsl"
18
18
  require "bundler/cli"
19
19
  require "bundler/repository"
20
20
 
@@ -4,6 +4,21 @@ module Bundler
4
4
  class CLI
5
5
  def self.run(command, options = {})
6
6
  new(options).run(command)
7
+ rescue DefaultManifestNotFound => e
8
+ Bundler.logger.error "Could not find a Gemfile to use"
9
+ exit 2
10
+ rescue InvalidEnvironmentName => e
11
+ Bundler.logger.error "Gemfile error: #{e.message}"
12
+ exit
13
+ rescue InvalidRepository => e
14
+ Bundler.logger.error e.message
15
+ exit
16
+ rescue VersionConflict => e
17
+ Bundler.logger.error e.message
18
+ exit
19
+ rescue GemNotFound => e
20
+ Bundler.logger.error e.message
21
+ exit
7
22
  end
8
23
 
9
24
  def initialize(options)
@@ -22,21 +37,7 @@ module Bundler
22
37
  end
23
38
 
24
39
  def run(command)
25
-
26
40
  send(command)
27
-
28
- rescue DefaultManifestNotFound => e
29
- Bundler.logger.error "Could not find a Gemfile to use"
30
- exit 2
31
- rescue InvalidEnvironmentName => e
32
- Bundler.logger.error "Gemfile error: #{e.message}"
33
- exit
34
- rescue InvalidRepository => e
35
- Bundler.logger.error e.message
36
- exit
37
- rescue VersionConflict => e
38
- Bundler.logger.error e.message
39
- exit
40
41
  end
41
42
 
42
43
  end
@@ -4,7 +4,7 @@ module Bundler
4
4
  class Dependency
5
5
  attr_reader :name, :version, :require_as, :only, :except
6
6
 
7
- def initialize(name, options = {})
7
+ def initialize(name, options = {}, &block)
8
8
  options.each do |k, v|
9
9
  options[k.to_s] = v
10
10
  end
@@ -14,6 +14,7 @@ module Bundler
14
14
  @require_as = Array(options["require_as"] || name)
15
15
  @only = Array(options["only"]).map {|e| e.to_s } if options["only"]
16
16
  @except = Array(options["except"]).map {|e| e.to_s } if options["except"]
17
+ @block = block
17
18
 
18
19
  if (@only && @only.include?("rubygems")) || (@except && @except.include?("rubygems"))
19
20
  raise InvalidEnvironmentName, "'rubygems' is not a valid environment name"
@@ -32,6 +33,16 @@ module Bundler
32
33
  to_gem_dependency.to_s
33
34
  end
34
35
 
36
+ def require(environment)
37
+ return unless in?(environment)
38
+
39
+ @require_as.each do |file|
40
+ super(file)
41
+ end
42
+
43
+ @block.call if @block
44
+ end
45
+
35
46
  def to_gem_dependency
36
47
  @gem_dep ||= Gem::Dependency.new(name, version)
37
48
  end
@@ -0,0 +1,61 @@
1
+ module Bundler
2
+ class ManifestFileNotFound < StandardError; end
3
+
4
+ class ManifestBuilder
5
+ def self.build(manifest_file, string)
6
+ builder = new(manifest_file)
7
+ builder.instance_eval(string)
8
+ builder
9
+ end
10
+
11
+ def self.load(manifest_file, filename)
12
+ unless File.exist?(filename)
13
+ raise ManifestFileNotFound, "#{filename.inspect} does not exist"
14
+ end
15
+ string = File.read(filename)
16
+ build(manifest_file, string)
17
+ end
18
+
19
+ def initialize(manifest_file)
20
+ @manifest_file = manifest_file
21
+ end
22
+
23
+ def bundle_path(path)
24
+ path = Pathname.new(path)
25
+ @manifest_file.gem_path = (path.relative? ?
26
+ @manifest_file.root.join(path) : path).expand_path
27
+ end
28
+
29
+ def bin_path(path)
30
+ path = Pathname.new(path)
31
+ @manifest_file.bindir = (path.relative? ?
32
+ @manifest_file.root.join(path) : path).expand_path
33
+ end
34
+
35
+ def disable_rubygems
36
+ @manifest_file.rubygems = false
37
+ end
38
+
39
+ def disable_system_gems
40
+ @manifest_file.system_gems = false
41
+ end
42
+
43
+ def source(source)
44
+ source = Source.new(source)
45
+ unless @manifest_file.sources.include?(source)
46
+ @manifest_file.add_source(source)
47
+ end
48
+ end
49
+
50
+ def clear_sources
51
+ @manifest_file.clear_sources
52
+ end
53
+
54
+ def gem(name, *args)
55
+ options = args.last.is_a?(Hash) ? args.pop : {}
56
+ version = args.last
57
+
58
+ @manifest_file.dependencies << Dependency.new(name, options.merge(:version => version))
59
+ end
60
+ end
61
+ end
@@ -18,23 +18,6 @@ module Bundler
18
18
  @sources = sources
19
19
  end
20
20
 
21
- # Figures out the best possible configuration of gems that satisfies
22
- # the list of passed dependencies and any child dependencies without
23
- # causing any gem activation errors.
24
- #
25
- # ==== Parameters
26
- # *dependencies<Gem::Dependency>:: The list of dependencies to resolve
27
- #
28
- # ==== Returns
29
- # <GemBundle>,nil:: If the list of dependencies can be resolved, a
30
- # collection of gemspecs is returned. Otherwise, nil is returned.
31
- def resolve(*dependencies)
32
- Bundler.logger.info "Calculating dependencies..."
33
-
34
- resolved = Resolver.resolve(dependencies, self)
35
- resolved && GemBundle.new(resolved)
36
- end
37
-
38
21
  # Searches for a gem that matches the dependency
39
22
  #
40
23
  # ==== Parameters
@@ -2,8 +2,8 @@ module Gem
2
2
  class Installer
3
3
  def app_script_text(bin_file_name)
4
4
  path = @gem_home
5
- template = File.read(File.join(File.dirname(__FILE__), "templates", "app_script.rb"))
6
- erb = ERB.new(template)
5
+ template = File.read(File.join(File.dirname(__FILE__), "templates", "app_script.erb"))
6
+ erb = ERB.new(template, nil, '-')
7
7
  erb.result(binding)
8
8
  end
9
9
  end
@@ -15,5 +15,10 @@ module Gem
15
15
  source = Bundler::Source.new(source) unless source.is_a?(Bundler::Source)
16
16
  @source = source
17
17
  end
18
+
19
+ # Hack to fix github's strange marshal file
20
+ def specification_version
21
+ @specification_version && @specification_version.to_i
22
+ end
18
23
  end
19
24
  end
@@ -4,43 +4,33 @@ module Bundler
4
4
  class VersionConflict < StandardError; end
5
5
 
6
6
  class Manifest
7
- attr_reader :sources, :dependencies, :path
7
+ attr_reader :filename, :sources, :dependencies, :path
8
8
 
9
- def initialize(sources, dependencies, bindir, repository_path, rubygems, system_gems)
9
+ def initialize(filename, sources, dependencies, bindir, path, rubygems, system_gems)
10
+ @filename = filename
10
11
  @sources = sources
11
12
  @dependencies = dependencies
12
- @bindir = bindir
13
- @repository = Repository.new(repository_path)
13
+ @bindir = bindir || repository.path.join("bin")
14
+ @path = path
14
15
  @rubygems = rubygems
15
16
  @system_gems = system_gems
16
17
  end
17
18
 
18
19
  def install(update)
19
20
  fetch(update)
20
- @repository.install_cached_gems(:bin_dir => @bindir || @repository.path.join("bin"))
21
- cleanup_removed_gems
22
- create_environment_files(@repository.path.join("environments"))
21
+ repository.install_cached_gems(:bin_dir => @bindir)
22
+ # Cleanup incase fetch was a no-op
23
+ repository.cleanup(gems)
24
+ create_environment_file(repository.path)
23
25
  Bundler.logger.info "Done."
24
26
  end
25
27
 
26
- def activate(environment = "default")
27
- require @repository.path.join("environments", "#{environment}.rb")
28
+ def gems
29
+ deps = dependencies
30
+ deps = deps.map { |d| d.to_gem_dependency }
31
+ Resolver.resolve(deps, repository.source_index)
28
32
  end
29
33
 
30
- def require_all
31
- dependencies.each do |dep|
32
- dep.require_as.each {|file| require file }
33
- end
34
- end
35
-
36
- def gems_for(environment = nil)
37
- deps = dependencies
38
- deps = deps.select { |d| d.in?(environment) } if environment
39
- deps = deps.map { |d| d.to_gem_dependency }
40
- Resolver.resolve(deps, @repository.source_index)
41
- end
42
- alias gems gems_for
43
-
44
34
  def environments
45
35
  envs = dependencies.map {|dep| Array(dep.only) + Array(dep.except) }.flatten
46
36
  envs << "default"
@@ -48,16 +38,28 @@ module Bundler
48
38
 
49
39
  private
50
40
 
41
+ def finder
42
+ @finder ||= Finder.new(*sources)
43
+ end
44
+
45
+ def repository
46
+ @repository ||= Repository.new(@path, @bindir)
47
+ end
48
+
51
49
  def fetch(update)
52
50
  return unless update || !all_gems_installed?
53
51
 
54
- finder = Finder.new(*sources)
55
- unless bundle = finder.resolve(*gem_dependencies)
52
+ unless bundle = Resolver.resolve(gem_dependencies, finder)
56
53
  gems = @dependencies.map {|d| " #{d.to_s}" }.join("\n")
57
54
  raise VersionConflict, "No compatible versions could be found for:\n#{gems}"
58
55
  end
59
56
 
60
- bundle.download(@repository)
57
+ # Cleanup here to remove any gems that could cause problem in the expansion
58
+ # phase
59
+ #
60
+ # TODO: Try to avoid double cleanup
61
+ repository.cleanup(bundle)
62
+ bundle.download(repository)
61
63
  end
62
64
 
63
65
  def gem_dependencies
@@ -67,7 +69,7 @@ module Bundler
67
69
  def all_gems_installed?
68
70
  downloaded_gems = {}
69
71
 
70
- Dir[@repository.path.join("cache", "*.gem")].each do |file|
72
+ Dir[repository.path.join("cache", "*.gem")].each do |file|
71
73
  file =~ /\/([^\/]+)-([\d\.]+)\.gem$/
72
74
  name, version = $1, $2
73
75
  downloaded_gems[name] = Gem::Version.new(version)
@@ -79,36 +81,18 @@ module Bundler
79
81
  end
80
82
  end
81
83
 
82
- def cleanup_removed_gems
83
- glob = gems.map { |g| g.full_name }.join(',')
84
- base = @repository.path.join("{cache,specifications,gems}")
85
-
86
- (Dir[base.join("*")] - Dir[base.join("{#{glob}}{.gemspec,.gem,}")]).each do |file|
87
- Bundler.logger.info "Deleting gem: #{File.basename(file, ".gem")}" if File.basename(file) =~ /\.gem$/
88
- FileUtils.rm_rf(file)
89
- end
90
-
91
- glob = gems.map { |g| g.executables }.flatten.join(',')
92
- (Dir[@bindir.join("*")] - Dir[@bindir.join("{#{glob}}")]).each do |file|
93
- Bundler.logger.info "Deleting bin file: #{File.basename(file)}"
94
- FileUtils.rm_rf(file)
95
- end
96
- end
97
-
98
- def create_environment_files(path)
84
+ def create_environment_file(path)
99
85
  FileUtils.mkdir_p(path)
100
- environments.each do |environment|
101
- specs = gems_for(environment)
102
- files = spec_files_for_specs(specs, path)
103
- load_paths = load_paths_for_specs(specs)
104
- create_environment_file(path, environment, files, load_paths)
105
- end
106
- end
107
86
 
108
- def create_environment_file(path, environment, spec_files, load_paths)
109
- File.open(path.join("#{environment}.rb"), "w") do |file|
110
- template = File.read(File.join(File.dirname(__FILE__), "templates", "environment.rb"))
111
- erb = ERB.new(template)
87
+ specs = gems
88
+ spec_files = spec_files_for_specs(specs, path)
89
+ load_paths = load_paths_for_specs(specs)
90
+ bindir = @bindir.relative_path_from(path).to_s
91
+ filename = @filename.relative_path_from(path).to_s
92
+
93
+ File.open(path.join("environment.rb"), "w") do |file|
94
+ template = File.read(File.join(File.dirname(__FILE__), "templates", "environment.erb"))
95
+ erb = ERB.new(template, nil, '-')
112
96
  file.puts erb.result(binding)
113
97
  end
114
98
  end
@@ -116,9 +100,13 @@ module Bundler
116
100
  def load_paths_for_specs(specs)
117
101
  load_paths = []
118
102
  specs.each do |spec|
119
- load_paths << File.join(spec.full_gem_path, spec.bindir) if spec.bindir
103
+ gem_path = Pathname.new(spec.full_gem_path)
104
+
105
+ if spec.bindir
106
+ load_paths << gem_path.join(spec.bindir).relative_path_from(@path).to_s
107
+ end
120
108
  spec.require_paths.each do |path|
121
- load_paths << File.join(spec.full_gem_path, path)
109
+ load_paths << gem_path.join(path).relative_path_from(@path).to_s
122
110
  end
123
111
  end
124
112
  load_paths
@@ -127,7 +115,7 @@ module Bundler
127
115
  def spec_files_for_specs(specs, path)
128
116
  files = {}
129
117
  specs.each do |s|
130
- files[s.name] = path.join("..", "specifications", "#{s.full_name}.gemspec").expand_path
118
+ files[s.name] = File.join("specifications", "#{s.full_name}.gemspec")
131
119
  end
132
120
  files
133
121
  end
@@ -2,7 +2,7 @@ module Bundler
2
2
  class DefaultManifestNotFound < StandardError; end
3
3
 
4
4
  class ManifestFile
5
- attr_reader :sources, :dependencies
5
+ attr_reader :dependencies
6
6
  attr_accessor :gem_path, :bindir, :rubygems, :system_gems
7
7
 
8
8
  def self.load(filename = nil)
@@ -10,11 +10,12 @@ module Bundler
10
10
  end
11
11
 
12
12
  def initialize(filename)
13
- @filename = filename
14
- @sources = [Source.new("http://gems.rubyforge.org")]
15
- @dependencies = []
16
- @rubygems = true
17
- @system_gems = true
13
+ @filename = filename
14
+ @default_sources = [Source.new("http://gems.rubyforge.org")]
15
+ @sources = []
16
+ @dependencies = []
17
+ @rubygems = true
18
+ @system_gems = true
18
19
  end
19
20
 
20
21
  def load
@@ -30,6 +31,19 @@ module Bundler
30
31
  manifest.install(update)
31
32
  end
32
33
 
34
+ def sources
35
+ @sources + @default_sources
36
+ end
37
+
38
+ def add_source(source)
39
+ @sources << source
40
+ end
41
+
42
+ def clear_sources
43
+ @sources.clear
44
+ @default_sources.clear
45
+ end
46
+
33
47
  def setup_environment
34
48
  unless @system_gems
35
49
  ENV["GEM_HOME"] = @gem_path
@@ -41,7 +55,7 @@ module Bundler
41
55
 
42
56
  def load_manifest
43
57
  ManifestBuilder.load(self, filename)
44
- Manifest.new(sources, dependencies, bindir, gem_path, rubygems, system_gems)
58
+ Manifest.new(filename, sources, dependencies, bindir, gem_path, rubygems, system_gems)
45
59
  end
46
60
 
47
61
  def gem_path
@@ -5,8 +5,9 @@ module Bundler
5
5
 
6
6
  attr_reader :path
7
7
 
8
- def initialize(path)
9
- @path = Pathname.new(path)
8
+ def initialize(path, bindir = nil)
9
+ @path = Pathname.new(path)
10
+ @bindir = Pathname.new(bindir) || @path.join("bin")
10
11
  unless valid?
11
12
  raise InvalidRepository, "'#{path}' is not a valid gem repository"
12
13
  end
@@ -19,7 +20,7 @@ module Bundler
19
20
  end
20
21
 
21
22
  def valid?
22
- (Dir[@path.join("*")] - Dir[@path.join("{cache,doc,gems,environments,specifications}")]).empty?
23
+ (Dir[@path.join("*")] - Dir[@path.join("{cache,doc,gems,environment.rb,specifications}")]).empty?
23
24
  end
24
25
 
25
26
  def download(spec)
@@ -54,6 +55,25 @@ module Bundler
54
55
  end
55
56
  end
56
57
 
58
+ def cleanup(gems)
59
+ glob = gems.map { |g| g.full_name }.join(',')
60
+ base = path.join("{cache,specifications,gems}")
61
+
62
+ (Dir[base.join("*")] - Dir[base.join("{#{glob}}{.gemspec,.gem,}")]).each do |file|
63
+ if File.basename(file) =~ /\.gem$/
64
+ name = File.basename(file, '.gem')
65
+ Bundler.logger.info "Deleting gem: #{name}"
66
+ end
67
+ FileUtils.rm_rf(file)
68
+ end
69
+
70
+ glob = gems.map { |g| g.executables }.flatten.join(',')
71
+ (Dir[@bindir.join("*")] - Dir[@bindir.join("{#{glob}}")]).each do |file|
72
+ Bundler.logger.info "Deleting bin file: #{File.basename(file)}"
73
+ FileUtils.rm_rf(file)
74
+ end
75
+ end
76
+
57
77
  private
58
78
 
59
79
  def cache_path
@@ -19,18 +19,31 @@ module Gem
19
19
  end
20
20
 
21
21
  module Bundler
22
+ class GemNotFound < StandardError; end
22
23
 
23
24
  class Resolver
24
25
 
25
26
  attr_reader :errors
26
27
 
28
+ # Figures out the best possible configuration of gems that satisfies
29
+ # the list of passed dependencies and any child dependencies without
30
+ # causing any gem activation errors.
31
+ #
32
+ # ==== Parameters
33
+ # *dependencies<Gem::Dependency>:: The list of dependencies to resolve
34
+ #
35
+ # ==== Returns
36
+ # <GemBundle>,nil:: If the list of dependencies can be resolved, a
37
+ # collection of gemspecs is returned. Otherwise, nil is returned.
27
38
  def self.resolve(requirements, index = Gem.source_index)
39
+ Bundler.logger.info "Calculating dependencies..."
40
+
28
41
  resolver = new(index)
29
42
  result = catch(:success) do
30
43
  resolver.resolve(requirements, {})
31
44
  nil
32
45
  end
33
- result && result.values
46
+ result && GemBundle.new(result.values)
34
47
  end
35
48
 
36
49
  def initialize(index)
@@ -88,6 +101,13 @@ module Bundler
88
101
  # TODO: Warn / error when no matching versions are found.
89
102
  matching_versions = @index.search(current)
90
103
 
104
+ if matching_versions.empty?
105
+ if current.required_by.empty?
106
+ raise GemNotFound, "Could not find gem '#{current}' in any of the sources"
107
+ end
108
+ Bundler.logger.warn "Could not find gem '#{current}' (required by '#{current.required_by.last}') in any of the sources"
109
+ end
110
+
91
111
  matching_versions.reverse_each do |spec|
92
112
  conflict = resolve_requirement(spec, current, reqs.dup, activated.dup)
93
113
  conflicts << conflict if conflict
@@ -1,61 +1,46 @@
1
+ require "bundler/dependency"
2
+
1
3
  module Bundler
2
4
  class ManifestFileNotFound < StandardError; end
3
5
 
4
- class ManifestBuilder
5
- def self.build(manifest_file, string)
6
- builder = new(manifest_file)
7
- builder.instance_eval(string)
8
- builder
9
- end
6
+ def self.require(environment = nil)
7
+ ManifestBuilder.run(@gemfile, environment || :default)
8
+ end
10
9
 
11
- def self.load(manifest_file, filename)
12
- unless File.exist?(filename)
13
- raise ManifestFileNotFound, "#{filename.inspect} does not exist"
10
+ class ManifestBuilder
11
+ def self.run(gemfile, environment)
12
+ unless File.exist?(gemfile)
13
+ raise ManifestFileNotFound, "#{gemfile.inspect} does not exist"
14
14
  end
15
- string = File.read(filename)
16
- build(manifest_file, string)
17
- end
18
15
 
19
- def initialize(manifest_file)
20
- @manifest_file = manifest_file
16
+ builder = new(environment)
17
+ builder.instance_eval(File.read(gemfile))
18
+ builder
21
19
  end
22
20
 
23
- def bundle_path(path)
24
- path = Pathname.new(path)
25
- @manifest_file.gem_path = (path.relative? ?
26
- @manifest_file.root.join(path) : path).expand_path
21
+ def initialize(environment)
22
+ @environment = environment
27
23
  end
28
24
 
29
- def bin_path(path)
30
- path = Pathname.new(path)
31
- @manifest_file.bindir = (path.relative? ?
32
- @manifest_file.root.join(path) : path).expand_path
33
- end
25
+ def bundle_path(*) ; end
34
26
 
35
- def disable_rubygems
36
- @manifest_file.rubygems = false
37
- end
27
+ def bin_path(*) ; end
38
28
 
39
- def disable_system_gems
40
- @manifest_file.system_gems = false
41
- end
29
+ def disable_rubygems(*) ; end
42
30
 
43
- def source(source)
44
- source = Source.new(source)
45
- unless @manifest_file.sources.include?(source)
46
- @manifest_file.sources << source
47
- end
48
- end
31
+ def disable_system_gems(*) ; end
49
32
 
50
- def sources
51
- @manifest_file.sources
52
- end
33
+ def source(*) ; end
34
+
35
+ def clear_sources(*) ; end
53
36
 
54
- def gem(name, *args)
37
+ def gem(name, *args, &blk)
55
38
  options = args.last.is_a?(Hash) ? args.pop : {}
56
39
  version = args.last
57
40
 
58
- @manifest_file.dependencies << Dependency.new(name, options.merge(:version => version))
41
+ dep = Dependency.new(name, options.merge(:version => version), &blk)
42
+ dep.require(@environment)
43
+ dep
59
44
  end
60
45
  end
61
- end
46
+ end
@@ -0,0 +1,3 @@
1
+ <%= shebang bin_file_name %>
2
+ require File.join(File.dirname(__FILE__), "<%= path.join("environment").relative_path_from(Pathname.new(bin_dir)) %>")
3
+ load File.join(File.dirname(__FILE__), "<%= path.join("gems", @spec.full_name, @spec.bindir, bin_file_name).relative_path_from(Pathname.new(bin_dir)) %>")
@@ -1,30 +1,30 @@
1
- <% unless @system_gems %>
2
- ENV["GEM_HOME"] = "<%= @repository.path %>"
3
- ENV["GEM_PATH"] = "<%= @repository.path %>"
4
- <% end %>
5
- ENV["PATH"] = "<%= @bindir %>:#{ENV["PATH"]}"
6
- ENV["RUBYOPT"] = "-r#{__FILE__} #{ENV["RUBYOPT"]}"
1
+ module Bundler
2
+ dir = File.dirname(__FILE__)
7
3
 
8
- <% load_paths.each do |load_path| %>
9
- $LOAD_PATH.unshift "<%= load_path %>"
10
- <% end %>
4
+ <% unless @system_gems -%>
5
+ ENV["GEM_HOME"] = dir
6
+ ENV["GEM_PATH"] = dir
7
+ <% end -%>
8
+ ENV["PATH"] = "#{dir}/<%= bindir %>:#{ENV["PATH"]}"
9
+ ENV["RUBYOPT"] = "-r#{__FILE__} #{ENV["RUBYOPT"]}"
11
10
 
12
- <% if @rubygems %>
13
- require "rubygems"
11
+ <% load_paths.each do |load_path| -%>
12
+ $LOAD_PATH.unshift "#{dir}/<%= load_path %>"
13
+ <% end -%>
14
14
 
15
- module Bundler
15
+ @gemfile = "#{dir}/<%= filename %>"
16
+
17
+ <% if @rubygems -%>
18
+ require "rubygems"
16
19
 
17
20
  @bundled_specs = {}
18
- <% spec_files.each do |name, path| %>
19
- @bundled_specs["<%= name %>"] = eval(File.read("<%= path %>"))
20
- @bundled_specs["<%= name %>"].loaded_from = "<%= path %>"
21
- <% end %>
21
+ <% spec_files.each do |name, path| -%>
22
+ @bundled_specs["<%= name %>"] = eval(File.read("#{dir}/<%= path %>"))
23
+ @bundled_specs["<%= name %>"].loaded_from = "#{dir}/<%= path %>"
24
+ <% end -%>
22
25
 
23
26
  def self.add_specs_to_loaded_specs
24
27
  Gem.loaded_specs.merge! @bundled_specs
25
- if Gem.respond_to?(:loaded_stacks)
26
- @bundled_specs.keys.each { |name| Gem.loaded_stacks[name] = [] }
27
- end
28
28
  end
29
29
 
30
30
  def self.add_specs_to_index
@@ -35,18 +35,19 @@ module Bundler
35
35
 
36
36
  add_specs_to_loaded_specs
37
37
  add_specs_to_index
38
+ <% end -%>
38
39
  end
39
40
 
41
+ <% if @rubygems -%>
40
42
  module Gem
41
43
  def source_index.refresh!
42
44
  super
43
45
  Bundler.add_specs_to_index
44
46
  end
45
47
  end
46
-
47
- <% else %>
48
-
48
+ <% else -%>
49
49
  $" << "rubygems.rb"
50
+
50
51
  module Kernel
51
52
  def gem(*)
52
53
  # Silently ignore calls to gem, since, in theory, everything
@@ -78,5 +79,6 @@ module Gem
78
79
  class VerificationError < Exception; end
79
80
  class SystemExitException < SystemExit; end
80
81
  end
82
+ <% end -%>
81
83
 
82
- <% end %>
84
+ require "bundler/runtime"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-02 00:00:00 -07:00
12
+ date: 2009-08-18 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -30,6 +30,7 @@ files:
30
30
  - lib/bundler/commands/bundle_command.rb
31
31
  - lib/bundler/commands/exec_command.rb
32
32
  - lib/bundler/dependency.rb
33
+ - lib/bundler/dsl.rb
33
34
  - lib/bundler/finder.rb
34
35
  - lib/bundler/gem_bundle.rb
35
36
  - lib/bundler/gem_ext.rb
@@ -39,9 +40,8 @@ files:
39
40
  - lib/bundler/resolver.rb
40
41
  - lib/bundler/runtime.rb
41
42
  - lib/bundler/source.rb
42
- - lib/bundler/templates/app_script.rb
43
- - lib/bundler/templates/environment.rb
44
- - lib/bundler/templates/rubygems.rb
43
+ - lib/bundler/templates/app_script.erb
44
+ - lib/bundler/templates/environment.erb
45
45
  - lib/bundler.rb
46
46
  - lib/rubygems_plugin.rb
47
47
  has_rdoc: true
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: "0"
66
+ version: 1.3.5
67
67
  version:
68
68
  requirements: []
69
69
 
@@ -1,3 +0,0 @@
1
- <%= shebang bin_file_name %>
2
- require "<%= path.join("environments", "default") %>"
3
- load "<%= path.join("gems", @spec.full_name, @spec.bindir, bin_file_name) %>"
@@ -1,5 +0,0 @@
1
- $:.delete File.expand_path(File.dirname(__FILE__))
2
- load "rubygems.rb"
3
- if defined?(Bundler) && Bundler.respond_to?(:rubygems_required)
4
- Bundler.rubygems_required
5
- end