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.



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

def initialize(repo, revision: nil, **args)
  @repository = if repo.is_a? Rugged::Repository
    repo
  else
    Rugged::Repository.new(repo)
  end

  @revision = revision
  super(**args)
rescue Rugged::OSError, Rugged::RepositoryError
  raise InvalidRepository
end

Instance Attribute Details

#repositoryObject (readonly)

Returns the value of attribute repository.



14
15
16
# File 'lib/licensee/projects/git_project.rb', line 14

def repository
  @repository
end

#revisionObject (readonly)

Returns the value of attribute revision.



14
15
16
# File 'lib/licensee/projects/git_project.rb', line 14

def revision
  @revision
end

Instance Method Details

#closeObject



31
32
33
# File 'lib/licensee/projects/git_project.rb', line 31

def close
  @repository.close
end