vx-builder 0.3.2 → 0.3.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/lib/vx/builder/build_configuration.rb +14 -0
- data/lib/vx/builder/deploy_builder.rb +1 -1
- data/lib/vx/builder/matrix_builder.rb +2 -1
- data/lib/vx/builder/version.rb +1 -1
- data/spec/lib/builder/build_configuration_spec.rb +20 -0
- data/spec/lib/builder/deploy_builder_spec.rb +14 -0
- data/spec/lib/builder/matrix_builder_spec.rb +8 -0
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5dfe8821a2dbcc3ee1ffcaab8735c41bafacd2b4
         | 
| 4 | 
            +
              data.tar.gz: 570fe0d7926a01cb815cfb17f96ceae9a7f5598a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 394f85a75f76e416b51aa311b0a3425bca20733e354cd26b6388a54c0e13311eaaef8992b2ebdfd6d0d7f47f8382ad6423de643051fe98d10f8f8ad701e86c1e
         | 
| 7 | 
            +
              data.tar.gz: 330d274952a14f064cae171fa88586d6b915223ce3be5b9231a893e72a889aa0fcb929f2b4e0415d22aa792a89d719e373e2330b0444e5d1b09676050a8bd192
         | 
| @@ -8,6 +8,14 @@ module Vx | |
| 8 8 | 
             
              module Builder
         | 
| 9 9 | 
             
                class BuildConfiguration
         | 
| 10 10 |  | 
| 11 | 
            +
                  REQUIRED_KEYS = %w{
         | 
| 12 | 
            +
                    rvm
         | 
| 13 | 
            +
                    scala
         | 
| 14 | 
            +
                    jdk
         | 
| 15 | 
            +
                    language
         | 
| 16 | 
            +
                    script
         | 
| 17 | 
            +
                  }
         | 
| 18 | 
            +
             | 
