Class: CocoapodsNexus::API
- Inherits:
-
Object
- Object
- CocoapodsNexus::API
- Defined in:
- lib/cocoapods-nexus/api.rb,
lib/cocoapods-nexus/api/components.rb,
lib/cocoapods-nexus/api/connection.rb
Overview
Defined Under Namespace
Classes: NexusConnection
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#repo ⇒ Object
Returns the value of attribute repo.
Instance Method Summary collapse
-
#initialize(hostname:, repo:) ⇒ API
constructor
用于管理nexus服务器.
-
#search_maven_component(artifact_id:) ⇒ Object
搜索组件.
-
#upload_maven_component(artifact_id:, version:, group_id:, podspec:, artifact:, files:) ⇒ Object
上传组件.
Constructor Details
#initialize(hostname:, repo:) ⇒ API
用于管理nexus服务器
11 12 13 14 |
# File 'lib/cocoapods-nexus/api.rb', line 11 def initialize(hostname:, repo:) @connection = CocoapodsNexus::API::NexusConnection.new(hostname: hostname) @repo = repo end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
7 8 9 |
# File 'lib/cocoapods-nexus/api.rb', line 7 def connection @connection end |
#repo ⇒ Object
Returns the value of attribute repo.
8 9 10 |
# File 'lib/cocoapods-nexus/api.rb', line 8 def repo @repo end |
Instance Method Details
#search_maven_component(artifact_id:) ⇒ Object
搜索组件
4 5 6 |
# File 'lib/cocoapods-nexus/api/components.rb', line 4 def search_maven_component(artifact_id:) @connection.get_response(endpoint: "search?repository=#{@repo}&name=#{artifact_id}") end |
#upload_maven_component(artifact_id:, version:, group_id:, podspec:, artifact:, files:) ⇒ Object
上传组件
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cocoapods-nexus/api/components.rb', line 9 def upload_maven_component(artifact_id:, version:, group_id:, podspec:, artifact:, files:) parameters = { 'maven2.artifactId' => artifact_id, 'maven2.version' => version, 'maven2.groupId' => group_id, 'maven2.generate-pom' => true, 'maven2.packaging' => artifact.nil? ? 'podspec' : File.extname(artifact).delete(".") } upload_files = [] upload_files << podspec unless podspec.nil? upload_files << artifact unless artifact.nil? upload_files | files unless files.nil? upload_files.each_index do |index| parameters["maven2.asset#{index + 1}"] = File.open(upload_files[index], 'r:utf-8') parameters["maven2.asset#{index + 1}.extension"] = File.extname(upload_files[index]).delete(".") end @connection.post(endpoint: "components?repository=#{@repo}", parameters: parameters, headers: {}) end |