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.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/licensee/projects/git_project.rb', line 29 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.
15 16 17 |
# File 'lib/licensee/projects/git_project.rb', line 15 def revision @revision end |
Class Method Details
.available? ⇒ Boolean
20 21 22 23 24 25 26 27 |
# File 'lib/licensee/projects/git_project.rb', line 20 def self.available? return true if defined?(Rugged) require 'rugged' true rescue LoadError false end |
Instance Method Details
#close ⇒ Object
53 54 55 |
# File 'lib/licensee/projects/git_project.rb', line 53 def close repository.close end |
#repository ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/licensee/projects/git_project.rb', line 43 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 |