Class: GitBundle::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/git_bundle/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProject

Returns a new instance of Project.



5
6
7
8
9
# File 'lib/git_bundle/project.rb', line 5

def initialize
  # TODO: Find out how to set Bundler's directory so that the directory can be an argument
  @directory = Dir.getwd
  @main_repository = GitBundle::Repository.new_main(File.basename(@directory), @directory)
end

Instance Attribute Details

#dependant_repositoriesObject (readonly)

Returns the value of attribute dependant_repositories.



3
4
5
# File 'lib/git_bundle/project.rb', line 3

def dependant_repositories
  @dependant_repositories
end

#main_repositoryObject (readonly)

Returns the value of attribute main_repository.



3
4
5
# File 'lib/git_bundle/project.rb', line 3

def main_repository
  @main_repository
end

Instance Method Details

#load_dependant_repositories(locked_branches: true) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/git_bundle/project.rb', line 11

def load_dependant_repositories(locked_branches: true)
  @dependant_repositories = []

  if Bundler.locked_gems
    if locked_branches
      specs = Bundler.locked_gems.specs
    else
      old_value = Bundler.settings[:disable_local_branch_check]
      Bundler.settings[:disable_local_branch_check] = true
      specs = Bundler.definition.specs
      Bundler.settings[:disable_local_branch_check] = old_value
    end

    Bundler.settings.local_overrides.each do |name, path|
      spec = specs.find { |s| s.name == name }
      if spec && spec.source.respond_to?(:branch)
        @dependant_repositories << GitBundle::Repository.new_dependant(spec.name, path, spec.source.branch, spec.source.revision)
      end
    end
  end
end

#repositoriesObject



33
34
35
# File 'lib/git_bundle/project.rb', line 33

def repositories
  @dependant_repositories + [@main_repository]
end