bamboo-cli 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. data/lib/bamboo.rb +42 -0
  2. data/lib/outputs.rb +23 -0
  3. metadata +5 -3
data/lib/bamboo.rb ADDED
@@ -0,0 +1,42 @@
1
+
2
+ require 'httparty'
3
+ require 'uri-handler'
4
+
5
+ class Bamboo
6
+ include HTTParty
7
+ default_params :output => 'json'
8
+ format :json
9
+ headers 'Accept' => 'application/json'
10
+
11
+ def initialize(u, p, uri)
12
+ self.class.base_uri uri
13
+ self.class.basic_auth u, p
14
+ end
15
+
16
+ def queue(key, allstages, stage)
17
+
18
+ url = '/rest/api/latest/queue/' + key
19
+ if allstages
20
+ url = url + '?executeAllStages=true'
21
+ elsif stage
22
+ url = url + '?stage=' + URI::encode(stage)
23
+ end
24
+ self.class.post(url)
25
+ end
26
+
27
+ def info
28
+ self.class.get('/rest/api/latest/info.json')
29
+ end
30
+
31
+ def me
32
+ self.class.get('/rest/api/latest/currentUser.json')
33
+ end
34
+
35
+ def pause
36
+ self.class.post('/rest/api/latest/server/pause')
37
+ end
38
+
39
+ def resume
40
+ self.class.post('/rest/api/latest/server/resume')
41
+ end
42
+ end
data/lib/outputs.rb ADDED
@@ -0,0 +1,23 @@
1
+
2
+ class TextOutput
3
+ def out(hash)
4
+ hash.each_pair do |k,v|
5
+ print(k, k, v) if v != nil
6
+ end
7
+ end
8
+
9
+ def print(parent_key, k, v)
10
+ if v.is_a?(Hash)
11
+ print_hash(k, v)
12
+ else
13
+ puts k + ": " + v.to_s
14
+ end
15
+ end
16
+
17
+ def print_hash(parent_key, hash)
18
+ hash.each_pair do |k,v|
19
+ print parent_key + "." + k, k, v if v != nil
20
+ end
21
+ end
22
+ end
23
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bamboo-cli
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Dumay
@@ -108,6 +108,8 @@ extra_rdoc_files: []
108
108
 
109
109
  files:
110
110
  - lib/cli.rb
111
+ - lib/bamboo.rb
112
+ - lib/outputs.rb
111
113
  - bin/bamboo-cli
112
114
  homepage: http://www.atlassian.com/bamboo
113
115
  licenses: []