Class: Lita::Handlers::Nexus
Instance Method Summary
collapse
#delete_artifact, #get_artifact_info, #get_current_repo, #get_license_info, #get_repository_info, #nexus_remote, #push_artifact, #search_for_artifact, #search_with_lucene
Instance Method Details
#cmd_artifact_info(response) ⇒ Object
99
100
101
102
103
|
# File 'lib/lita/handlers/nexus.rb', line 99
def cmd_artifact_info(response)
coordinate = response.matches[0][0]
info = get_artifact_info(coordinate)
response.reply info
end
|
#cmd_delete_artifact(response) ⇒ Object
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/lita/handlers/nexus.rb', line 163
def cmd_delete_artifact(response)
coordinate = response.matches[0][0]
begin
delete_artifact(coordinate)
response.reply t('msg.info_artifact_deleted')
rescue Exception => e
response.reply e.message
end
end
|
#cmd_get_artifact_versions(response) ⇒ Object
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
# File 'lib/lita/handlers/nexus.rb', line 193
def cmd_get_artifact_versions(response)
coordinate = response.matches[0][0]
begin
info = search_for_artifact(coordinate)
dom = Nokogiri::XML(info)do |config|
config.strict.nonet
end
data = dom.xpath('//artifact/version')
versions =[]
data.each do |version|
versions << version.text
end
versions.sort! {|x,y|
Versionomy.parse(x) <=> Versionomy.parse(y)
}
response.reply versions.to_s
rescue Exception =>e
response.reply e.message
end
end
|
#cmd_license_info(response) ⇒ Object
152
153
154
155
|
# File 'lib/lita/handlers/nexus.rb', line 152
def cmd_license_info(response)
info = get_license_info
response.reply info
end
|
#cmd_push_artifact(coordinate, file_path) ⇒ Object
189
190
191
|
# File 'lib/lita/handlers/nexus.rb', line 189
def cmd_push_artifact(coordinate, file_path)
push_artifact(coordinate, file_path)
end
|
#cmd_repo_info(response) ⇒ Object
157
158
159
160
161
|
# File 'lib/lita/handlers/nexus.rb', line 157
def cmd_repo_info(response)
repo_name = response.matches[0][0]
info = get_repository_info repo_name
response.reply info
end
|
#cmd_search_artifact(response) ⇒ Object
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/lita/handlers/nexus.rb', line 105
def cmd_search_artifact(response)
coordinate = response.matches[0][0]
limit = response.matches[0][1]
return_limit = nil
if !limit.nil? && ! limit.empty?
return_limit = Integer(limit)
end
begin
info = search_for_artifact(coordinate)
dom = Nokogiri::XML(info)do |config|
config.strict.nonet
end
total_count = dom.xpath('//totalCount').text
data = dom.xpath('//artifact')
all_versions = {}
data.each do |artifact|
version_str= artifact.xpath('version').text
artifact_output = StringIO.open do |s|
s.puts "[Coordinate] #{artifact.xpath('groupId').text}:#{artifact.xpath('artifactId').text}:#{artifact.xpath('version').text}:#{artifact.xpath('packaging').text}"
s.puts "[Download URL] #{artifact.xpath('resourceURI').text}"
s.puts "[Repository] #{artifact.xpath('repoId').text}(#{artifact.xpath('contextId').text})"
s.string
end
all_versions[version_str]= artifact_output
end
response.reply "Artifact found: #{all_versions.size}, showing max #{return_limit||config.search_limit} of latest version"
out_artifacts = []
unless all_versions.empty?
all_versions.sort_by {|k,v|
Versionomy.parse(k)
}
tmp_artifacts = all_versions.values.reverse
out_artifacts = tmp_artifacts.first(return_limit||config.search_limit)
end
index = 0
out_artifacts.each do |artifact|
index = index +1
response.reply "Artifact #{index}:"
response.reply artifact
end
rescue Exception =>e
response.reply e.message
end
end
|
#cmd_set_current_repository(response) ⇒ Object
174
175
176
177
178
179
180
181
|
# File 'lib/lita/handlers/nexus.rb', line 174
def cmd_set_current_repository(response)
repo = response.matches[0][0]
if repo && repo.strip.length >0
config.current_repository = repo
end
response.reply t('msg.info_repos_set_success', repo: repo)
end
|
#cmd_show_current_repository(response) ⇒ Object
183
184
185
186
187
|
# File 'lib/lita/handlers/nexus.rb', line 183
def cmd_show_current_repository(response)
current_repo = get_current_repo
response.reply t('msg.info_current_repo_is', repo: current_repo)
end
|