42 lines
896 B
Ruby
42 lines
896 B
Ruby
|
#!/usr/bin/env ruby
|
||
|
|
||
|
require '../app_build_number_cpe_mapper/exchange.rb'
|
||
|
require 'optparse'
|
||
|
require 'json'
|
||
|
|
||
|
def pretty_json(data_hash)
|
||
|
json = JSON.parse(data_hash.to_json)
|
||
|
JSON.pretty_generate(json)
|
||
|
end
|
||
|
|
||
|
def export_to_json(data, filename)
|
||
|
File.write(filename, data)
|
||
|
end
|
||
|
|
||
|
def do_export(data_hash)
|
||
|
filename = './data/microsoft_exchange_release_info.json'
|
||
|
json = pretty_json(data_hash)
|
||
|
export_to_json(json, filename)
|
||
|
puts "----" * 12
|
||
|
puts "Succesfully Exported to #{filename}:"
|
||
|
puts "----" * 12
|
||
|
puts json
|
||
|
puts "----" * 12
|
||
|
end
|
||
|
|
||
|
@options = {}
|
||
|
|
||
|
OptionParser.new do |opts|
|
||
|
opts.on("-e", "--export", "Export Microsoft Exchange Server release data to json file in ./data") do |export|
|
||
|
@options[:export] = export
|
||
|
end
|
||
|
end.parse!
|
||
|
|
||
|
scraper = MicrosoftExchangeReleaseInfo.new
|
||
|
RestClient.log = 'stdout'
|
||
|
|
||
|
if @options[:export]
|
||
|
data_hash = scraper.main
|
||
|
do_export(data_hash)
|
||
|
end
|