diff --git a/tools/microsoft/app_build_number_cpe_mapper/exchange.rb b/tools/microsoft/app_build_number_cpe_mapper/exchange.rb index b49adb4..778da88 100644 --- a/tools/microsoft/app_build_number_cpe_mapper/exchange.rb +++ b/tools/microsoft/app_build_number_cpe_mapper/exchange.rb @@ -27,6 +27,7 @@ class MicrosoftExchangeReleaseInfo end end + def parse_html(html) Nokogiri::HTML(html) end diff --git a/tools/microsoft/bin/get_microsoft_exchange_release_builds.rb b/tools/microsoft/bin/get_microsoft_exchange_release_builds.rb new file mode 100755 index 0000000..70d9227 --- /dev/null +++ b/tools/microsoft/bin/get_microsoft_exchange_release_builds.rb @@ -0,0 +1,41 @@ +#!/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