Class: CodeInventory::Inventory

Inherits:
Object
  • Object
show all
Defined in:
lib/codeinventory/inventory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*sources) ⇒ Inventory

Returns a new instance of Inventory.



5
6
7
# File 'lib/codeinventory/inventory.rb', line 5

def initialize(*sources)
  @sources = [sources].flatten
end

Instance Attribute Details

#sourcesObject

Returns the value of attribute sources.



3
4
5
# File 'lib/codeinventory/inventory.rb', line 3

def sources
  @sources
end

Instance Method Details

#generate(agency, version) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/codeinventory/inventory.rb', line 18

def generate(agency, version)
  {
    "agency": agency,
    "version": version,
    "measurementType" => {
      "method" => "modules"
    },
    "releases": projects
  }
end

#projectsObject



9
10
11
12
13
14
15
16
# File 'lib/codeinventory/inventory.rb', line 9

def projects
  @sources.collect { |src|
    src.projects do |project|
      yield project, src if block_given?
      project
    end
  }.flatten
end