gocd 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e86e47908ee026309142adda1ea7a4d41b1c2afe
4
- data.tar.gz: 6b138074811e9f5d73ce174ba88e05b6b99d9822
3
+ metadata.gz: 6e4a8f7ee005ef2453ffa3acb68fc21e179a3e92
4
+ data.tar.gz: f8b9d5969b926945fb9e90e9ea3db7fce9607914
5
5
  SHA512:
6
- metadata.gz: d2a1da24bb05bde6c8830c3dca8a875fb9a4b6b04290bf995e662285fbee9780f7aef8455078b33caf50aa4160dba9592741a835873a82b19d5d1684e63ce395
7
- data.tar.gz: cb9dc4585951818bf3581389f379250ec40b9e7587a3f21838b4ce5314e519d0447f1b917c5c0115e7f3b0555393f6fa9293e4bebd55be0c1d1a63e3be700579
6
+ metadata.gz: 0680c58875b5b1516efe35ea40e84ce176b0c459687e091e58d364b4ad48853bf5dc57956eb0f1f53afcd355d01e0b2bd3f5d25ebca0f43e47e38fbfff62527a
7
+ data.tar.gz: 9b8f48342eeb38975f7047450473bd8b0b0ba6af5a995e9435e2841dac8ddce25072abec144b4c092529cf013a95ca578bc6843409e1c0152be94a14d9b4f10f
@@ -6,7 +6,7 @@ require_relative './lib/gocd/version.rb'
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'gocd'
8
8
  s.version = GOCD::VERSION
9
- s.date = '2016-09-22'
9
+ s.date = '2017-02-25'
10
10
  s.summary = 'Get info from gocd using its apis'
11
11
  s.description = s.summary
12
12
  s.authors = ['Ajit Singh']
@@ -16,6 +16,7 @@ module GOCD
16
16
  end
17
17
 
18
18
  def enrich_with_pipelines(pipelines)
19
+ pipelines.each { |pipeline| pipeline.environment = name }
19
20
  @pipelines = pipelines
20
21
  end
21
22
 
@@ -4,7 +4,7 @@ module GOCD
4
4
  module PIPELINE_CONFIG
5
5
  class Job
6
6
  include GOCD::PIPELINE_CONFIG
7
- attr_reader :pipeline, :stage, :name, :resources
7
+ attr_reader :pipeline, :stage, :name, :resources, :environment
8
8
 
9
9
  def initialize(pipeline, stage, data)
10
10
  @pipeline = pipeline
@@ -13,6 +13,10 @@ module GOCD
13
13
  @resources = data['resources'].nil? ? [] : to_array(data['resources']['resource'])
14
14
  end
15
15
 
16
+ def environment=(env)
17
+ @environment = env
18
+ end
19
+
16
20
  def pipeline=(new_name)
17
21
  @pipeline = new_name
18
22
  end
@@ -4,7 +4,7 @@ module GOCD
4
4
  module PIPELINE_CONFIG
5
5
  class Pipeline
6
6
  include GOCD::PIPELINE_CONFIG
7
- attr_reader :name, :stages, :template
7
+ attr_reader :name, :stages, :template, :environment
8
8
 
9
9
  def initialize(data)
10
10
  @template = data['template']
@@ -21,6 +21,11 @@ module GOCD
21
21
  @stages.each { |stage| stage.pipeline = new_name }
22
22
  end
23
23
 
24
+ def environment=(env)
25
+ @environment = env
26
+ @stages.each { |stage| stage.environment = env }
27
+ end
28
+
24
29
  private
25
30
  def to_stages(data)
26
31
  to_array(data).map { |stage| GOCD::PIPELINE_CONFIG::Stage.new(name, stage) } unless data.nil?
@@ -4,7 +4,7 @@ module GOCD
4
4
  module PIPELINE_CONFIG
5
5
  class Stage
6
6
  include GOCD::PIPELINE_CONFIG
7
- attr_reader :pipeline, :name, :jobs
7
+ attr_reader :pipeline, :name, :jobs, :environment
8
8
 
9
9
  def initialize(pipeline, data)
10
10
  @pipeline = pipeline
