From 3d2390e48be9d1ea1b48ff8c481157dbf5bdce31 Mon Sep 17 00:00:00 2001 From: hahwul Date: Mon, 15 Aug 2022 23:18:05 +0900 Subject: [PATCH] Update migrate script --- scripts/migration.rb | 51 +++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/scripts/migration.rb b/scripts/migration.rb index 5dd7dc6..63ef307 100644 --- a/scripts/migration.rb +++ b/scripts/migration.rb @@ -20,28 +20,35 @@ def get_urls str return URI.extract(str).uniq end -file = File.read('./data.json') -data_hash = JSON.parse(file) +def migrate jsonfile + file = File.read(jsonfile) + data_hash = JSON.parse(file) -data_hash.each do | name, obj | - filename = name.gsub(' ','_')+".yaml" - # Make object - new_obj = {} - new_obj['name'] = name - new_obj['description'] = obj['Description'] - new_obj['urls'] = get_urls obj['Data'] - new_obj['category'] = 'tool' - new_obj['types'] = [] - if obj['Install'] != nil - new_obj['os'] = get_os(obj['Install']) + data_hash.each do | name, obj | + filename = name.gsub(' ','_')+".yaml" + # Make object + new_obj = {} + new_obj['name'] = name + new_obj['description'] = obj['Description'] + new_obj['urls'] = get_urls obj['Data'] + new_obj['category'] = 'tool' + new_obj['types'] = [] + if obj['Install'] != nil + new_obj['os'] = get_os(obj['Install']) + end + new_obj['lang'] = [] # parse DATA + new_obj['tags'] = [] + + # Convert to YAML + yaml_data = YAML.dump(new_obj) + + # Save yaml file + puts filename + #File.write("./data/#{filename}", yaml_data) end - new_obj['lang'] = [] # parse DATA - new_obj['tags'] = [] +end - # Convert to YAML - yaml_data = YAML.dump(new_obj) - - # Save yaml file - puts filename - #File.write("./data/#{filename}", yaml_data) -end \ No newline at end of file +migrate './data.json' +migrate './Bookmarklets/data.json' +migrate './Browser Extensions/data.json' +migrate './Burp and ZAP Extensions/data.json' \ No newline at end of file