Skip to content

Commit

Permalink
Have the gem specification track whether or not it is a no_bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Lerche committed Dec 16, 2009
1 parent 648ac7f commit 2ae6287
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
13 changes: 4 additions & 9 deletions lib/bundler/bundle.rb
Expand Up @@ -20,16 +20,11 @@ def initialize(env)
def install(options = {})
dependencies = @environment.dependencies
sources = @environment.sources
update = options[:update]

# ========== from env
if only_envs = options[:only]
dependencies.reject! { |d| !only_envs.any? {|env| d.in?(env) } }
end

options[:no_bundle] = dependencies.map do |dep|
dep.source == SystemGemSource.instance && dep.name
end.compact
# ==========

# TODO: clean this up
Expand All @@ -49,7 +44,7 @@ def install(options = {})

# Check the remote sources if the existing cache does not meet the requirements
# or the user passed --update
if update || !valid
if options[:update] || !valid
Bundler.logger.info "Calculating dependencies..."
bundle = Resolver.resolve(dependencies, [@cache] + sources)
download(bundle, options)
Expand Down Expand Up @@ -145,14 +140,14 @@ def only_local(sources)

def download(bundle, options)
bundle.sort_by {|s| s.full_name.downcase }.each do |spec|
next if options[:no_bundle].include?(spec.name)
next if spec.no_bundle?
spec.source.download(spec)
end
end

def do_install(bundle, options)
bundle.each do |spec|
next if options[:no_bundle].include?(spec.name)
next if spec.no_bundle?
spec.loaded_from = @path.join("specifications", "#{spec.full_name}.gemspec")
# Do nothing if the gem is already expanded
next if @path.join("gems", spec.full_name).directory?
Expand All @@ -168,7 +163,7 @@ def do_install(bundle, options)

def generate_bins(bundle, options)
bundle.each do |spec|
next if options[:no_bundle].include?(spec.name)
next if spec.no_bundle?
# HAX -- Generate the bin
bin_dir = @bindir
path = @path
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/environment.rb
Expand Up @@ -82,7 +82,7 @@ def repository
def load_paths_for_specs(specs, options)
load_paths = []
specs.each do |spec|
next if options[:no_bundle].include?(spec.name)
next if spec.no_bundle?
full_gem_path = Pathname.new(spec.full_gem_path)

load_paths << load_path_for(full_gem_path, spec.bindir) if spec.bindir
Expand Down
5 changes: 3 additions & 2 deletions lib/bundler/gem_ext.rb
Expand Up @@ -11,8 +11,9 @@ def app_script_text(bin_file_name)
end

class Specification
attr_accessor :source
attr_accessor :location
attr_accessor :source, :location, :no_bundle

alias no_bundle? no_bundle

remove_method(:specification_version) if method_defined?(:specification_version)

Expand Down
1 change: 1 addition & 0 deletions lib/bundler/resolver.rb
Expand Up @@ -61,6 +61,7 @@ def self.resolve(requirements, sources)
# a smaller index in the array.
ordered = []
result.values.each do |spec1|
spec1.no_bundle = true if source_requirements[spec1.name] == SystemGemSource.instance
index = nil
place = ordered.detect do |spec2|
spec1.dependencies.any? { |d| d.name == spec2.name }
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/templates/environment.erb
Expand Up @@ -21,7 +21,7 @@ module Bundler

@bundled_specs = {}
<% specs.each do |spec| -%>
<% if options[:no_bundle].include?(spec.name) -%>
<% if spec.no_bundle? -%>
gem "<%= spec.name %>", "<%= spec.version %>"
<% else -%>
<% path = spec_file_for(spec) -%>
Expand Down

0 comments on commit 2ae6287

Please sign in to comment.