Class: Licensee::Project
- Inherits:
-
Object
show all
- Defined in:
- lib/licensee/project.rb,
lib/licensee/project_file.rb
Defined Under Namespace
Classes: File, LicenseFile, PackageInfo
Instance Method Summary
collapse
Constructor Details
#initialize(detect_packages) ⇒ Project
6
7
8
|
# File 'lib/licensee/project.rb', line 6
def initialize(detect_packages)
@detect_packages = detect_packages
end
|
Instance Method Details
#detect_packages? ⇒ Boolean
10
11
12
|
# File 'lib/licensee/project.rb', line 10
def detect_packages?
@detect_packages
end
|
#license ⇒ Object
Returns the matching Licensee::License instance if a license can be detected
15
16
17
|
# File 'lib/licensee/project.rb', line 15
def license
@license ||= matched_file && matched_file.license
end
|
#license_file ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'lib/licensee/project.rb', line 23
def license_file
return @license_file if defined? @license_file
@license_file = begin
content, name = find_file { |name| LicenseFile.name_score(name) }
if content && name
LicenseFile.new(content, name)
end
end
end
|
#matched_file ⇒ Object
19
20
21
|
# File 'lib/licensee/project.rb', line 19
def matched_file
@matched_file ||= (license_file || package_file)
end
|
#package_file ⇒ Object
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/licensee/project.rb', line 33
def package_file
return unless detect_packages?
return @package_file if defined? @package_file
@package_file = begin
content, name = find_file { |name| PackageInfo.name_score(name) }
if content && name
PackageInfo.new(content, name)
end
end
end
|