class CodeInventory::CLI::App
Public Instance Methods
combine(agency, *filenames)
click to toggle source
# File lib/codeinventory/cli/combine.rb, line 10 def combine(agency, *filenames) if filenames.count == 0 puts "You must provide at least one code.json file" exit 1 end combined = { "version" => "2.0.0", "agency" => agency, "measurementType" => { "method" => "modules" }, "releases" => [] } filenames.each do |filename| if !File.exist? filename puts "File not found: #{filename}" exit 1 end inventory = JSON.load(File.new(filename)) projects = inventory["releases"] if options[:replace] projects.each do |project| project["organization"] = inventory["agency"] if !inventory["agency"].nil? end end combined["releases"].concat(projects) end if options["pretty"] puts JSON.pretty_generate(combined) else puts combined.to_json end end
csv(agency, filename)
click to toggle source
# File lib/codeinventory/cli/csv.rb, line 9 def csv(agency, filename) file = Pathname.new(filename) unless File.exist? file puts "No such file: #{file}" exit 1 end source = CodeInventory::CSVFile.new(file) inventory = CodeInventory::Inventory.new(source) output = inventory.generate(agency, "2.0.0") puts JSON.pretty_generate(output) end
json(agency, filename)
click to toggle source
# File lib/codeinventory/cli/json.rb, line 9 def json(agency, filename) file = Pathname.new(filename) unless File.exist? file puts "No such file: #{file}" exit 1 end source = CodeInventory::JSONFile.new(file) inventory = CodeInventory::Inventory.new(source) output = inventory.generate(agency, "2.0.0") puts JSON.pretty_generate(output) end
version()
click to toggle source
# File lib/codeinventory/cli/app.rb, line 7 def version puts CodeInventory::VERSION end