@@ -12,6 +12,12 @@ module GOCD
12
12
  @jobs = data['jobs'].nil? ? [] : to_jobs(data['jobs']['job'])
13
13
  end
14
14
 
15
+
16
+ def environment=(env)
17
+ @environment = env
18
+ @jobs.each { |job| job.environment = env }
19
+ end
20
+
15
21
  def pipeline=(new_name)
16
22
  @pipeline = new_name
17
23
  @jobs.each { |job| job.pipeline = new_name }
@@ -1,3 +1,3 @@
1
1
  module GOCD
2
- VERSION = '1.0'
2
+ VERSION = '1.1'
3
3
  end
@@ -24,4 +24,14 @@ RSpec.describe GOCD::PIPELINE_CONFIG::Environment, 'Environment' do
24
24
  expect(environment.pipeline_names.first).to eq 'Pipeline1'
25
25
  expect(environment.pipeline_names.last).to eq 'Pipeline2'
26
26
  end
27
+
28
+ it 'should update environment in pipeline' do
29
+ response = Hash.from_xml(xml_response)
30
+ environment = GOCD::PIPELINE_CONFIG::Environment.new response['environment']
31
+
32
+ pipeline = instance_double('pipeline')
33
+ expect(pipeline).to receive(:environment=).with('Env')
34
+
35
+ environment.enrich_with_pipelines([pipeline])
36
+ end
27
37
  end
@@ -59,4 +59,14 @@ RSpec.describe GOCD::PIPELINE_CONFIG::Pipeline, 'Pipeline' do
59
59
  expect(pipeline.name).to eq 'MyAwesomePipeline'
60
60
  expect(pipeline.template).to eq 'MyAwesomeTemplate'
61
61
  end
62
+
63
+ it 'should update environment in stages' do
64
+ stage = instance_double('stage')
65
+ expect(GOCD::PIPELINE_CONFIG::Stage).to receive(:new).and_return(stage)
66
+ pipeline = GOCD::PIPELINE_CONFIG::Pipeline.new({'stage' => [stage]})
67
+
68
+ expect(stage).to receive(:environment=).with('Env')
69
+
70
+ pipeline.environment = 'Env'
71
+ end
62
72
  end
@@ -3,7 +3,7 @@ require 'active_support/core_ext/hash/conversions'
3
3
 
4
4
  RSpec.describe GOCD::PIPELINE_CONFIG::Stage, 'Stage' do
5
5
  xml_response = <<-PipelineGroup
6
- <stage name="build">
6
+ <job name="build">
7
7
  <jobs>
8
8
  <job name="flavor1_build">
9
9
  <resources>
@@ -18,15 +18,25 @@ RSpec.describe GOCD::PIPELINE_CONFIG::Stage, 'Stage' do
18
18
  </resources>
19
19
  </job>
20
20
  </jobs>
21
- </stage>
21
+ </job>
22
22
  PipelineGroup
23
23
 
24
- it 'should parse stage' do
24
+ it 'should parse job' do
25
25
  response = Hash.from_xml(xml_response)
26
- stage = GOCD::PIPELINE_CONFIG::Stage.new 'MyAwesomePipeline', response['stage']
26
+ stage = GOCD::PIPELINE_CONFIG::Stage.new 'MyAwesomePipeline', response['job']
27
27
 
28
28
  expect(stage.name).to eq 'build'
29
29
  expect(stage.pipeline).to eq 'MyAwesomePipeline'
30
30
  expect(stage.jobs.size).to eq 2
31
31
  end
32
+
33
+ it 'should update environment in jobs' do
34
+ job = instance_double('job')
35
+ expect(GOCD::PIPELINE_CONFIG::Job).to receive(:new).and_return(job)
36
+ stage = GOCD::PIPELINE_CONFIG::Stage.new('pipeline', {'jobs' => {'job' => job}})
37
+
38
+ expect(job).to receive(:environment=).with('Env')
39
+
40
+ stage.environment = 'Env'
41
+ end
32
42
  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.0'
4
+ version: '1.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ajit Singh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-22 00:00:00.000000000 Z
11
+ date: 2017-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport