Sha256: 315900780099fef8d54a72b9700537752dee29e13878bf99a0ab96ec2aa7333f

Contents?: true

Size: 791 Bytes

Versions: 5

Compression:

Stored size: 791 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'set'
require 'roo'
require 'ruby-progressbar'
require_relative 'model'

class InsightVMApi
  def fetch_microsoft_product_lifecycle(spreadsheet, tabsheet_name: 'lifecycle_data')
    xlsx = Roo::Excelx.new(spreadsheet)
    sheet = xlsx.sheet(tabsheet_name)
    headers = xlsx.row(7)
    p headers
    models = []
    total_rows = sheet.last_row - 7
    progress_bar = ProgressBar.create(
      title: "Processing #{spreadsheet}",
      total: total_rows,
      format: '%a %B %p%% %t'
    )
    xlsx.each_row_streaming(offset: 7) do |row|
      values = row.map(&:value)
      attributes = Hash[headers.zip(values)]
      models << MicrosoftProductLifecycle.new(attributes)

      progress_bar.increment
    end
    models
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
avs-0.1.3 lib/domain/software/api.rb
avs-0.1.2 lib/domain/software/api.rb
avs-0.1.1 lib/domain/software/api.rb
avs-0.1.0 lib/domain/software/api.rb
avs-0.0.9 lib/domain/software/api.rb