Class: KwalifyToJsonSchema::Cli
- Inherits:
-
Thor
- Object
- Thor
- KwalifyToJsonSchema::Cli
- Defined in:
- lib/kwalify_to_json_schema/cli.rb
Constant Summary collapse
- CUSTOM_PROCESSING_CODE_DOC =
"class CustomProcessing\n # The method will be called before conversion allowing to customize the input Kwalify schema.\n # The implementation have to return the modified schema.\n # The default implemention don't modify the schema.\n # @param kwalify_schema {Hash}\n # @return modified schema\n def preprocess(kwalify_schema)\n # TODO return modified schema\n end\n \n # The method will be called after the conversion allowing to customize the output JSON schema.\n # The implementation have to return the modified schema.\n # The default implemention don't modify the schema.\n # @param json_schema {Hash}\n # @return modified schema\n def postprocess(json_schema)\n # TODO return modified schema\n end\nend\n"
Class Method Summary collapse
Instance Method Summary collapse
- #convert(kwalify_schema_file, result_file) ⇒ Object
- #convert_dir(kwalify_schema_dir, result_dir) ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
85 86 87 |
# File 'lib/kwalify_to_json_schema/cli.rb', line 85 def self.exit_on_failure? false end |
Instance Method Details
#convert(kwalify_schema_file, result_file) ⇒ Object
43 44 45 46 47 |
# File 'lib/kwalify_to_json_schema/cli.rb', line 43 def convert(kwalify_schema_file, result_file) opts = .dup opts[Options::CUSTOM_PROCESSING] = custom_processing() KwalifyToJsonSchema.convert_file(kwalify_schema_file, result_file, opts) end |
#convert_dir(kwalify_schema_dir, result_dir) ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/kwalify_to_json_schema/cli.rb', line 74 def convert_dir(kwalify_schema_dir, result_dir) opts = .dup opts[Options::CUSTOM_PROCESSING] = custom_processing() path = [kwalify_schema_dir, ["recursive"] ? "**" : nil, "*.{yaml,yml}"].compact Dir.glob(File.join(*path)).each { |kwalify_schema_file| result_file = File.join(result_dir, File.basename(kwalify_schema_file, File.extname(kwalify_schema_file))) + ".#{options["format"]}" KwalifyToJsonSchema.convert_file(kwalify_schema_file, result_file, opts) } end |