Class: Vulcano::Main
- Inherits:
-
Object
- Object
- Vulcano::Main
- Defined in:
- lib/vulcano.rb
Instance Method Summary collapse
Instance Method Details
#parse_options ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vulcano.rb', line 21 def = {} OptionParser.new do |opts| opts. = "Usage: vulcano json_path [options]" opts.on("-d", "--destination-folder DESTINATION_FOLDER", String, "Destination folder for the generated source") do |destination_folder| [:destination_folder] = destination_folder end opts.on("-n", "--class-name CLASS_NAME", String, "Name for the generated class (the default name is 'Generated')") do |class_name| [:class_name] = class_name end end.parse! return end |
#start ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/vulcano.rb', line 10 def start raise RuntimeError, 'The script has to be called with a JSON path' unless ARGV.length > 0 = () json_path = ARGV[0] destination_folder = [:destination_folder].nil? ? "." : [:destination_folder] json = JsonReader.new.read_from_file(json_path) CodableGenerator.new.generate_codable_file(json, destination_folder, [:class_name]) end |