| 11 19 | 
             
                  ATTRIBUTES = %w{
         | 
| 12 20 | 
             
                    rvm
         | 
| 13 21 | 
             
                    scala
         | 
| @@ -57,6 +65,12 @@ module Vx | |
| 57 65 | 
             
                    build_attributes new_attributes
         | 
| 58 66 | 
             
                  end
         | 
| 59 67 |  | 
| 68 | 
            +
                  def any?
         | 
| 69 | 
            +
                    REQUIRED_KEYS.any? do |key|
         | 
| 70 | 
            +
                      attributes[key].any?
         | 
| 71 | 
            +
                    end
         | 
| 72 | 
            +
                  end
         | 
| 73 | 
            +
             | 
| 60 74 | 
             
                  def matrix_attributes
         | 
| 61 75 | 
             
                    @matrix_attributes.inject({}) do |a,pair|
         | 
| 62 76 | 
             
                      k,v = pair
         | 
| @@ -14,7 +14,7 @@ module Vx | |
| 14 14 |  | 
| 15 15 | 
             
                  def initialize(matrix_builder, options = {})
         | 
| 16 16 | 
             
                    @base_build_configuration    = matrix_builder.build_configuration
         | 
| 17 | 
            -
                    @matrix_build_configuration  = matrix_builder.build.first
         | 
| 17 | 
            +
                    @matrix_build_configuration  = matrix_builder.build.first || matrix_builder.build_configuration
         | 
| 18 18 | 
             
                    @branch                      = options[:branch]
         | 
| 19 19 | 
             
                  end
         | 
| 20 20 |  | 
| @@ -19,10 +19,11 @@ module Vx | |
| 19 19 | 
             
                  def build
         | 
| 20 20 | 
             
                    @build ||= begin
         | 
| 21 21 | 
             
                      new_attributes = build_configuration.to_hash.dup
         | 
| 22 | 
            -
                      attributes_for_new_build_configurations_with_merged_env.map do |matrix_attributes|
         | 
| 22 | 
            +
                      build_configurations = attributes_for_new_build_configurations_with_merged_env.map do |matrix_attributes|
         | 
| 23 23 | 
             
                        new_attributes.merge!(matrix_attributes)
         | 
| 24 24 | 
             
                        BuildConfiguration.new new_attributes, matrix_attributes
         | 
| 25 25 | 
             
                      end
         | 
| 26 | 
            +
                      build_configurations.select{|bc| bc.any? }
         | 
| 26 27 | 
             
                    end
         | 
| 27 28 | 
             
                  end
         | 
| 28 29 |  | 
    
        data/lib/vx/builder/version.rb
    CHANGED
    
    
| @@ -78,4 +78,24 @@ describe Vx::Builder::BuildConfiguration do | |
| 78 78 | 
             
                  expect(config).to be_deploy_modules
         | 
| 79 79 | 
             
                end
         | 
| 80 80 | 
             
              end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
              context "any?" do
         | 
| 83 | 
            +
                subject { config.any? }
         | 
| 84 | 
            +
                %w{ rvm scala jdk language script }.each do |required_key|
         | 
| 85 | 
            +
                  context "when key #{required_key} exists" do
         | 
| 86 | 
            +
                    let(:content) { {
         | 
| 87 | 
            +
                      required_key => "value"
         | 
| 88 | 
            +
                    } }
         | 
| 89 | 
            +
                    it { should be }
         | 
| 90 | 
            +
                  end
         | 
| 91 | 
            +
                end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                context "when required keys does not exists" do
         | 
| 94 | 
            +
                  let(:content) { {
         | 
| 95 | 
            +
                    "before_script" => "value",
         | 
| 96 | 
            +
                    "deploy"        => "value"
         | 
| 97 | 
            +
                  } }
         | 
| 98 | 
            +
                  it { should_not be }
         | 
| 99 | 
            +
                end
         | 
| 100 | 
            +
              end
         | 
| 81 101 | 
             
            end
         | 
| @@ -61,6 +61,20 @@ describe Vx::Builder::DeployBuilder do | |
| 61 61 | 
             
                  expect(config.first).to be_deploy_modules
         | 
| 62 62 | 
             
                end
         | 
| 63 63 |  | 
| 64 | 
            +
                it "should create build_configurations when matrix_build_configurations is empty" do
         | 
| 65 | 
            +
                  empty_config = Vx::Builder::BuildConfiguration.new("before_install" => "value", "deploy" => { "shell" => "value" })
         | 
| 66 | 
            +
                  matrix = Vx::Builder.matrix empty_config
         | 
| 67 | 
            +
                  deploy = Vx::Builder.deploy matrix
         | 
| 68 | 
            +
                  config = deploy.build
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  expect(matrix.build).to be_empty
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                  expect(config).to have(1).item
         | 
| 73 | 
            +
                  expect(config.first).to_not be_deploy
         | 
| 74 | 
            +
                  expect(config.first).to be_deploy_modules
         | 
| 75 | 
            +
                  expect(config.first.before_install).to eq ["value"]
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
             | 
| 64 78 | 
             
                it "should be empty if not valid" do
         | 
| 65 79 | 
             
                  deploy = described_class.new matrix, branch: "production"
         | 
| 66 80 | 
             
                  expect(deploy.build).to be_empty
         | 
| @@ -48,6 +48,14 @@ describe Vx::Builder::MatrixBuilder do | |
| 48 48 | 
             
                  expect(subject.map(&:before_install).flatten).to eq ["echo before_install"] * 12
         | 
| 49 49 | 
             
                end
         | 
| 50 50 |  | 
| 51 | 
            +
                context "when empty configuration" do
         | 
| 52 | 
            +
                  let(:attributes) { {
         | 
| 53 | 
            +
                    "deploy" => "value"
         | 
| 54 | 
            +
                  } }
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                  it { should be_empty }
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
             | 
| 51 59 | 
             
                context "without any matrix keys" do
         | 
| 52 60 | 
             
                  let(:attributes) { {
         | 
| 53 61 | 
             
                    "script" => %w{ /bin/true },
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: vx-builder
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.3. | 
| 4 | 
            +
              version: 0.3.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Dmitry Galinsky
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-06- | 
| 11 | 
            +
            date: 2014-06-16 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: vx-common
         |