require 'json' require 'rake/testtask' require 'rubygems' require 'gems' require 'fileutils' Rake::TestTask.new do |t| t.pattern = "spec/*.rb" end lib_dir = 'lib' gen_dir = 'gen' task :clean do rm_rf gen_dir rm_rf lib_dir end GEM_VERSION = ENV['SDK_VERSION'] ||= "0.0.0" task :buildgem do Dir.mkdir(gen_dir) unless File.exists?(gen_dir) `gem build purecloud.gemspec` FileUtils.mv "purecloud-#{GEM_VERSION}.gem", "#{gen_dir}" end task :generate do codegenConfig = { "gemVersion" => GEM_VERSION, "gemName" => "purecloud", "moduleName" => "PureCloud", "gemLicense" => "MIT", "gemSummary" => "PureCloud Platform API Library", "gemDescription" => "A Ruby library to interface with the PureCloud Platform API", "gemHomepage" => "https://developer.mypurecloud.com", "gemAuthor" => "Kevin Glinski", "gemAuthorEmail" => "Kevin.Glinski@inin.com", "httpUserAgent" => "PureCloud SDK/Ruby #{GEM_VERSION}", "gitUserId" => "mypurecloud", "gitRepoId" => "purecloud_api_sdk_ruby" } File.open("config-ruby.json", 'w') { |file| file.write(codegenConfig.to_json) } rm_rf 'docs' `java -jar external/swagger-codegen-cli.jar generate -i ./swagger.json -l ruby -c config-ruby.json -t swagger_template` `cat lib/purecloud.rb extensions/auth.rb > lib/purecloud.tmp` `mv lib/purecloud.tmp lib/purecloud.rb` Dir.glob('docs/*.md') do |filepath| File.rename(filepath, filepath.gsub(/md$/, "html.md")) end Dir.glob('README.md') do |filepath| FileUtils.cp(filepath, filepath.gsub(/README/, "docs/index.html")) end FileUtils.mv 'docs', 'doc_out' rm_rf 'spec/api' rm_rf 'spec/models' end task :release do version = ENV['SDK_VERSION'] puts "releasing #{version}" Gems.configure do |config| config.key = ENV['GEM_KEY'] end puts Gems.push File.new "gen/purecloud-#{version}.gem" end task :default => [:clean, :generate, :buildgem]# :test,