Class: Licensee::Projects::GitProject
- Defined in:
- lib/licensee/projects/git_project.rb
Overview
Scans a Git repository (via Rugged) for license-related files.
Defined Under Namespace
Classes: InvalidRepository, RuggedNotAvailable
Constant Summary
Constants inherited from Project
Instance Attribute Summary collapse
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
Attributes inherited from Project
#detect_packages, #detect_readme
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(repo, revision: nil, **args) ⇒ GitProject
constructor
A new instance of GitProject.
- #repository ⇒ Object
Methods inherited from Project
#build_license_files, #license, #license_file, #license_files, #licenses, #matched_file, #matched_files, #package_file, #readme_file
Methods included from HashHelper
Constructor Details
#initialize(repo, revision: nil, **args) ⇒ GitProject
Returns a new instance of GitProject.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/licensee/projects/git_project.rb', line 30 def initialize(repo, revision: nil, **args) unless self.class.available? raise RuggedNotAvailable, 'Install the rugged gem to enable Git repository scanning' end @raw_repo = repo @revision = revision raise InvalidRepository if repository.head_unborn? super(**args) end |
Instance Attribute Details
#revision ⇒ Object (readonly)
Returns the value of attribute revision.
21 22 23 |
# File 'lib/licensee/projects/git_project.rb', line 21 def revision @revision end |
Class Method Details
.available? ⇒ Boolean
26 27 28 |
# File 'lib/licensee/projects/git_project.rb', line 26 def self.available? !!defined?(Rugged) end |
Instance Method Details
#close ⇒ Object
54 55 56 |
# File 'lib/licensee/projects/git_project.rb', line 54 def close repository.close end |
#repository ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/licensee/projects/git_project.rb', line 44 def repository @repository ||= if @raw_repo.is_a? Rugged::Repository @raw_repo else Rugged::Repository.new(@raw_repo) end rescue Rugged::OSError, Rugged::RepositoryError raise InvalidRepository end |