Class: Gemterms::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/gemterms/project.rb

Overview

A collection of components to be evaluated as a set.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProject

Returns a new instance of Project.



50
51
52
# File 'lib/gemterms/project.rb', line 50

def initialize
  @components = []
end

Instance Attribute Details

#componentsObject (readonly)

Returns the value of attribute components.



29
30
31
# File 'lib/gemterms/project.rb', line 29

def components
  @components
end

Instance Method Details

#<<(component) ⇒ Object



31
32
33
# File 'lib/gemterms/project.rb', line 31

def <<(component)
  @components << component
end

#components_for_license(license) ⇒ Object



46
47
48
# File 'lib/gemterms/project.rb', line 46

def components_for_license(license)
  @components.select { |c| c.licenses.include?(license) }
end

#countint

Returns number of components in the project.

Returns:

  • number of components in the project



36
37
38
# File 'lib/gemterms/project.rb', line 36

def count
  @components.length
end

#count_unlicensedint

licenses

Returns:

  • count of components in this projects that have “Unknown”



42
43
44
# File 'lib/gemterms/project.rb', line 42

def count_unlicensed
  @components.count { |c| c.licensed? }
end

#licenses(include_unknown = true) ⇒ Object



54
55
56
57
58
# File 'lib/gemterms/project.rb', line 54

def licenses(include_unknown = true)
  result = @components.map { |c| c.licenses }.flatten
  result.reject! { |l| l.unknown? } unless include_unknown
  result
end

#unique_licenses(include_unknown = true) ⇒ Array<License>

included in the returned list. Defaults to true.

project.

Parameters:

  • (defaults to: true)

    If true, unknown licenses are

Returns:

  • array of unique licenses in use by this



65
66
67
# File 'lib/gemterms/project.rb', line 65

def unique_licenses(include_unknown = true)
  self.licenses.uniq
end