gocd 1.2.5 → 1.3
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 +5 -5
- data/.travis.yml +5 -5
- data/Gemfile +2 -2
- data/Gemfile.lock +28 -30
- data/README.md +2 -0
- data/lib/gocd/config/credentials.rb +3 -1
- data/lib/gocd/pipeline_status/pipeline_repository.rb +1 -1
- data/lib/gocd/pipeline_status/pipelines.rb +37 -23
- data/lib/gocd/version.rb +1 -1
- data/spec/gocd/config/credentials_spec.rb +6 -1
- data/spec/gocd/pipeline_status/pipelines_spec.rb +50 -0
- metadata +3 -4
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 188ab274b584582cbb0f8541d50165549b845d444f0120f784ce5dc7ef14e62a
|
4
|
+
data.tar.gz: '07808c0d30bfa63b5f1c4e395a3c2232bc81933d685d49a3ca003af748b7e0bc'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b914ef2f894244676d15d7a12ef96ac4fab8a82ed28928e55fc3e57fa73d33da13b24b464dea34dda594340c23e27f2004e27c1567aac7225d3deaade6d03012
|
7
|
+
data.tar.gz: 23a87cb1c0e574afeacf305cc9c6a42abb8c600ab27bc2aa1b1ec09f2aaaab791f2433fd1b992b6bc1c5a5af394583036bbfcbd082e864048835a5c4d03b50d8
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,48 +1,49 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (5.
|
4
|
+
activesupport (5.2.1)
|
5
5
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
-
i18n (
|
6
|
+
i18n (>= 0.7, < 2)
|
7
7
|
minitest (~> 5.1)
|
8
8
|
tzinfo (~> 1.1)
|
9
9
|
cobravsmongoose (0.0.2)
|
10
|
-
concurrent-ruby (1.0.
|
11
|
-
diff-lcs (1.
|
12
|
-
domain_name (0.5.
|
10
|
+
concurrent-ruby (1.0.5)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
domain_name (0.5.20180417)
|
13
13
|
unf (>= 0.0.5, < 1.0.0)
|
14
14
|
http-cookie (1.0.3)
|
15
15
|
domain_name (~> 0.5)
|
16
|
-
i18n (
|
17
|
-
|
16
|
+
i18n (1.1.1)
|
17
|
+
concurrent-ruby (~> 1.0)
|
18
|
+
mime-types (3.2.2)
|
18
19
|
mime-types-data (~> 3.2015)
|
19
|
-
mime-types-data (3.
|
20
|
-
minitest (5.
|
20
|
+
mime-types-data (3.2018.0812)
|
21
|
+
minitest (5.11.3)
|
21
22
|
netrc (0.11.0)
|
22
|
-
rake (
|
23
|
-
rest-client (2.0.
|
23
|
+
rake (12.3.1)
|
24
|
+
rest-client (2.0.2)
|
24
25
|
http-cookie (>= 1.0.2, < 2.0)
|
25
26
|
mime-types (>= 1.16, < 4.0)
|
26
27
|
netrc (~> 0.8)
|
27
|
-
rspec (3.
|
28
|
-
rspec-core (~> 3.
|
29
|
-
rspec-expectations (~> 3.
|
30
|
-
rspec-mocks (~> 3.
|
31
|
-
rspec-core (3.
|
32
|
-
rspec-support (~> 3.
|
33
|
-
rspec-expectations (3.
|
28
|
+
rspec (3.8.0)
|
29
|
+
rspec-core (~> 3.8.0)
|
30
|
+
rspec-expectations (~> 3.8.0)
|
31
|
+
rspec-mocks (~> 3.8.0)
|
32
|
+
rspec-core (3.8.0)
|
33
|
+
rspec-support (~> 3.8.0)
|
34
|
+
rspec-expectations (3.8.2)
|
34
35
|
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
-
rspec-support (~> 3.
|
36
|
-
rspec-mocks (3.
|
36
|
+
rspec-support (~> 3.8.0)
|
37
|
+
rspec-mocks (3.8.0)
|
37
38
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
-
rspec-support (~> 3.
|
39
|
-
rspec-support (3.
|
40
|
-
thread_safe (0.3.
|
41
|
-
tzinfo (1.2.
|
39
|
+
rspec-support (~> 3.8.0)
|
40
|
+
rspec-support (3.8.0)
|
41
|
+
thread_safe (0.3.6)
|
42
|
+
tzinfo (1.2.5)
|
42
43
|
thread_safe (~> 0.1)
|
43
44
|
unf (0.1.4)
|
44
45
|
unf_ext
|
45
|
-
unf_ext (0.0.7.
|
46
|
+
unf_ext (0.0.7.5)
|
46
47
|
|
47
48
|
PLATFORMS
|
48
49
|
ruby
|
@@ -52,10 +53,7 @@ DEPENDENCIES
|
|
52
53
|
cobravsmongoose (= 0.0.2)
|
53
54
|
rake
|
54
55
|
rest-client
|
55
|
-
rspec
|
56
|
-
|
57
|
-
RUBY VERSION
|
58
|
-
ruby 2.3.1p112
|
56
|
+
rspec
|
59
57
|
|
60
58
|
BUNDLED WITH
|
61
|
-
1.
|
59
|
+
1.16.1
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# gocd
|
2
2
|
|
3
|
+
[](https://GitHub.com/ajitsing/gocd/graphs/commit-activity)
|
3
4
|
[](https://opensource.org/licenses/Apache-2.0)
|
4
5
|
[](https://badge.fury.io/rb/gocd)
|
6
|
+
[](http://hits.dwyl.io/ajitsing/gocd)
|
5
7
|

|
6
8
|
[](https://travis-ci.org/ajitsing/gocd)
|
7
9
|
[](https://twitter.com/Ajit5ingh)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
|
1
3
|
module GOCD
|
2
4
|
class Credentials
|
3
5
|
attr_reader :username, :password
|
@@ -8,7 +10,7 @@ module GOCD
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def curl_credentials
|
11
|
-
"#{@username}:#{@password}"
|
13
|
+
Shellwords.escape("#{@username}:#{@password}")
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
@@ -1,62 +1,76 @@
|
|
1
1
|
module GOCD
|
2
2
|
class AllPipelines
|
3
3
|
class << self
|
4
|
+
DEFAULT_OPTS = {cache: false}
|
5
|
+
|
4
6
|
def information_available?
|
5
7
|
!pipelines.nil?
|
6
8
|
end
|
7
9
|
|
8
|
-
def red_pipelines
|
9
|
-
pipelines.select { |pipeline| pipeline.red? }
|
10
|
+
def red_pipelines(opts = {})
|
11
|
+
pipelines(opts).select { |pipeline| pipeline.red? }
|
10
12
|
end
|
11
13
|
|
12
|
-
def green_pipelines
|
13
|
-
pipelines.select { |pipeline| pipeline.green? }
|
14
|
+
def green_pipelines(opts = {})
|
15
|
+
pipelines(opts).select { |pipeline| pipeline.green? }
|
14
16
|
end
|
15
17
|
|
16
|
-
def status
|
17
|
-
pipelines.map { |pipeline| pipeline.status }
|
18
|
+
def status(opts = {})
|
19
|
+
pipelines(opts).map { |pipeline| pipeline.status }
|
18
20
|
end
|
19
21
|
|
20
|
-
def any_red?
|
21
|
-
!red_pipelines.empty?
|
22
|
+
def any_red?(opts = {})
|
23
|
+
!red_pipelines(opts).empty?
|
22
24
|
end
|
23
25
|
|
24
|
-
def pipelines
|
25
|
-
|
26
|
+
def pipelines(opts = {})
|
27
|
+
merged_opts = DEFAULT_OPTS.merge(opts)
|
28
|
+
if merged_opts[:cache]
|
29
|
+
@pipelines ||= GOCD::PipelineRepository.pipelines
|
30
|
+
else
|
31
|
+
@pipelines = GOCD::PipelineRepository.pipelines
|
32
|
+
end
|
26
33
|
end
|
27
34
|
end
|
28
35
|
end
|
29
36
|
|
30
37
|
class PipelineGroup
|
31
|
-
def initialize(pipelines)
|
38
|
+
def initialize(pipelines, opts = {})
|
32
39
|
@pipelines = pipelines
|
40
|
+
@default_opts = {cache: false}.merge(opts)
|
33
41
|
end
|
34
42
|
|
35
43
|
def information_available?
|
36
44
|
!pipelines.nil?
|
37
45
|
end
|
38
46
|
|
39
|
-
def red_pipelines
|
40
|
-
pipelines.select { |pipeline| pipeline.red? }
|
47
|
+
def red_pipelines(opts = {})
|
48
|
+
pipelines(opts).select { |pipeline| pipeline.red? }
|
41
49
|
end
|
42
50
|
|
43
|
-
def green_pipelines
|
44
|
-
pipelines.select { |pipeline| pipeline.green? }
|
51
|
+
def green_pipelines(opts = {})
|
52
|
+
pipelines(opts).select { |pipeline| pipeline.green? }
|
45
53
|
end
|
46
54
|
|
47
|
-
def status
|
48
|
-
pipelines.map { |pipeline| pipeline.status }
|
55
|
+
def status(opts = {})
|
56
|
+
pipelines(opts).map { |pipeline| pipeline.status }
|
49
57
|
end
|
50
58
|
|
51
|
-
def any_red?
|
52
|
-
!red_pipelines.empty?
|
59
|
+
def any_red?(opts = {})
|
60
|
+
!red_pipelines(opts).empty?
|
53
61
|
end
|
54
62
|
|
55
|
-
def pipelines
|
56
|
-
|
63
|
+
def pipelines(opts = {})
|
64
|
+
merged_opts = @default_opts.merge(opts)
|
65
|
+
if merged_opts[:cache]
|
66
|
+
@all_pipelines ||= GOCD::PipelineRepository.pipelines
|
67
|
+
else
|
68
|
+
@all_pipelines = GOCD::PipelineRepository.pipelines
|
69
|
+
end
|
70
|
+
|
57
71
|
missing_pipelines = []
|
58
72
|
@pipelines.select do |pipeline|
|
59
|
-
if all_pipelines.find { |p| p.name == pipeline }.nil?
|
73
|
+
if @all_pipelines.find { |p| p.name == pipeline }.nil?
|
60
74
|
missing_pipelines << pipeline
|
61
75
|
end
|
62
76
|
end
|
@@ -67,7 +81,7 @@ module GOCD
|
|
67
81
|
end
|
68
82
|
|
69
83
|
@pipelines.map do |pipeline|
|
70
|
-
all_pipelines.find { |p| p.name == pipeline }
|
84
|
+
@all_pipelines.find { |p| p.name == pipeline }
|
71
85
|
end
|
72
86
|
end
|
73
87
|
end
|
data/lib/gocd/version.rb
CHANGED
@@ -6,4 +6,9 @@ RSpec.describe GOCD::Credentials, 'credentials' do
|
|
6
6
|
credentials = GOCD::Credentials.new 'admin', 'password'
|
7
7
|
expect(credentials.curl_credentials).to eq 'admin:password'
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
|
+
it '#curl_credentials should be escaped for the command line' do
|
11
|
+
credentials = GOCD::Credentials.new('admin', '"cpF@<`89Q.[cA]C%hj>M<s3\'sl')
|
12
|
+
expect(credentials.curl_credentials).to eq('admin:\"cpF@\<\`89Q.\[cA\]C\%hj\>M\<s3\\\'sl')
|
13
|
+
end
|
14
|
+
end
|
@@ -43,6 +43,18 @@ RSpec.describe GOCD::AllPipelines, 'pipelines' do
|
|
43
43
|
mock_pipeline_repository_with_green_pipelines
|
44
44
|
expect(GOCD::AllPipelines.any_red?).to be_falsy
|
45
45
|
end
|
46
|
+
|
47
|
+
context 'cache' do
|
48
|
+
it 'should not fetch latest pipelines when cache is enabled' do
|
49
|
+
mock_pipeline_repository
|
50
|
+
|
51
|
+
GOCD::AllPipelines.pipelines(cache: false)
|
52
|
+
GOCD::AllPipelines.any_red?(cache: true)
|
53
|
+
GOCD::AllPipelines.red_pipelines(cache: true)
|
54
|
+
GOCD::AllPipelines.green_pipelines(cache: true)
|
55
|
+
GOCD::AllPipelines.status(cache: true)
|
56
|
+
end
|
57
|
+
end
|
46
58
|
end
|
47
59
|
|
48
60
|
|
@@ -83,5 +95,43 @@ RSpec.describe GOCD::AllPipelines, 'pipelines' do
|
|
83
95
|
pipeline_group = GOCD::PipelineGroup.new %w(pipeline1 pipeline3)
|
84
96
|
expect{pipeline_group.any_red?}.to raise_error(PipelinesNotFoundException).with_message("Could not find [\"pipeline3\"]")
|
85
97
|
end
|
98
|
+
|
99
|
+
context 'cache' do
|
100
|
+
it 'should not fetch latest pipelines when cache is enabled' do
|
101
|
+
pipeline = instance_double("Pipeline", :red? => false, :green? => true, :status => 'passing', :name => 'pipeline1')
|
102
|
+
expect(GOCD::PipelineRepository).to receive(:pipelines).once.and_return([pipeline])
|
103
|
+
|
104
|
+
pipeline_group = GOCD::PipelineGroup.new %w(pipeline1)
|
105
|
+
|
106
|
+
pipeline_group.pipelines(cache: true)
|
107
|
+
pipeline_group.any_red?(cache: true)
|
108
|
+
pipeline_group.red_pipelines(cache: true)
|
109
|
+
pipeline_group.green_pipelines(cache: true)
|
110
|
+
pipeline_group.status(cache: true)
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should not fetch latest pipelines when cache is enabled during initialization' do
|
114
|
+
pipeline = instance_double("Pipeline", :red? => false, :green? => true, :status => 'passing', :name => 'pipeline1')
|
115
|
+
expect(GOCD::PipelineRepository).to receive(:pipelines).once.and_return([pipeline])
|
116
|
+
|
117
|
+
pipeline_group = GOCD::PipelineGroup.new %w(pipeline1), cache: true
|
118
|
+
|
119
|
+
pipeline_group.pipelines
|
120
|
+
pipeline_group.any_red?
|
121
|
+
pipeline_group.red_pipelines
|
122
|
+
pipeline_group.green_pipelines
|
123
|
+
pipeline_group.status
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should fetch latest pipelines when cache is disabled during api call' do
|
127
|
+
pipeline = instance_double("Pipeline", :red? => false, :green? => true, :status => 'passing', :name => 'pipeline1')
|
128
|
+
expect(GOCD::PipelineRepository).to receive(:pipelines).twice.and_return([pipeline])
|
129
|
+
|
130
|
+
pipeline_group = GOCD::PipelineGroup.new %w(pipeline1), cache: true
|
131
|
+
|
132
|
+
pipeline_group.pipelines
|
133
|
+
pipeline_group.any_red?(cache: false)
|
134
|
+
end
|
135
|
+
end
|
86
136
|
end
|
87
137
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gocd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ajit Singh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -102,7 +102,6 @@ extra_rdoc_files: []
|
|
102
102
|
files:
|
103
103
|
- ".gitignore"
|
104
104
|
- ".rspec"
|
105
|
-
- ".ruby-version"
|
106
105
|
- ".travis.yml"
|
107
106
|
- Gemfile
|
108
107
|
- Gemfile.lock
|
@@ -166,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
165
|
version: '0'
|
167
166
|
requirements: []
|
168
167
|
rubyforge_project:
|
169
|
-
rubygems_version: 2.6
|
168
|
+
rubygems_version: 2.7.6
|
170
169
|
signing_key:
|
171
170
|
specification_version: 4
|
172
171
|
summary: Get info from gocd using its apis
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.3.1
|