subordinate 0.2.2 → 0.3.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.
@@ -7,7 +7,7 @@ module Subordinate
|
|
7
7
|
module Load
|
8
8
|
# Returns the current load statistics of the Jenkins server
|
9
9
|
#
|
10
|
-
# @see
|
10
|
+
# @see https://ci.jenkins-ci.org:8080/queue/api/
|
11
11
|
#
|
12
12
|
# @return [Hashie::Mash] load statistics response
|
13
13
|
#
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# View
|
2
|
+
module Subordinate
|
3
|
+
class Client
|
4
|
+
# View
|
5
|
+
#
|
6
|
+
# @see https://ci.jenkins-ci.org/view/All%20Unstable/api/
|
7
|
+
module View
|
8
|
+
# Returns the specified view
|
9
|
+
#
|
10
|
+
# @see http://ci.jenkins-ci.org/view/All%20Unstable/api/json?pretty=true
|
11
|
+
#
|
12
|
+
# @param view_name [String] the name of the view you want inforamtion on
|
13
|
+
#
|
14
|
+
# @return [Hashie::Mash] response from the specified view
|
15
|
+
#
|
16
|
+
# @example Get the current view
|
17
|
+
# Subordinate::Client.view("My-Awesome-View")
|
18
|
+
#
|
19
|
+
# @author Jason Truluck
|
20
|
+
def view(view_name, options = {})
|
21
|
+
get("view/#{view_name}/api/json", options)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns all of the views with their corresponding jobs
|
25
|
+
#
|
26
|
+
# @see https://ci.jenkins-ci.org/api/json?tree=views[name,jobs[name]]
|
27
|
+
#
|
28
|
+
# @return [Hashie::Mash] response containing all views on the server and their respective jobs
|
29
|
+
#
|
30
|
+
# @example Get all the views
|
31
|
+
# Subordinate::Client.all_views
|
32
|
+
#
|
33
|
+
# @author Jason Truluck
|
34
|
+
def all_views(options = {})
|
35
|
+
options.merge!(
|
36
|
+
:tree => "views[name,url,jobs[name,url]]"
|
37
|
+
)
|
38
|
+
get("api/json", options)
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
# Add a job to the Jenkins view
|
43
|
+
#
|
44
|
+
# @see http://ci.jenkins-ci.org/view/All%20Unstable/api/
|
45
|
+
#
|
46
|
+
# @param view_name [String] the name of the view you want inforamtion on
|
47
|
+
# @param job [String] the name of the job you want to add
|
48
|
+
#
|
49
|
+
# @return [Integer] status the status of the request
|
50
|
+
#
|
51
|
+
# @example Add the selected Job to the Jenkins View
|
52
|
+
# Subordinate::Client.add_job_to_view("My-Awesome-View", "My-Awesome-Job")
|
53
|
+
#
|
54
|
+
# @author Jason Truluck
|
55
|
+
def add_job_to_view(view_name, job, options = {})
|
56
|
+
options.merge!(
|
57
|
+
:with_query_params => true,
|
58
|
+
:name => job
|
59
|
+
)
|
60
|
+
post("view/#{view_name}/addJobToView", options)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Remove a job to the Jenkins view
|
64
|
+
#
|
65
|
+
# @see http://ci.jenkins-ci.org/view/All%20Unstable/api/
|
66
|
+
#
|
67
|
+
# @param view_name [String] the name of the view you want inforamtion on
|
68
|
+
# @param job [String] the name of the job you want to remove
|
69
|
+
#
|
70
|
+
# @return [Integer] status the status of the request
|
71
|
+
#
|
72
|
+
# @example Remove the selected job from the Jenkins View
|
73
|
+
# Subordinate::Client.remove_job_from_view("My-Awesome-View", "My-Awesome-Job")
|
74
|
+
#
|
75
|
+
# @author Jason Truluck
|
76
|
+
def remove_job_from_view(view_name, job, options = {})
|
77
|
+
options.merge!(
|
78
|
+
:with_query_params => true,
|
79
|
+
:name => job
|
80
|
+
)
|
81
|
+
post("view/#{view_name}/removeJobFromView", options)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/subordinate/client.rb
CHANGED
@@ -8,6 +8,7 @@ require "subordinate/client/system"
|
|
8
8
|
require "subordinate/client/build"
|
9
9
|
require "subordinate/client/queue"
|
10
10
|
require "subordinate/client/load"
|
11
|
+
require "subordinate/client/view"
|
11
12
|
|
12
13
|
module Subordinate
|
13
14
|
class Client
|
@@ -45,5 +46,6 @@ module Subordinate
|
|
45
46
|
include Subordinate::Client::Build
|
46
47
|
include Subordinate::Client::Queue
|
47
48
|
include Subordinate::Client::Load
|
49
|
+
include Subordinate::Client::View
|
48
50
|
end
|
49
51
|
end
|
data/lib/subordinate/request.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'multi_json'
|
2
|
+
|
1
3
|
module Subordinate
|
2
4
|
module Request
|
3
5
|
def get(path, options = {})
|
@@ -23,8 +25,13 @@ module Subordinate
|
|
23
25
|
when :get
|
24
26
|
request.url(path, options)
|
25
27
|
when :post
|
26
|
-
|
27
|
-
|
28
|
+
with_query_params = options.delete(:with_query_params) || false
|
29
|
+
if with_query_params
|
30
|
+
request.url(path, options)
|
31
|
+
else
|
32
|
+
request.path = path
|
33
|
+
request.body = MultiJson.dump(options) unless options.empty?
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
30
37
|
response
|
data/lib/subordinate/version.rb
CHANGED
@@ -0,0 +1,94 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
auth = YAML::load(File.open(File.expand_path("../../../fixtures/authentications.yml", __FILE__)))
|
4
|
+
|
5
|
+
# View Spec
|
6
|
+
describe Subordinate::Client do
|
7
|
+
before do
|
8
|
+
Subordinate.reset!
|
9
|
+
Subordinate.configure do |c|
|
10
|
+
c.subdomain = auth["subdomain"]
|
11
|
+
c.domain = auth["domain"]
|
12
|
+
c.port = auth["port"]
|
13
|
+
c.ssl = false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:subordinate) { Subordinate::Client.new(:username => auth["username"], :api_token => auth["token"]) }
|
18
|
+
|
19
|
+
describe "#view", :vcr do
|
20
|
+
let(:current_response) { subordinate.view(auth["view"]) }
|
21
|
+
|
22
|
+
it "returns the view response" do
|
23
|
+
current_response.should_not be_nil
|
24
|
+
end
|
25
|
+
|
26
|
+
context "methods" do
|
27
|
+
it "responds to .description" do
|
28
|
+
current_response.should respond_to(:description)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "responds to .jobs" do
|
32
|
+
current_response.should respond_to(:jobs)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "responds to .name" do
|
36
|
+
current_response.should respond_to(:name)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "responds to .property" do
|
40
|
+
current_response.should respond_to(:property)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "responds to .url" do
|
44
|
+
current_response.should respond_to(:url)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#all_views", :vcr do
|
50
|
+
let(:current_response) { subordinate.all_views }
|
51
|
+
|
52
|
+
it "returns the view response" do
|
53
|
+
current_response.should_not be_nil
|
54
|
+
end
|
55
|
+
|
56
|
+
context "methods" do
|
57
|
+
it "respond to .views" do
|
58
|
+
current_response.should respond_to(:views)
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "within views" do
|
62
|
+
it "respond to .jobs" do
|
63
|
+
current_response.views.first.should respond_to(:jobs)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "respond to .name" do
|
67
|
+
current_response.views.first.should respond_to(:name)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "respond to .url" do
|
71
|
+
current_response.views.first.should respond_to(:url)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#add_job_to_view" do
|
78
|
+
it "responds with a success" do
|
79
|
+
stub_request(:post, "#{subordinate.api_endpoint}/view/#{auth['view']}/addJobToView").
|
80
|
+
to_return(:status => 200, :body => "", :headers => {})
|
81
|
+
|
82
|
+
subordinate.add_job_to_view(auth['view'], auth['job']).status.should == 200
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#remove_job_from_view" do
|
87
|
+
it "responds with a success" do
|
88
|
+
stub_request(:post, "#{subordinate.api_endpoint}/view/#{auth['view']}/removeJobFromView").
|
89
|
+
to_return(:status => 200, :body => "", :headers => {})
|
90
|
+
|
91
|
+
subordinate.remove_job_from_view(auth['view'], auth['job']).status.should == 200
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subordinate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -239,6 +239,7 @@ files:
|
|
239
239
|
- lib/subordinate/client/load.rb
|
240
240
|
- lib/subordinate/client/queue.rb
|
241
241
|
- lib/subordinate/client/system.rb
|
242
|
+
- lib/subordinate/client/view.rb
|
242
243
|
- lib/subordinate/configuration.rb
|
243
244
|
- lib/subordinate/connection.rb
|
244
245
|
- lib/subordinate/request.rb
|
@@ -250,6 +251,7 @@ files:
|
|
250
251
|
- spec/subordinate/client/load_spec.rb
|
251
252
|
- spec/subordinate/client/queue_spec.rb
|
252
253
|
- spec/subordinate/client/system_spec.rb
|
254
|
+
- spec/subordinate/client/view_spec.rb
|
253
255
|
- spec/subordinate/client_spec.rb
|
254
256
|
- subordinate.gemspec
|
255
257
|
homepage: https://github.com/jasontruluck/subordinate
|
@@ -266,7 +268,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
266
268
|
version: '0'
|
267
269
|
segments:
|
268
270
|
- 0
|
269
|
-
hash:
|
271
|
+
hash: 1397159424799143771
|
270
272
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
271
273
|
none: false
|
272
274
|
requirements:
|
@@ -275,7 +277,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
275
277
|
version: '0'
|
276
278
|
segments:
|
277
279
|
- 0
|
278
|
-
hash:
|
280
|
+
hash: 1397159424799143771
|
279
281
|
requirements: []
|
280
282
|
rubyforge_project:
|
281
283
|
rubygems_version: 1.8.24
|
@@ -290,5 +292,6 @@ test_files:
|
|
290
292
|
- spec/subordinate/client/load_spec.rb
|
291
293
|
- spec/subordinate/client/queue_spec.rb
|
292
294
|
- spec/subordinate/client/system_spec.rb
|
295
|
+
- spec/subordinate/client/view_spec.rb
|
293
296
|
- spec/subordinate/client_spec.rb
|
294
297
|
has_rdoc:
|