Class Index [+]

Quicksearch

Bundler::Source::Git

Attributes

uri[R]
ref[R]
options[R]
submodules[R]

Public Class Methods

from_lock(options) click to toggle source
     # File lib/bundler/source.rb, line 476
476:       def self.from_lock(options)
477:         new(options.merge("uri" => options.delete("remote")))
478:       end
new(options) click to toggle source
     # File lib/bundler/source.rb, line 463
463:       def initialize(options)
464:         super
465: 
466:         # stringify options that could be set as symbols
467:         %(ref branch tag revision).each{|k| options[k] = options[k].to_s if options[k] }
468: 
469:         @uri        = options["uri"]
470:         @ref        = options["ref"] || options["branch"] || options["tag"] || 'master'
471:         @revision   = options["revision"]
472:         @submodules = options["submodules"]
473:         @update     = false
474:       end

Public Instance Methods

==(o) click to toggle source
Alias for: eql?
eql?(o) click to toggle source
     # File lib/bundler/source.rb, line 491
491:       def eql?(o)
492:         Git === o            &&
493:         uri == o.uri         &&
494:         ref == o.ref         &&
495:         name == o.name       &&
496:         version == o.version &&
497:         submodules == o.submodules
498:       end
Also aliased as: ==
install(spec) click to toggle source
     # File lib/bundler/source.rb, line 538
538:       def install(spec)
539:         Bundler.ui.info "Using #{spec.name} (#{spec.version}) from #{to_s} "
540: 
541:         unless @installed
542:           Bundler.ui.debug "  * Checking out revision: #{ref}"
543:           checkout if allow_git_ops?
544:           @installed = true
545:         end
546:         generate_bin(spec)
547:       end
load_spec_files() click to toggle source
     # File lib/bundler/source.rb, line 549
549:       def load_spec_files
550:         super
551:       rescue PathError, GitError
552:         raise GitError, "#{to_s} is not checked out. Please run `bundle install`"
553:       end
name() click to toggle source
     # File lib/bundler/source.rb, line 507
507:       def name
508:         File.basename(@uri, '.git')
509:       end
path() click to toggle source
     # File lib/bundler/source.rb, line 511
511:       def path
512:         @install_path ||= begin
513:           git_scope = "#{base_name}-#{shortref_for_path(revision)}"
514: 
515:           if Bundler.requires_sudo?
516:             Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope)
517:           else
518:             Bundler.install_path.join(git_scope)
519:           end
520:         end
521:       end
specs() click to toggle source

TODO: actually cache git specs

     # File lib/bundler/source.rb, line 528
528:       def specs
529:         if allow_git_ops? && !@update
530:           # Start by making sure the git cache is up to date
531:           cache
532:           checkout
533:           @update = true
534:         end
535:         local_specs
536:       end
to_lock() click to toggle source
     # File lib/bundler/source.rb, line 480
480:       def to_lock
481:         out = "GIT\n"
482:         out << "  remote: #{@uri}\n"
483:         out << "  revision: #{revision}\n"
484:         %(ref branch tag submodules).each do |opt|
485:           out << "  #{opt}: #{options[opt]}\n" if options[opt]
486:         end
487:         out << "  glob: #{@glob}\n" unless @glob == DEFAULT_GLOB
488:         out << "  specs:\n"
489:       end
to_s() click to toggle source
     # File lib/bundler/source.rb, line 502
502:       def to_s
503:         sref = options["ref"] ? shortref_for_display(options["ref"]) : ref
504:         "#{uri} (at #{sref})"
505:       end
unlock!() click to toggle source
     # File lib/bundler/source.rb, line 523
523:       def unlock!
524:         @revision = nil
525:       end

Private Instance Methods

allow_git_ops?() click to toggle source
     # File lib/bundler/source.rb, line 647
647:       def allow_git_ops?
648:         @allow_remote || @allow_cached
649:       end
base_name() click to toggle source
     # File lib/bundler/source.rb, line 572
