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 =
<<~CODE class CustomProcessing # The method will be called before conversion allowing to customize the input Kwalify schema. # The implementation have to return the modified schema. # The default implemention don't modify the schema. # @param kwalify_schema {Hash} # @return modified schema def preprocess(kwalify_schema) # TODO return modified schema end # The method will be called after the conversion allowing to customize the output JSON schema. # The implementation have to return the modified schema. # The default implemention don't modify the schema. # @param json_schema {Hash} # @return modified schema def postprocess(json_schema) # TODO return modified schema end end CODE
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))) + ".#{["format"]}" KwalifyToJsonSchema.convert_file(kwalify_schema_file, result_file, opts) } end |