gocd 1.2.1 → 1.2.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 +4 -4
- data/.travis.yml +8 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +5 -0
- data/README.md +67 -0
- data/gocd.gemspec +0 -1
- data/lib/gocd/pipeline_config/environment.rb +2 -2
- data/lib/gocd/pipeline_config/job.rb +19 -2
- data/lib/gocd/pipeline_config/pipeline.rb +18 -3
- data/lib/gocd/pipeline_config/pipeline_config.rb +18 -14
- data/lib/gocd/pipeline_config/pipeline_group.rb +1 -1
- data/lib/gocd/pipeline_config/repository/pipeline_config_repository.rb +2 -2
- data/lib/gocd/pipeline_config/stage.rb +1 -1
- data/lib/gocd/version.rb +1 -1
- data/spec/gocd/history/history_fetcher_spec.rb +1 -1
- data/spec/gocd/pipeline_config/environment_spec.rb +3 -3
- data/spec/gocd/pipeline_config/job_spec.rb +21 -4
- data/spec/gocd/pipeline_config/pipeline_group_spec.rb +2 -2
- data/spec/gocd/pipeline_config/pipeline_spec.rb +38 -3
- data/spec/gocd/pipeline_config/stage_spec.rb +2 -2
- data/spec/gocd/pipeline_config/template_spec.rb +2 -2
- metadata +4 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f8c7b5ca4f714b0afe958a5805c4068028b43fa6
         | 
| 4 | 
            +
              data.tar.gz: 5294d066465fdf8351e18ac833ffee64993ed960
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a6bff43e851fc5e2f44adf17b812b2afce3f5e056743e139e196d23b1d8b1dcf7b3be71fe1f762ff1d2f2799436325c8d522cad01807b76075fdc971412eb8cf
         | 
| 7 | 
            +
              data.tar.gz: cf2f05530f734a7f0a7a9ffbcf33e8efa6a0ab497795960ddb75bfb96c5bd627df8b6d390656fabc4de558a7cbbde6e51e242dbed39f7508cf982727c1059a07
         | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -6,6 +6,7 @@ GEM | |
| 6 6 | 
             
                  i18n (~> 0.7)
         | 
| 7 7 | 
             
                  minitest (~> 5.1)
         | 
| 8 8 | 
             
                  tzinfo (~> 1.1)
         | 
| 9 | 
            +
                cobravsmongoose (0.0.2)
         | 
| 9 10 | 
             
                concurrent-ruby (1.0.2)
         | 
| 10 11 | 
             
                diff-lcs (1.2.5)
         | 
| 11 12 | 
             
                domain_name (0.5.20161021)
         | 
| @@ -48,9 +49,13 @@ PLATFORMS | |
| 48 49 |  | 
| 49 50 | 
             
            DEPENDENCIES
         | 
| 50 51 | 
             
              activesupport
         | 
| 52 | 
            +
              cobravsmongoose (= 0.0.2)
         | 
| 51 53 | 
             
              rake
         | 
| 52 54 | 
             
              rest-client
         | 
| 53 55 | 
             
              rspec (~> 3.0)
         | 
| 54 56 |  | 
| 57 | 
            +
            RUBY VERSION
         | 
| 58 | 
            +
               ruby 2.3.1p112
         | 
| 59 | 
            +
             | 
| 55 60 | 
             
            BUNDLED WITH
         | 
| 56 61 | 
             
               1.13.6
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,6 +1,10 @@ | |
| 1 1 | 
             
            # gocd
         | 
