Created
April 29, 2016 05:54
-
-
Save kei-q/5507d510ae5b68ca315f98844f2f612d to your computer and use it in GitHub Desktop.
jsonをrubyのhashに読み書きしやすい形で出力するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# require: awesome_print, rubocop | |
require 'ap' | |
require 'json' | |
if ARGV.count != 2 | |
puts 'usage: ./script.rb <input_json_file> <output_sour_file_name>' | |
exit 1 | |
end | |
INPUT_JSON_FILE = ARGV[0] | |
OUTPUT_SOURCE_FILE = ARGV[1] | |
contents = File.read(INPUT_JSON_FILE) | |
output = JSON.parse(contents, symbolize_names: true).ai(index: false, plain: true, indent: 2) | |
File.write(OUTPUT_SOURCE_FILE, output) | |
system("rubocop #{OUTPUT_SOURCE_FILE} --auto-correct --format disabled") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment