Class: OrmDev::HTTPUtil
- Inherits:
-
Object
- Object
- OrmDev::HTTPUtil
- Defined in:
- lib/ormdev/source/util/http_util.rb
Constant Summary collapse
- API_THIRD_PLUGIN_CHECK =
测试地址
'http://112.65.142.83:7799/soops/sword/portal/checkPluginBaseInfo'.freeze
- API_THIRD_PLUGIN_PUBLISH =
测试地址
'http://112.65.142.83:7799/soops/sword/portal?SwordControllerName=uploadPlugin'.freeze
Class Method Summary collapse
- .send_check_plugin_http(username, password, publish_type, podspec_path, zip_path, changelog = '') ⇒ Object
- .send_pulish_plugin_http(username, password, publish_type, podspec_path, zip_path, changelog = '') ⇒ Object
Class Method Details
.send_check_plugin_http(username, password, publish_type, podspec_path, zip_path, changelog = '') ⇒ Object
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 60 61 |
# File 'lib/ormdev/source/util/http_util.rb', line 10 def self.send_check_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 'pluginName' => @spec.name.gsub(/^CIP/, 'cip'), 'pluginVersion' => @spec.version.to_s, 'pluginBaseVersion' => cim_sdk_version, #base版本号 } 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 '【发布第三方插件】开始上传 ...' 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 |
.send_pulish_plugin_http(username, password, publish_type, podspec_path, zip_path, changelog = '') ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/ormdev/source/util/http_util.rb', line 63 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 '【发布第三方插件】开始上传 ...' 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 |