Class: Licensee::Projects::GitProject

Inherits:
Project
  • Object
show all
Defined in:
lib/licensee/projects/git_project.rb

Defined Under Namespace

Classes: InvalidRepository

Constant Summary

Constants inherited from Project

Project::HASH_METHODS

Instance Attribute Summary collapse

Attributes inherited from Project

#detect_packages, #detect_readme

Instance Method Summary collapse

Methods inherited from Project

#license, #license_file, #license_files, #licenses, #matched_file, #matched_files, #package_file, #readme_file

Methods included from HashHelper

#to_h

Constructor Details

#initialize(repo, revision: nil, **args) ⇒ GitProject

Returns a new instance of GitProject.

Raises:



20
21
22
23
24
25
26
27
# File 'lib/licensee/projects/git_project.rb', line 20

def initialize(repo, revision: nil, **args)
  @raw_repo = repo
  @revision = revision

  raise InvalidRepository if repository.head_unborn?

  super(**args)
end

Instance Attribute Details

#revisionObject (readonly)

Returns the value of attribute revision.



16
17
18
# File 'lib/licensee/projects/git_project.rb', line 16

def revision
  @revision
end

Instance Method Details

#closeObject



39
40
41
# File 'lib/licensee/projects/git_project.rb', line 39

def close
  repository.close
end

#repositoryObject



29
30
31
32
33
34
35
36
37
# File 'lib/licensee/projects/git_project.rb', line 29

def repository
  @repository ||= begin
    return @raw_repo if @raw_repo.is_a? Rugged::Repository

    Rugged::Repository.new(@raw_repo)
  end
rescue Rugged::OSError, Rugged::RepositoryError
  raise InvalidRepository
end