572:       def base_name
573:         File.basename(uri.sub(%{^(\w+://)?([^/:]+:)},''), ".git")
574:       end
cache() click to toggle source
     # File lib/bundler/source.rb, line 608
608:       def cache
609:         if cached?
610:           return if has_revision_cached?
611:           Bundler.ui.info "Updating #{uri}"
612:           in_cache do
613:             git %fetch --force --quiet --tags "#{uri}" refs/heads/*:refs/heads/*|
614:           end
615:         else
616:           Bundler.ui.info "Fetching #{uri}"
617:           FileUtils.mkdir_p(cache_path.dirname)
618:           git %clone "#{uri}" "#{cache_path}" --bare --no-hardlinks|
619:         end
620:       end
cache_path() click to toggle source
     # File lib/bundler/source.rb, line 596
596:       def cache_path
597:         @cache_path ||= begin
598:           git_scope = "#{base_name}-#{uri_hash}"
599: 
600:           if Bundler.requires_sudo?
601:             Bundler.user_bundle_path.join("cache/git", git_scope)
602:           else
603:             Bundler.cache.join("git", git_scope)
604:           end
605:         end
606:       end
cached?() click to toggle source
     # File lib/bundler/source.rb, line 661
661:       def cached?
662:         cache_path.exist?
663:       end
checkout() click to toggle source
     # File lib/bundler/source.rb, line 622
622:       def checkout
623:         unless File.exist?(path.join(".git"))
624:           FileUtils.mkdir_p(path.dirname)
625:           FileUtils.rm_rf(path)
626:           git %clone --no-checkout "#{cache_path}" "#{path}"|
627:         end
628:         Dir.chdir(path) do
629:           git %fetch --force --quiet --tags "#{cache_path}"|
630:           git "reset --hard #{revision}"
631: 
632:           if @submodules
633:             git "submodule init"
634:             git "submodule update"
635:           end
636:         end
637:       end
git(command) click to toggle source
     # File lib/bundler/source.rb, line 557
557:       def git(command)
558:         if allow_git_ops?
559:           out = %{git #{command}}
560: 
561:           if $? != 0
562:             raise GitError, "An error has occurred in git when running `git #{command}`. Cannot complete bundling."
563:           end
564:           out
565:         else
566:           raise GitError, "Bundler is trying to run a `git #{command}` at runtime. You probably need to run `bundle install`. However, "                            "this error message could probably be more useful. Please submit a ticket at http://github.com/carlhuda/bundler/issues "                            "with steps to reproduce as well as the following\n\nCALLER: #{caller.join("\n")}"
567:         end
568:       end
has_revision_cached?() click to toggle source
     # File lib/bundler/source.rb, line 639
639:       def has_revision_cached?
640:         return unless @revision
641:         in_cache { git %cat-file -e #{@revision}| }
642:         true
643:       rescue GitError
644:         false
645:       end
in_cache(&blk) click to toggle source
     # File lib/bundler/source.rb, line 665
665:       def in_cache(&blk)
666:         cache unless cached?
667:         Dir.chdir(cache_path, &blk)
668:       end
revision() click to toggle source
     # File lib/bundler/source.rb, line 651
651:       def revision
652:         @revision ||= begin
653:           if allow_git_ops?
654:             in_cache { git("rev-parse #{ref}").strip }
655:           else
656:             raise GitError, "The git source #{uri} is not yet checked out. Please run `bundle install` before trying to start your application"
657:           end
658:         end
659:       end
shortref_for_display(ref) click to toggle source
     # File lib/bundler/source.rb, line 576
576:       def shortref_for_display(ref)
577:         ref[0..6]
578:       end
shortref_for_path(ref) click to toggle source
     # File lib/bundler/source.rb, line 580
580:       def shortref_for_path(ref)
581:         ref[0..11]
582:       end
uri_hash() click to toggle source
     # File lib/bundler/source.rb, line 584
584:       def uri_hash
585:         if uri =~ %{^\w+://(\w+@)?}
586:           # Downcase the domain component of the URI
587:           # and strip off a trailing slash, if one is present
588:           input = URI.parse(uri).normalize.to_s.sub(%{/$},'')
589:         else
590:           # If there is no URI scheme, assume it is an ssh/git URI
591:           input = uri
592:         end
593:         Digest::SHA1.hexdigest(input)
594:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.