bundler 0.4.1 → 0.5.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.

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.4.1
4
+ version: 0.5.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-19 00:00:00 -07:00
12
+ date: 2009-09-03 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -29,16 +29,16 @@ files:
29
29
  - lib/bundler/cli.rb
30
30
  - lib/bundler/commands/bundle_command.rb
31
31
  - lib/bundler/commands/exec_command.rb
32
+ - lib/bundler/dependency.rb
32
33
  - lib/bundler/dsl.rb
34
+ - lib/bundler/environment.rb
33
35
  - lib/bundler/finder.rb
34
36
  - lib/bundler/gem_bundle.rb
35
37
  - lib/bundler/gem_ext.rb
36
- - lib/bundler/manifest.rb
37
- - lib/bundler/manifest_file.rb
38
+ - lib/bundler/repository/directory_repository.rb
39
+ - lib/bundler/repository/gem_repository.rb
38
40
  - lib/bundler/repository.rb
39
41
  - lib/bundler/resolver.rb
40
- - lib/bundler/runtime/dependency.rb
41
- - lib/bundler/runtime/dsl.rb
42
42
  - lib/bundler/runtime.rb
43
43
  - lib/bundler/source.rb
44
44
  - lib/bundler/templates/app_script.erb
@@ -1,136 +0,0 @@
1
- require "rubygems/source_index"
2
-
3
- module Bundler
4
- class VersionConflict < StandardError; end
5
-
6
- class Manifest
7
- attr_reader :filename, :sources, :dependencies, :path
8
-
9
- def initialize(filename, sources, dependencies, bindir, path, rubygems, system_gems)
10
- @filename = filename
11
- @sources = sources
12
- @dependencies = dependencies
13
- @bindir = bindir || repository.path.join("bin")
14
- @path = path
15
- @rubygems = rubygems
16
- @system_gems = system_gems
17
- end
18
-
19
- def install(update)
20
- fetch(update)
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)
25
- create_bundler_runtime
26
- Bundler.logger.info "Done."
27
- end
28
-
29
- def gems
30
- deps = dependencies
31
- deps = deps.map { |d| d.to_gem_dependency }
32
- Resolver.resolve(deps, repository.source_index)
33
- end
34
-
35
- def environments
36
- envs = dependencies.map {|dep| Array(dep.only) + Array(dep.except) }.flatten
37
- envs << "default"
38
- end
39
-
40
- private
41
-
42
- def finder
43
- @finder ||= Finder.new(*sources)
44
- end
45
-
46
- def repository
47
- @repository ||= Repository.new(@path, @bindir)
48
- end
49
-
50
- def fetch(update)
51
- return unless update || !all_gems_installed?
52
-
53
- unless bundle = Resolver.resolve(gem_dependencies, finder)
54
- gems = @dependencies.map {|d| " #{d.to_s}" }.join("\n")
55
- raise VersionConflict, "No compatible versions could be found for:\n#{gems}"
56
- end
57
-
58
- # Cleanup here to remove any gems that could cause problem in the expansion
59
- # phase
60
- #
61
- # TODO: Try to avoid double cleanup
62
- repository.cleanup(bundle)
63
- bundle.download(repository)
64
- end
65
-
66
- def gem_dependencies
67
- @gem_dependencies ||= dependencies.map { |d| d.to_gem_dependency }
68
- end
69
-
70
- def all_gems_installed?
71
- downloaded_gems = {}
72
-
73
- Dir[repository.path.join("cache", "*.gem")].each do |file|
74
- file =~ /\/([^\/]+)-([\d\.]+)\.gem$/
75
- name, version = $1, $2
76
- downloaded_gems[name] = Gem::Version.new(version)
77
- end
78
-
79
- gem_dependencies.all? do |dep|
80
- downloaded_gems[dep.name] &&
81
- dep.version_requirements.satisfied_by?(downloaded_gems[dep.name])
82
- end
83
- end
84
-
85
- def create_environment_file(path)
86
- FileUtils.mkdir_p(path)
87
-
88
- specs = gems
89
- spec_files = spec_files_for_specs(specs, path)
90
- load_paths = load_paths_for_specs(specs)
91
- bindir = @bindir.relative_path_from(path).to_s
92
- filename = @filename.relative_path_from(path).to_s
93
-
94
- File.open(path.join("environment.rb"), "w") do |file|
95
- template = File.read(File.join(File.dirname(__FILE__), "templates", "environment.erb"))
96
- erb = ERB.new(template, nil, '-')
97
- file.puts erb.result(binding)
98
- end
99
- end
100
-
101
- def load_paths_for_specs(specs)
102
- load_paths = []
103
- specs.each do |spec|
104
- gem_path = Pathname.new(spec.full_gem_path)
105
-
106
- if spec.bindir
107
- load_paths << gem_path.join(spec.bindir).relative_path_from(@path).to_s
108
- end
109
- spec.require_paths.each do |path|
110
- load_paths << gem_path.join(path).relative_path_from(@path).to_s
111
- end
112
- end
113
- load_paths
114
- end
115
-
116
- def spec_files_for_specs(specs, path)
117
- files = {}
118
- specs.each do |s|
119
- files[s.name] = File.join("specifications", "#{s.full_name}.gemspec")
120
- end
121
- files
122
- end
123
-
124
- def create_bundler_runtime
125
- here = Pathname.new(__FILE__).dirname
126
- there = path.join("bundler")
127
-
128
- Bundler.logger.info "Creating the bundler runtime"
129
-
130
- FileUtils.rm_rf(there)
131
- there.mkdir
132
- FileUtils.cp(here.join("runtime.rb"), there)
133
- FileUtils.cp_r(here.join("runtime"), there)
134
- end
135
- end
136
- end
@@ -1,89 +0,0 @@
1
- module Bundler
2
- class DefaultManifestNotFound < StandardError; end
3
-
4
- class ManifestFile
5
- attr_reader :dependencies
6
- attr_accessor :gem_path, :bindir, :rubygems, :system_gems
7
-
8
- def self.load(filename = nil)
9
- new(filename).load
10
- end
11
-
12
- def initialize(filename)
13
- @filename = filename
14
- @default_sources = [Source.new("http://gems.rubyforge.org")]
15
- @sources = []
16
- @dependencies = []
17
- @rubygems = true
18
- @system_gems = true
19
- end
20
-
21
- def load
22
- manifest
23
- self
24
- end
25
-
26
- def manifest
27
- @manifest ||= load_manifest
28
- end
29
-
30
- def install(update = false)
31
- manifest.install(update)
32
- end
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
-
47
- def setup_environment
48
- unless @system_gems
49
- ENV["GEM_HOME"] = @gem_path
50
- ENV["GEM_PATH"] = @gem_path
51
- end
52
- ENV["PATH"] = "#{@bindir}:#{ENV["PATH"]}"
53
- ENV["RUBYOPT"] = "-r#{@gem_path}/environment #{ENV["RUBYOPT"]}"
54
- end
55
-
56
- def load_manifest
57
- ManifestBuilder.load(self, filename)
58
- Manifest.new(filename, sources, dependencies, bindir, gem_path, rubygems, system_gems)
59
- end
60
-
61
- def gem_path
62
- @gem_path ||= root.join("vendor", "gems")
63
- end
64
-
65
- def bindir
66
- @bindir ||= root.join("bin")
67
- end
68
-
69
- def root
70
- filename.parent
71
- end
72
-
73
- def filename
74
- Pathname.new(@filename ||= find_manifest_file)
75
- end
76
-
77
- def find_manifest_file
78
- current = Pathname.new(Dir.pwd)
79
-
80
- until current.root?
81
- filename = current.join("Gemfile")
82
- return filename if filename.exist?
83
- current = current.parent
84
- end
85
-
86
- raise DefaultManifestNotFound
87
- end
88
- end
89
- end
@@ -1,44 +0,0 @@
1
- module Bundler
2
- class ManifestFileNotFound < StandardError; end
3
-
4
- def self.require(environment = nil)
5
- ManifestBuilder.run(@gemfile, environment || :default)
6
- end
7
-
8
- class ManifestBuilder
9
- def self.run(gemfile, environment)
10
- unless File.exist?(gemfile)
11
- raise ManifestFileNotFound, "#{gemfile.inspect} does not exist"
12
- end
13
-
14
- builder = new(environment)
15
- builder.instance_eval(File.read(gemfile))
16
- builder
17
- end
18
-
19
- def initialize(environment)
20
- @environment = environment
21
- end
22
-
23
- def bundle_path(*) ; end
24
-
25
- def bin_path(*) ; end
26
-
27
- def disable_rubygems(*) ; end
28
-
29
- def disable_system_gems(*) ; end
30
-
31
- def source(*) ; end
32
-
33
- def clear_sources(*) ; end
34
-
35
- def gem(name, *args, &blk)
36
- options = args.last.is_a?(Hash) ? args.pop : {}
37
- version = args.last
38
-
39
- dep = Dependency.new(name, options.merge(:version => version), &blk)
40
- dep.require(@environment)
41
- dep
42
- end
43
- end
44
- end