stash-api 1.1.33.0 → 1.1.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/stash-api/explorer.rb +44 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzkzOGYyNjM1NDlkYTM3YzgyOThlMDViMzExZjkzMmQ0NWU1MTlmNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjdlZDgzOWNlMDRkOWY3Njk1MThkMTBlMDc2MzEwOTM2MWNlN2M0NQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWYxMTJlMWExZjRjZjE3YTllYWUwZmY5YWVkOTlkMTA2ZTJlNjVkMDhkMTcz
|
10
|
+
MjFiOGE2OGVhNWYxYzViYzA2NmRlMjYyNWZkOWU2ZjA1ZGE1MDY0YTAzZmZm
|
11
|
+
ZjVhNzY4YzdiNTY2Zjg4MDczYWRkZjgyOTNhNmU3MDdkNzhhOWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjJkMWJkNDljYWYwOTc5ZDNiYWZkNDJjODRiYTc3MmNjMTdhMTJlYTFiMTg2
|
14
|
+
Zjk0OTQ0MjhjYWVhYmVjZmNmZTY5ZmQ3Yzc1Y2EyZDcwNzU5Y2ZkYTJkYjJl
|
15
|
+
MTU0YjNjOTAxMmVlNjZhMDg5ZGFlYjRmMGFjNzQ2ZGNhNTUzYTc=
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
module Stash
|
5
|
+
class Explorer
|
6
|
+
attr_accessor :server
|
7
|
+
|
8
|
+
def initialize(username, password, server)
|
9
|
+
raise 'API username must be specified' if !username
|
10
|
+
raise 'API password must be specified' if !password
|
11
|
+
raise 'Stash server must be specified' if !server
|
12
|
+
@username = username
|
13
|
+
@password = password
|
14
|
+
@server = server
|
15
|
+
|
16
|
+
@get_repos_url = File.join("https://#{@server}", 'rest', 'api', '1.0', 'projects')
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_repositories(project_key)
|
20
|
+
repos = []
|
21
|
+
RestClient::Request.new(
|
22
|
+
:method => :get,
|
23
|
+
:url => URI::encode("#{File.join(@get_repos_url, project_key, 'repos')}?limit=1000"),
|
24
|
+
:user => @username,
|
25
|
+
:password => @password,
|
26
|
+
:headers => { :accept => :json, :content_type => :json }).execute do |response, request, result|
|
27
|
+
raise "Could not get repositories - #{JSON::pretty_generate(JSON::parse(response.body))}" if !response.code.to_s.match(/^2\d{2}$/)
|
28
|
+
JSON::parse(response)['values'].each{ |h| repos << h['slug'] }
|
29
|
+
end
|
30
|
+
repos
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_file(project_key, repo, path)
|
34
|
+
RestClient::Request.new(
|
35
|
+
:method => :get,
|
36
|
+
:url => URI::encode("#{File.join(@get_repos_url, project_key, 'repos', repo, 'browse', path)}?limit=1000"),
|
37
|
+
:user => @username,
|
38
|
+
:password => @password,
|
39
|
+
:headers => { :accept => :json, :content_type => :json }).execute do |response, request, result|
|
40
|
+
return response.code.to_s.match(/^2\d{2}$/) ? JSON::parse(response)['lines'].map{|t| t['text']}.join("\n") : nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stash-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.35.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Warren Parad
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/stash-api.rb
|
63
63
|
- lib/stash-api/client.rb
|
64
64
|
- lib/stash-api/dsl.rb
|
65
|
+
- lib/stash-api/explorer.rb
|
65
66
|
homepage: https://github.com/wparad/Stash-API
|
66
67
|
licenses:
|
67
68
|
- BSD-3-Clause
|