Class: Bundler::Source::Git

Inherits:
Path show all
Defined in:
lib/bundler/source.rb

Constant Summary

Constants inherited from Path

Path::DEFAULT_GLOB

Instance Attribute Summary collapse

Attributes inherited from Path

#version

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Path

#cached!, #hash, #local_specs, #remote!

Constructor Details

#initialize(options) ⇒ Git

Returns a new instance of Git.



482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/bundler/source.rb', line 482

def initialize(options)
  super

  # stringify options that could be set as symbols
  %w(ref branch tag revision).each{|k| options[k] = options[k].to_s if options[k] }

  @uri        = options["uri"]
  @ref        = options["ref"] || options["branch"] || options["tag"] || 'master'
  @revision   = options["revision"]
  @submodules = options["submodules"]
  @update     = false
  @installed  = nil
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



480
481
482
# File 'lib/bundler/source.rb', line 480

def options
  @options
end

#refObject (readonly)

Returns the value of attribute ref.



480
481
482
# File 'lib/bundler/source.rb', line 480

def ref
  @ref
end

#submodulesObject (readonly)

Returns the value of attribute submodules.



480
481
482
# File 'lib/bundler/source.rb', line 480

def submodules
  @submodules
end

#uriObject (readonly)

Returns the value of attribute uri.



480
481
482
# File 'lib/bundler/source.rb', line 480

def uri
  @uri
end

Class Method Details

.from_lock(options) ⇒ Object



496
497
498
# File 'lib/bundler/source.rb', line 496

def self.from_lock(options)
  new(options.merge("uri" => options.delete("remote")))
end

Instance Method Details

#eql?(o) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


511
512
513
514
515
516
517
518
# File 'lib/bundler/source.rb', line 511

def eql?(o)
  Git === o            &&
  uri == o.uri         &&
  ref == o.ref         &&
  name == o.name       &&
  version == o.version &&
  submodules == o.submodules
end

#install(spec) ⇒ Object



558
559
560
561
562
563
564
565
566
567
# File 'lib/bundler/source.rb', line 558

def install(spec)
  Bundler.ui.info "Using #{spec.name} (#{spec.version}) from #{to_s} "

  unless @installed
    Bundler.ui.debug "  * Checking out revision: #{ref}"
    checkout if allow_git_ops?
    @installed = true
  end
  generate_bin(spec)
end

#load_spec_filesObject



569
570
571
572
573
# File 'lib/bundler/source.rb', line 569

def load_spec_files
  super
rescue PathError, GitError
  raise GitError, "#{to_s} is not checked out. Please run `bundle install`"
end

#nameObject



527
528
529
# File 'lib/bundler/source.rb', line 527

def name
  File.basename(@uri, '.git')
end

#pathObject



531
532
533
534
535
536
537
538
539
540
541
# File 'lib/bundler/source.rb', line 531

def path
  @install_path ||= begin
    git_scope = "#{base_name}-#{shortref_for_path(revision)}"

    if Bundler.requires_sudo?
      Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope)
    else
      Bundler.install_path.join(git_scope)
    end
  end
end

#specsObject

TODO: actually cache git specs



548
549
550
551
552
553
554
555
556
# File 'lib/bundler/source.rb', line 548

def specs
  if allow_git_ops? && !@update
    # Start by making sure the git cache is up to date
    cache
    checkout
    @update = true
  end
  local_specs
end

#to_lockObject



500
501
502
503
504
505
506
507
508
509
# File 'lib/bundler/source.rb', line 500

def to_lock
  out = "GIT\n"
  out << "  remote: #{@uri}\n"
  out << "  revision: #{revision}\n"
  %w(ref branch tag submodules).each do |opt|
    out << "  #{opt}: #{options[opt]}\n" if options[opt]
  end
  out << "  glob: #{@glob}\n" unless @glob == DEFAULT_GLOB
  out << "  specs:\n"
end

#to_sObject



522
523
524
525
# File 'lib/bundler/source.rb', line 522

def to_s
  sref = options["ref"] ? shortref_for_display(options["ref"]) : ref
  "#{uri} (at #{sref})"
end

#unlock!Object



543
544
545
# File 'lib/bundler/source.rb', line 543

def unlock!
  @revision = nil
end