Class: OrmDev::HTTPUtil
- Inherits:
-
Object
- Object
- OrmDev::HTTPUtil
- Defined in:
- lib/ormdev/source/util/http_util.rb
Constant Summary collapse
- API_THIRD_PLUGIN_PUBLISH =
测试地址
'http://192.168.2.110:8081/soops/sword/portal?SwordControllerName=uploadPlugin'.freeze
Class Method Summary collapse
Class Method Details
.send_pulish_plugin_http(username, password, publish_type, podspec_path, zip_path, changelog = '') ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ormdev/source/util/http_util.rb', line 9 def self.send_pulish_plugin_http(username, password, publish_type, podspec_path, zip_path, changelog = '') @spec = Pod::Specification.from_file(podspec_path) cim_sdk_version = '' @spec.dependencies.each do |dep| if 'CIMSDK'.eql? dep.name cim_sdk_version = plugin_version_from(dep.requirement.requirements.flatten.last.to_s) end end # start upload = { request: { timeout: 1000, open_timeout: 300 } } pgyer_client = Faraday.new(nil, ) do |c| c.request :multipart c.request :url_encoded c.response :json, content_type: /\bjson$/ c.adapter :net_http end params = { 'username' => username || ENV['ORMDEV_CLT_USERNAME'], 'password' => password || ENV['ORMDEV_CLT_PASSWORD'], 'version' => OrmDev::VERSION, 'platform' => 1,# 0:android,1:ios 'type' => 1,# ios:0,1,2 'cipBaseVersion' => cim_sdk_version, #base版本号 'desc' => changelog, } unless podspec_path.nil? then params[File.basename(podspec_path)] = Faraday::UploadIO.new(podspec_path, 'application/octet-stream') if File.exist?(podspec_path) end unless zip_path.nil? then params[File.basename(zip_path)] = Faraday::UploadIO.new(zip_path, 'application/octet-stream') if File.exist?(zip_path) end OrmDev::LogUtil.info '【发布第三方插件】Start upload ...' api = ENV['ORMDEV_CLT_API_THIRD_PLUGIN_PUBLISH'] || API_THIRD_PLUGIN_PUBLISH response = pgyer_client.post api, params info = response.body OrmDev::LogUtil.info "【第三方插件发布】#{api}" OrmDev::LogUtil.info "【第三方插件发布】Upload complate: #{info}" if info && info['status'] && info['status'] == '0000' then OrmDev::LogUtil.info '发布成功' end info end |