class Fictium::Postman::V2Exporter
Public Instance Methods
export(document)
click to toggle source
# File lib/fictium/exporters/postman/v2_exporter.rb, line 17 def export(document) result = format_document(document) validate!(result) FileUtils.mkdir_p(File.dirname(export_file)) File.write(export_file, pretty_print? ? JSON.pretty_generate(result) : result.to_json) end
Private Instance Methods
export_file()
click to toggle source
# File lib/fictium/exporters/postman/v2_exporter.rb, line 26 def export_file @export_file ||= File.join(Fictium.configuration.export_path, 'postman', '2.1.0', 'collection.json') end
format_document(document)
click to toggle source
# File lib/fictium/exporters/postman/v2_exporter.rb, line 43 def format_document(document) data = { info: info_formatter.format(document), item: item_formatter.format(document) } metadata_formatter.format(document, data) end
info_formatter()
click to toggle source
# File lib/fictium/exporters/postman/v2_exporter.rb, line 52 def info_formatter @info_formatter ||= InfoFormatter.new end
item_formatter()
click to toggle source
# File lib/fictium/exporters/postman/v2_exporter.rb, line 56 def item_formatter @item_formatter ||= ItemFormatter.new end
metadata_formatter()
click to toggle source
# File lib/fictium/exporters/postman/v2_exporter.rb, line 48 def metadata_formatter @metadata_formatter ||= MetadataFormatter.new end
pretty_print?()
click to toggle source
# File lib/fictium/exporters/postman/v2_exporter.rb, line 39 def pretty_print? Fictium.configuration.pretty_print end
schema()
click to toggle source
# File lib/fictium/exporters/postman/v2_exporter.rb, line 35 def schema @schema ||= JSON.parse(File.read(File.join(__dir__, 'schemas', '2.1.0.json'))) end
validate!(result)
click to toggle source
# File lib/fictium/exporters/postman/v2_exporter.rb, line 31 def validate!(result) JSON::Validator.validate!(schema, result) end