Sha256: 51826b29214ca15d112b66793927dc17c7a511873916c763326f7815c4ebce1f
Contents?: true
Size: 1019 Bytes
Versions: 1
Compression:
Stored size: 1019 Bytes
Contents
require 'tempfile' require 'fileutils' require 'open3' class Zup class Swagger def installed? begin `swagger-codegen` return true rescue return false end end def languages languages = `swagger-codegen` languages.gsub!("Available languages: ", "").tr!("[] ", "").split(',') end def generate(content_yml, lang, output) path = create_temp_file(content_yml) makedir(output) begin `swagger-codegen generate -i #{path} -l #{lang} -o #{output} &> /dev/null` return true rescue return false end remove_temp_file end private def create_temp_file(content_yml) @file = Tempfile.new(['swagger', '.yaml']) @file.write(JSON.parse(content_yml.to_json).to_yaml) @file.rewind @file.close @file.path end def remove_temp_file @file.unlink end def makedir(output) FileUtils.mkdir(output) if !Dir.exist?(output) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zup-generator-0.1.1 | lib/zup/swagger.rb |