| 2 2 |  | 
| 3 | 
            +
            [](https://opensource.org/licenses/Apache-2.0)
         | 
| 3 4 | 
             
            [](https://badge.fury.io/rb/gocd)
         | 
| 5 | 
            +
            
         | 
| 6 | 
            +
            [](https://travis-ci.org/ajitsing/gocd)
         | 
| 7 | 
            +
            [](https://twitter.com/Ajit5ingh)
         | 
| 4 8 |  | 
| 5 9 | 
             
            ### Installation
         | 
| 6 10 | 
             
            ```ruby
         | 
| @@ -13,6 +17,9 @@ or | |
| 13 17 | 
             
            gem install gocd
         | 
| 14 18 | 
             
            ```
         | 
| 15 19 |  | 
| 20 | 
            +
            ### Code Documentation
         | 
| 21 | 
            +
            http://www.rubydoc.info/gems/gocd/1.2.1
         | 
| 22 | 
            +
             | 
| 16 23 | 
             
            ### Usage
         | 
| 17 24 |  | 
| 18 25 | 
             
            ```ruby
         | 
| @@ -34,6 +41,19 @@ pipelines.status | |
| 34 41 | 
             
            pipelines.any_red?
         | 
| 35 42 | 
             
            ```
         | 
| 36 43 |  | 
| 44 | 
            +
            #### Want to create your own gocd dashboard? Its easy now!
         | 
| 45 | 
            +
            ```ruby
         | 
| 46 | 
            +
            require 'sinatra'
         | 
| 47 | 
            +
            require 'gocd'
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            get '/' do
         | 
| 50 | 
            +
              GOCD.server = GOCD::Server.new 'http://goserverurl.com'
         | 
| 51 | 
            +
              GOCD.credentials = GOCD::Credentials.new 'username', 'password'
         | 
| 52 | 
            +
              GOCD::AllPipelines.red_pipelines.map {|pipeline| pipeline.to_hash}.to_json
         | 
| 53 | 
            +
            end
         | 
| 54 | 
            +
            ```
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            #### Go Agents
         | 
| 37 57 | 
             
            ###### To get all the idle agents:
         | 
| 38 58 | 
             
            ```ruby
         | 
| 39 59 | 
             
            idle_agents = GOCD::Agents.idle
         | 
| @@ -50,6 +70,53 @@ GOCD::Agents.missing | |
| 50 70 | 
             
            GOCD::Agents.disabled
         | 
| 51 71 | 
             
            ```
         | 
| 52 72 |  | 
| 73 | 
            +
            #### Pipeline Configuration
         | 
| 74 | 
            +
             | 
| 75 | 
            +
            ###### Get all the environments
         | 
| 76 | 
            +
            ```ruby
         | 
| 77 | 
            +
            include GOCD::PIPELINE_CONFIG
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            environments #returns all the environments and the whole hierarchy of it
         | 
| 80 | 
            +
            ```
         | 
| 81 | 
            +
             | 
| 82 | 
            +
            ###### Get all the pipelines
         | 
| 83 | 
            +
            ```ruby
         | 
| 84 | 
            +
            include GOCD::PIPELINE_CONFIG
         | 
| 85 | 
            +
             | 
| 86 | 
            +
            pipelines = environments.map(&:pipelines).flatten
         | 
| 87 | 
            +
            ```
         | 
| 88 | 
            +
             | 
| 89 | 
            +
            ###### Get all the stages
         | 
| 90 | 
            +
            ```ruby
         | 
| 91 | 
            +
            include GOCD::PIPELINE_CONFIG
         | 
| 92 | 
            +
             | 
| 93 | 
            +
            stages = environments.map(&:pipelines).flatten.map(&:stages).flatten
         | 
| 94 | 
            +
            ```
         | 
| 95 | 
            +
             | 
| 96 | 
            +
            ###### Get all the jobs
         | 
| 97 | 
            +
            ```ruby
         | 
| 98 | 
            +
            include GOCD::PIPELINE_CONFIG
         | 
| 99 | 
            +
             | 
| 100 | 
            +
            jobs = environments.map(&:pipelines).flatten.map(&:stages).flatten.map(&:jobs).flatten
         | 
| 101 | 
            +
            ```
         | 
| 102 | 
            +
             | 
| 103 | 
            +
            #### History Fetcher
         | 
| 104 | 
            +
            You can fetch history of a job using the HistoryFetcher APIs
         | 
| 105 | 
            +
            ```ruby
         | 
| 106 | 
            +
            require 'gocd'
         | 
| 107 | 
            +
             | 
| 108 | 
            +
            GOCD.server = GOCD::Server.new 'http://goserverurl.com'
         | 
| 109 | 
            +
            GOCD.credentials = GOCD::Credentials.new 'username', 'password'
         | 
| 110 | 
            +
             | 
| 111 | 
            +
            include GOCD::PIPELINE_CONFIG
         | 
| 112 | 
            +
             | 
| 113 | 
            +
            histories = []
         | 
| 114 | 
            +
            runs = 1000
         | 
| 115 | 
            +
            jobs = environments.map(&:pipelines).flatten.map(&:stages).flatten.map(&:jobs).flatten
         | 
| 116 | 
            +
            jobs.each do |job|
         | 
| 117 | 
            +
              histories << GOCD::HistoryFetcher.fetch_job_history(job, runs)
         | 
| 118 | 
            +
            end
         | 
| 119 | 
            +
            ```
         | 
| 53 120 |  | 
| 54 121 | 
             
            LICENSE
         | 
| 55 122 | 
             
            -------
         | 
    
        data/gocd.gemspec
    CHANGED
    
    
| @@ -7,7 +7,7 @@ module GOCD | |
| 7 7 | 
             
                  attr_reader :name, :pipelines, :pipeline_names
         | 
| 8 8 |  | 
| 9 9 | 
             
                  def initialize(environment)
         | 
| 10 | 
            -
                    @name = environment['name']
         | 
| 10 | 
            +
                    @name = environment['@name']
         | 
| 11 11 | 
             
                    @pipeline_names = to_pipelines(environment["pipelines"] || {})
         | 
| 12 12 | 
             
                  end
         | 
| 13 13 |  | 
| @@ -23,7 +23,7 @@ module GOCD | |
| 23 23 | 
             
                  private
         | 
| 24 24 | 
             
                  def to_pipelines(pipelines)
         | 
| 25 25 | 
             
                    pipes = pipelines["pipeline"] || []
         | 
| 26 | 
            -
                    to_array(pipes).map { |p| p['name'] } unless pipes.nil?
         | 
| 26 | 
            +
                    to_array(pipes).map { |p| p['@name'] } unless pipes.nil?
         | 
| 27 27 | 
             
                  end
         | 
| 28 28 | 
             
                end
         | 
| 29 29 | 
             
              end
         | 
| @@ -9,8 +9,8 @@ module GOCD | |
| 9 9 | 
             
                  def initialize(pipeline, stage, data)
         | 
| 10 10 | 
             
                    @pipeline = pipeline
         | 
| 11 11 | 
             
                    @stage = stage
         | 
| 12 | 
            -
                    @name = data['name']
         | 
| 13 | 
            -
                    @resources = data['resources'].nil? ? [] : to_array(data | 
| 12 | 
            +
                    @name = data['@name']
         | 
| 13 | 
            +
                    @resources = data['resources'].nil? ? [] : to_array(parse_resources(data))
         | 
| 14 14 | 
             
                  end
         | 
| 15 15 |  | 
| 16 16 | 
             
                  def environment=(env)
         | 
| @@ -20,6 +20,23 @@ module GOCD | |
| 20 20 | 
             
                  def pipeline=(new_name)
         | 
| 21 21 | 
             
                    @pipeline = new_name
         | 
| 22 22 | 
             
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  private
         | 
| 25 | 
            +
                  def parse_resources(data)
         | 
| 26 | 
            +
                    res = data['resources']['resource']
         | 
| 27 | 
            +
                    if res.is_a?(Array)
         | 
| 28 | 
            +
                      res.map do |r|
         | 
| 29 | 
            +
                        r.is_a?(Hash) ? filter_xml_specific_keys(r).values : r
         | 
| 30 | 
            +
                      end
         | 
| 31 | 
            +
                    elsif res.is_a?(Hash)
         | 
| 32 | 
            +
                      filter_xml_specific_keys(res).values
         | 
| 33 | 
            +
                    end
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  def filter_xml_specific_keys(res)
         | 
| 37 | 
            +
                    res.delete('@xmlns')
         | 
| 38 | 
            +
                    res
         | 
| 39 | 
            +
                  end
         | 
| 23 40 | 
             
                end
         | 
| 24 41 | 
             
              end
         | 
| 25 42 | 
             
            end
         | 
| @@ -4,12 +4,13 @@ module GOCD | |
| 4 4 | 
             
              module PIPELINE_CONFIG
         | 
| 5 5 | 
             
                class Pipeline
         | 
| 6 6 | 
             
                  include GOCD::PIPELINE_CONFIG
         | 
| 7 | 
            -
                  attr_reader :name, :stages, :template, :environment
         | 
| 7 | 
            +
                  attr_reader :name, :stages, :template, :environment, :params
         | 
| 8 8 |  | 
| 9 9 | 
             
                  def initialize(data)
         | 
| 10 | 
            -
                    @template = data['template']
         | 
| 11 | 
            -
                    @name = data['name']
         | 
| 10 | 
            +
                    @template = data['@template']
         | 
| 11 | 
            +
                    @name = data['@name']
         | 
| 12 12 | 
             
                    @stages = to_stages(data['stage']) || []
         | 
| 13 | 
            +
                    @params = parse_params(data)
         | 
| 13 14 | 
             
                  end
         | 
| 14 15 |  | 
| 15 16 | 
             
                  def has_template?
         | 
| @@ -30,6 +31,20 @@ module GOCD | |
| 30 31 | 
             
                  def to_stages(data)
         | 
| 31 32 | 
             
                    to_array(data).map { |stage| GOCD::PIPELINE_CONFIG::Stage.new(name, stage) } unless data.nil?
         | 
| 32 33 | 
             
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  def parse_params(data)
         | 
| 36 | 
            +
                    params = {}
         | 
| 37 | 
            +
                    return params if (data['params'].nil? || data['params']['param'].nil?)
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                    params_response = data['params']['param']
         | 
| 40 | 
            +
                    if params_response.is_a?(Hash)
         | 
| 41 | 
            +
                      params[params_response['@name']] = params_response['$']
         | 
| 42 | 
            +
                    elsif params_response.is_a?(Array)
         | 
| 43 | 
            +
                      params_response.each { |p| params[p['@name']] = p['$'] }
         | 
| 44 | 
            +
                    end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                    params
         | 
| 47 | 
            +
                  end
         | 
| 33 48 | 
             
                end
         | 
| 34 49 | 
             
              end
         | 
| 35 50 | 
             
            end
         | 
| @@ -19,7 +19,7 @@ module GOCD | |
| 19 19 |  | 
| 20 20 | 
             
                def pipelines
         | 
| 21 21 | 
             
                  pipelines = groups.map { |group| group.pipelines }.flatten
         | 
| 22 | 
            -
                  merge_pipelines_with_templates pipelines | 
| 22 | 
            +
                  merge_pipelines_with_templates pipelines
         | 
| 23 23 | 
             
                end
         | 
| 24 24 |  | 
| 25 25 | 
             
                def templates
         | 
| @@ -53,20 +53,24 @@ module GOCD | |
| 53 53 | 
             
                  end
         | 
| 54 54 | 
             
                end
         | 
| 55 55 |  | 
| 56 | 
            -
                def merge_pipelines_with_templates(pipelines | 
| 57 | 
            -
                   | 
| 58 | 
            -
                   | 
| 56 | 
            +
                def merge_pipelines_with_templates(pipelines)
         | 
| 57 | 
            +
                  pipelines_with_template = pipelines.select { |p| p.has_template? }
         | 
| 58 | 
            +
                  pipelines_with_template.map! do |p|
         | 
| 59 | 
            +
                    template = template_for_pipeline(p)
         | 
| 60 | 
            +
                    next if template.nil?
         | 
| 61 | 
            +
                    template.name = p.name
         | 
| 62 | 
            +
                    template.stages.each { |s| s.pipeline = p.name }
         | 
| 63 | 
            +
                    template
         | 
| 64 | 
            +
                  end.compact!
         | 
| 59 65 |  | 
| 60 | 
            -
                   | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
                  end
         | 
| 69 | 
            -
                  [standalone_pipelines + pipelines_merged_with_templates].flatten.compact
         | 
| 66 | 
            +
                  pipelines_without_template = pipelines.select { |p| !p.has_template? }
         | 
| 67 | 
            +
                  [pipelines_with_template + pipelines_without_template].flatten.compact
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                def template_for_pipeline(pipeline)
         | 
| 71 | 
            +
                  template = templates.select { |t| t.name == pipeline.template }.first
         | 
| 72 | 
            +
                  p "Could not find any template for #{pipeline.name}:#{pipeline.template}" if template.nil?
         | 
| 73 | 
            +
                  template
         | 
| 70 74 | 
             
                end
         | 
| 71 75 | 
             
              end
         | 
| 72 76 | 
             
            end
         | 
| @@ -1,10 +1,10 @@ | |
| 1 | 
            -
            require ' | 
| 1 | 
            +
            require 'cobravsmongoose'
         | 
| 2 2 |  | 
| 3 3 | 
             
            module GOCD
         | 
| 4 4 | 
             
              module PIPELINE_CONFIG
         | 
| 5 5 | 
             
                class PipelineConfigRepository
         | 
| 6 6 | 
             
                  def self.fetch_config
         | 
| 7 | 
            -
                     | 
| 7 | 
            +
                    CobraVsMongoose.xml_to_hash(`curl -s -k -u #{GOCD.credentials.curl_credentials} #{GOCD.server.url}/go/api/admin/config/current.xml`)
         | 
| 8 8 | 
             
                  end
         | 
| 9 9 | 
             
                end
         | 
| 10 10 | 
             
              end
         | 
    
        data/lib/gocd/version.rb
    CHANGED
    
    
| @@ -13,7 +13,7 @@ end | |
| 13 13 | 
             
            RSpec.describe GOCD::HistoryFetcher, 'history' do
         | 
| 14 14 |  | 
| 15 15 | 
             
              response = "cruise_agent,cruise_job_duration,cruise_job_id,cruise_job_result,cruise_pipeline_counter,cruise_pipeline_label,cruise_stage_counter,cruise_timestamp_01_scheduled,cruise_timestamp_02_assigned,cruise_timestamp_03_preparing,cruise_timestamp_04_building,cruise_timestamp_05_completing,cruise_timestamp_06_completed,tests_failed_count,tests_ignored_count,tests_total_count,tests_total_duration\nAgent1,320,826882,Passed,10314,pipe-10314-job-5621,1,2017-02-23T14:49:17Z,2017-02-23T14:49:22Z,2017-02-23T14:49:33Z,2017-02-23T14:49:41Z,2017-02-23T14:54:39Z,2017-02-23T14:55:02Z,0,0,4218,84.882\n"
         | 
| 16 | 
            -
              job = GOCD::PIPELINE_CONFIG::Job.new('Pipeline', 'stage', {'name' => 'job'})
         | 
| 16 | 
            +
              job = GOCD::PIPELINE_CONFIG::Job.new('Pipeline', 'stage', {'@name' => 'job'})
         | 
| 17 17 |  | 
| 18 18 | 
             
              before(:each) do
         | 
| 19 19 | 
             
                setup_credential_and_server
         | 
| @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            require './lib/gocd/pipeline_config/pipeline_group'
         | 
| 2 | 
            -
            require ' | 
| 2 | 
            +
            require 'cobravsmongoose'
         | 
| 3 3 |  | 
| 4 4 | 
             
            RSpec.describe GOCD::PIPELINE_CONFIG::Environment, 'Environment' do
         | 
| 5 5 | 
             
              xml_response = <<-PipelineGroup
         | 
| @@ -16,7 +16,7 @@ RSpec.describe GOCD::PIPELINE_CONFIG::Environment, 'Environment' do | |
| 16 16 | 
             
              PipelineGroup
         | 
| 17 17 |  | 
| 18 18 | 
             
              it 'should parse environment' do
         | 
| 19 | 
            -
                response =  | 
| 19 | 
            +
                response = CobraVsMongoose.xml_to_hash(xml_response)
         | 
| 20 20 | 
             
                environment = GOCD::PIPELINE_CONFIG::Environment.new response['environment']
         | 
| 21 21 |  | 
| 22 22 | 
             
                expect(environment.name).to eq 'Env'
         | 
| @@ -26,7 +26,7 @@ RSpec.describe GOCD::PIPELINE_CONFIG::Environment, 'Environment' do | |
| 26 26 | 
             
              end
         | 
| 27 27 |  | 
| 28 28 | 
             
              it 'should update environment in pipeline' do
         | 
| 29 | 
            -
                response =  | 
| 29 | 
            +
                response = CobraVsMongoose.xml_to_hash(xml_response)
         | 
| 30 30 | 
             
                environment = GOCD::PIPELINE_CONFIG::Environment.new response['environment']
         | 
| 31 31 |  | 
| 32 32 | 
             
                pipeline = instance_double('pipeline')
         | 
| @@ -1,18 +1,18 @@ | |
| 1 1 | 
             
            require './lib/gocd/pipeline_config/pipeline_group'
         | 
| 2 | 
            -
            require ' | 
| 2 | 
            +
            require 'cobravsmongoose'
         | 
| 3 3 |  | 
| 4 4 | 
             
            RSpec.describe GOCD::PIPELINE_CONFIG::Job, 'Job' do
         | 
| 5 | 
            -
              xml_response = <<- | 
| 5 | 
            +
              xml_response = <<-Job
         | 
| 6 6 | 
             
                <job name="flavor1_spec" timeout="60">
         | 
| 7 7 | 
             
                    <resources>
         | 
| 8 8 | 
             
                        <resource>mac</resource>
         | 
| 9 9 | 
             
                        <resource>spec</resource>
         | 
| 10 10 | 
             
                    </resources>
         | 
| 11 11 | 
             
                </job>
         | 
| 12 | 
            -
               | 
| 12 | 
            +
              Job
         | 
| 13 13 |  | 
| 14 14 | 
             
              it 'should parse job' do
         | 
| 15 | 
            -
                response =  | 
| 15 | 
            +
                response = CobraVsMongoose.xml_to_hash(xml_response)
         | 
| 16 16 | 
             
                job = GOCD::PIPELINE_CONFIG::Job.new 'MyAwesomePipeline', 'spec', response['job']
         | 
| 17 17 |  | 
| 18 18 | 
             
                expect(job.resources.size).to eq 2
         | 
| @@ -20,4 +20,21 @@ RSpec.describe GOCD::PIPELINE_CONFIG::Job, 'Job' do | |
| 20 20 | 
             
                expect(job.pipeline).to eq 'MyAwesomePipeline'
         | 
| 21 21 | 
             
                expect(job.stage).to eq 'spec'
         | 
| 22 22 | 
             
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              it 'should parse job with resources as array' do
         | 
| 25 | 
            +
                xml_response = <<-Job
         | 
| 26 | 
            +
                <job name="flavor1_spec" timeout="60" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         | 
| 27 | 
            +
                    <resources>
         | 
| 28 | 
            +
                        <resource>mac</resource>
         | 
| 29 | 
            +
                        <resource>spec</resource>
         | 
| 30 | 
            +
                    </resources>
         | 
| 31 | 
            +
                </job>
         | 
| 32 | 
            +
                Job
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                response = CobraVsMongoose.xml_to_hash(xml_response)
         | 
| 35 | 
            +
                job = GOCD::PIPELINE_CONFIG::Job.new 'MyAwesomePipeline', 'spec', response['job']
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                expect(job.resources.size).to eq 2
         | 
| 38 | 
            +
                expect(job.resources.first).to eq 'mac'
         | 
| 39 | 
            +
              end
         | 
| 23 40 | 
             
            end
         | 
| @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            require './lib/gocd/pipeline_config/pipeline_group'
         | 
| 2 | 
            -
            require ' | 
| 2 | 
            +
            require 'cobravsmongoose'
         | 
| 3 3 |  | 
| 4 4 | 
             
            RSpec.describe GOCD::PIPELINE_CONFIG::PipelineGroup, 'PipelineGroup' do
         | 
| 5 5 | 
             
              pipeline_group_xml = <<-PipelineGroup
         | 
| @@ -42,7 +42,7 @@ RSpec.describe GOCD::PIPELINE_CONFIG::PipelineGroup, 'PipelineGroup' do | |
| 42 42 | 
             
              PipelineGroup
         | 
| 43 43 |  | 
| 44 44 | 
             
              it 'should parse pipeline group' do
         | 
| 45 | 
            -
                response =  | 
| 45 | 
            +
                response = CobraVsMongoose.xml_to_hash(pipeline_group_xml)
         | 
| 46 46 | 
             
                pipeline_group = GOCD::PIPELINE_CONFIG::PipelineGroup.new response['pipelines']
         | 
| 47 47 |  | 
| 48 48 | 
             
                expect(pipeline_group.name).to eq 'MyPipelineGroup'
         | 
| @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            require './lib/gocd/pipeline_config/pipeline_group'
         | 
| 2 | 
            -
            require ' | 
| 2 | 
            +
            require 'cobravsmongoose'
         | 
| 3 3 |  | 
| 4 4 | 
             
            RSpec.describe GOCD::PIPELINE_CONFIG::Pipeline, 'Pipeline' do
         | 
| 5 5 | 
             
              xml_response = <<-PipelineGroup
         | 
| @@ -45,15 +45,16 @@ RSpec.describe GOCD::PIPELINE_CONFIG::Pipeline, 'Pipeline' do | |
| 45 45 | 
             
              PipelineGroup
         | 
| 46 46 |  | 
| 47 47 | 
             
              it 'should parse pipeline' do
         | 
| 48 | 
            -
                response =  | 
| 48 | 
            +
                response = CobraVsMongoose.xml_to_hash(xml_response)
         | 
| 49 49 | 
             
                pipeline = GOCD::PIPELINE_CONFIG::Pipeline.new response['pipeline']
         | 
| 50 50 |  | 
| 51 51 | 
             
                expect(pipeline.name).to eq 'MyAwesomePipeline'
         | 
| 52 52 | 
             
                expect(pipeline.stages.size).to eq 2
         | 
| 53 | 
            +
                expect(pipeline.params.keys.size).to eq 0
         | 
| 53 54 | 
             
              end
         | 
| 54 55 |  | 
| 55 56 | 
             
              it 'should parse pipeline created from template' do
         | 
| 56 | 
            -
                response =  | 
| 57 | 
            +
                response = CobraVsMongoose.xml_to_hash(template_pipline)
         | 
| 57 58 | 
             
                pipeline = GOCD::PIPELINE_CONFIG::Pipeline.new response['pipeline']
         | 
| 58 59 |  | 
| 59 60 | 
             
                expect(pipeline.name).to eq 'MyAwesomePipeline'
         | 
| @@ -69,4 +70,38 @@ RSpec.describe GOCD::PIPELINE_CONFIG::Pipeline, 'Pipeline' do | |
| 69 70 |  | 
| 70 71 | 
             
                pipeline.environment = 'Env'
         | 
| 71 72 | 
             
              end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
              it 'should parse pipeline params' do
         | 
| 75 | 
            +
                pipeline_with_params = <<-Pipeline
         | 
| 76 | 
            +
                <pipeline name="ChildPipeline" isLocked="false" template="pipeline_template">
         | 
| 77 | 
            +
                  <params>
         | 
| 78 | 
            +
                    <param name="MODULE_NAME">Module1</param>
         | 
| 79 | 
            +
                    <param name="UPSTREAM_PIPELINE">ParentPipeline</param>
         | 
| 80 | 
            +
                  </params>
         | 
| 81 | 
            +
                </pipeline>
         | 
| 82 | 
            +
                Pipeline
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                response = CobraVsMongoose.xml_to_hash(pipeline_with_params)
         | 
| 85 | 
            +
                pipeline = GOCD::PIPELINE_CONFIG::Pipeline.new response['pipeline']
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                expect(pipeline.params.keys.size).to eq 2
         | 
| 88 | 
            +
                expect(pipeline.params['MODULE_NAME']).to eq 'Module1'
         | 
| 89 | 
            +
                expect(pipeline.params['UPSTREAM_PIPELINE']).to eq 'ParentPipeline'
         | 
| 90 | 
            +
              end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
              it 'should parse pipeline with one param' do
         | 
| 93 | 
            +
                pipeline_with_params = <<-Pipeline
         | 
| 94 | 
            +
                <pipeline name="ChildPipeline" isLocked="false" template="pipeline_template">
         | 
| 95 | 
            +
                  <params>
         | 
| 96 | 
            +
                    <param name="MODULE_NAME">Module1</param>
         | 
| 97 | 
            +
                  </params>
         | 
| 98 | 
            +
                </pipeline>
         | 
| 99 | 
            +
                Pipeline
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                response = CobraVsMongoose.xml_to_hash(pipeline_with_params)
         | 
| 102 | 
            +
                pipeline = GOCD::PIPELINE_CONFIG::Pipeline.new response['pipeline']
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                expect(pipeline.params.keys.size).to eq 1
         | 
| 105 | 
            +
                expect(pipeline.params['MODULE_NAME']).to eq 'Module1'
         | 
| 106 | 
            +
              end
         | 
| 72 107 | 
             
            end
         | 
| @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            require './lib/gocd/pipeline_config/pipeline_group'
         | 
| 2 | 
            -
            require ' | 
| 2 | 
            +
            require 'cobravsmongoose'
         | 
| 3 3 |  | 
| 4 4 | 
             
            RSpec.describe GOCD::PIPELINE_CONFIG::Stage, 'Stage' do
         | 
| 5 5 | 
             
              xml_response = <<-PipelineGroup
         | 
| @@ -22,7 +22,7 @@ RSpec.describe GOCD::PIPELINE_CONFIG::Stage, 'Stage' do | |
| 22 22 | 
             
              PipelineGroup
         | 
| 23 23 |  | 
| 24 24 | 
             
              it 'should parse job' do
         | 
| 25 | 
            -
                response =  | 
| 25 | 
            +
                response = CobraVsMongoose.xml_to_hash(xml_response)
         | 
| 26 26 | 
             
                stage = GOCD::PIPELINE_CONFIG::Stage.new 'MyAwesomePipeline', response['job']
         | 
| 27 27 |  | 
| 28 28 | 
             
                expect(stage.name).to eq 'build'
         | 
| @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            require './lib/gocd/pipeline_config/template'
         | 
| 2 | 
            -
            require ' | 
| 2 | 
            +
            require 'cobravsmongoose'
         | 
| 3 3 |  | 
| 4 4 | 
             
            RSpec.describe GOCD::PIPELINE_CONFIG::Template, 'Template' do
         | 
| 5 5 | 
             
              xml_response = <<-Template
         | 
| @@ -20,7 +20,7 @@ RSpec.describe GOCD::PIPELINE_CONFIG::Template, 'Template' do | |
| 20 20 | 
             
              Template
         | 
| 21 21 |  | 
| 22 22 | 
             
              it 'should parse template' do
         | 
| 23 | 
            -
                response =  | 
| 23 | 
            +
                response = CobraVsMongoose.xml_to_hash(xml_response)
         | 
| 24 24 | 
             
                pipeline = GOCD::PIPELINE_CONFIG::Template.new response['templates']['pipeline']
         | 
| 25 25 |  | 
| 26 26 | 
             
                expect(pipeline.name).to eq 'MyPipeline'
         | 
    
        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.2. | 
| 4 | 
            +
              version: 1.2.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: 2017- | 
| 11 | 
            +
            date: 2017-11-16 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         | 
| @@ -89,6 +89,7 @@ files: | |
| 89 89 | 
             
            - ".gitignore"
         | 
| 90 90 | 
             
            - ".rspec"
         | 
| 91 91 | 
             
            - ".ruby-version"
         | 
| 92 | 
            +
            - ".travis.yml"
         | 
| 92 93 | 
             
            - Gemfile
         | 
| 93 94 | 
             
            - Gemfile.lock
         | 
| 94 95 | 
             
            - LICENSE.txt
         | 
| @@ -150,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 150 151 | 
             
                  version: '0'
         | 
| 151 152 | 
             
            requirements: []
         | 
| 152 153 | 
             
            rubyforge_project: 
         | 
| 153 | 
            -
            rubygems_version: 2. | 
| 154 | 
            +
            rubygems_version: 2.6.13
         | 
| 154 155 | 
             
            signing_key: 
         | 
| 155 156 | 
             
            specification_version: 4
         | 
| 156 157 | 
             
            summary: Get info from gocd using its apis
         |