Class: Bundler::Source::Git

Inherits:
Path
  • Object
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.



464
465
466
467
468
469
470
471
472
473
474
475
# File 'lib/bundler/source.rb', line 464

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
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



462
463
464
# File 'lib/bundler/source.rb', line 462

def options
  @options
end

#refObject (readonly)

Returns the value of attribute ref.



462
463
464
# File 'lib/bundler/source.rb', line 462

def ref
  @ref
end

#submodulesObject (readonly)

Returns the value of attribute submodules.



462
463
464
# File 'lib/bundler/source.rb', line 462

def submodules
  @submodules
end

#uriObject (readonly)

Returns the value of attribute uri.



462
463
464
# File 'lib/bundler/source.rb', line 462

def uri
  @uri
end

Class Method Details

.from_lock(options) ⇒ Object



477
478
479
# File 'lib/bundler/source.rb', line 477

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

Instance Method Details

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

Returns:

  • (Boolean)


492
493
494
495
496
497
498
499
# File 'lib/bundler/source.rb', line 492

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

#install(spec) ⇒ Object



539
540
541
542
543
544
545
546
547
548
# File 'lib/bundler/source.rb', line 539

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



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

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

#nameObject



508
509
510
# File 'lib/bundler/source.rb', line 508

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

#pathObject



512
513
514
515
516
517
518
519
520
521
522
# File 'lib/bundler/source.rb', line 512

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



529
530
531
532
533
534
535
536
537
# File 'lib/bundler/source.rb', line 529

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



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

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



503
504
505
506
# File 'lib/bundler/source.rb', line 503

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

#unlock!Object



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

def unlock!
  @revision = nil
end