Class: Licensee::Project
- Inherits:
-
Object
- Object
- Licensee::Project
- Defined in:
- lib/licensee/project.rb
Instance Attribute Summary collapse
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Class Method Summary collapse
-
.match_license_file(filename) ⇒ Object
Scores a given file as a potential license.
Instance Method Summary collapse
-
#initialize(path_or_repo, revision = nil) ⇒ Project
constructor
Initializes a new project.
-
#license ⇒ Object
Returns the matching Licensee::License instance if a license can be detected.
-
#license_file ⇒ Object
Returns an instance of Licensee::LicenseFile if there’s a license file detected.
Constructor Details
#initialize(path_or_repo, revision = nil) ⇒ Project
Initializes a new project
path_or_repo path to git repo or Rugged::Repository instance revsion - revision ref, if any
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/licensee/project.rb', line 9 def initialize(path_or_repo, revision = nil) if path_or_repo.kind_of? Rugged::Repository @repository = path_or_repo else begin @repository = Rugged::Repository.new(path_or_repo) rescue Rugged::RepositoryError if revision raise else @repository = FilesystemRepository.new(path_or_repo) end end end @revision = revision end |
Instance Attribute Details
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
3 4 5 |
# File 'lib/licensee/project.rb', line 3 def repository @repository end |
Class Method Details
.match_license_file(filename) ⇒ Object
Scores a given file as a potential license
filename - (string) the name of the file to score
Returns 1 if the file is definately a license file Return 0.5 if the file is likely a license file Returns 0 if the file is definately not a license file
44 45 46 47 48 |
# File 'lib/licensee/project.rb', line 44 def self.match_license_file(filename) return 1 if self.license_file?(filename) return 0.5 if self.maybe_license_file?(filename) return 0 end |
Instance Method Details
#license ⇒ Object
Returns the matching Licensee::License instance if a license can be detected
33 34 35 |
# File 'lib/licensee/project.rb', line 33 def license @license ||= license_file.match if license_file end |
#license_file ⇒ Object
Returns an instance of Licensee::LicenseFile if there’s a license file detected
28 29 30 |
# File 'lib/licensee/project.rb', line 28 def license_file @license_file ||= LicenseFile.new(license_blob, :path => license_path) if license_blob end |