soloist 0.0.7 → 0.0.8
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.
- data/MIT-LICENSE +20 -0
- data/README.markdown +6 -2
- data/lib/soloist/chef_config_generator.rb +10 -8
- data/lib/soloist/version.rb +1 -1
- data/spec/chef_config_generator_spec.rb +38 -4
- metadata +5 -4
    
        data/MIT-LICENSE
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            # Copyright (c) 2010, 2011 Matthew Kocher
         | 
| 2 | 
            +
            #  
         | 
| 3 | 
            +
            # Permission is hereby granted, free of charge, to any person obtaining 
         | 
| 4 | 
            +
            # a copy of this software and associated documentation files (the 
         | 
| 5 | 
            +
            # "Software"), to deal in the Software without restriction, including 
         | 
| 6 | 
            +
            # without limitation the rights to use, copy, modify, merge, publish, 
         | 
| 7 | 
            +
            # distribute, sublicense, and/or sell copies of the Software, and to 
         | 
| 8 | 
            +
            # permit persons to whom the Software is furnished to do so, subject to 
         | 
| 9 | 
            +
            # the following conditions: 
         | 
| 10 | 
            +
            #  
         | 
| 11 | 
            +
            # The above copyright notice and this permission notice shall be 
         | 
| 12 | 
            +
            # included in all copies or substantial portions of the Software. 
         | 
| 13 | 
            +
            #  
         | 
| 14 | 
            +
            # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
         | 
| 15 | 
            +
            # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
         | 
| 16 | 
            +
            # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
         | 
| 17 | 
            +
            # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
         | 
| 18 | 
            +
            # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
         | 
| 19 | 
            +
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
         | 
| 20 | 
            +
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.markdown
    CHANGED
    
    | @@ -10,7 +10,7 @@ Soloist is a script packaged as a gem which when run recurses up the file tree l | |
| 10 10 | 
             
            # That's exactly what I've always wanted! How do I use it?
         | 
| 11 11 | 
             
            * (sudo) gem install soloist
         | 
| 12 12 | 
             
            * create a directory to store your cookbooks in, and get a cookbook: 
         | 
| 13 | 
            -
            	sh -c 'mkdir -p chef/cookbooks/pivotal_workstation && cd chef/cookbooks/pivotal_workstation &&  curl -L http://github.com/ | 
| 13 | 
            +
            	sh -c 'mkdir -p chef/cookbooks/pivotal_workstation && cd chef/cookbooks/pivotal_workstation &&  curl -L http://github.com/pivotal/pivotal_workstation/tarball/master |  gunzip | tar xvf - --strip=1'
         | 
| 14 14 | 
             
            * create your soloistrc file in the root of your project.
         | 
| 15 15 |  | 
| 16 16 | 
             
            # What if I'm just setting up my own machine, and have many projects?
         | 
| @@ -91,4 +91,8 @@ and a recipe list of | |
| 91 91 | 
             
            	[
         | 
| 92 92 | 
             
            	  "pivotal_workstation::ack", 
         | 
| 93 93 | 
             
            	  "production::foo"
         | 
| 94 | 
            -
            	]
         | 
| 94 | 
            +
            	]
         | 
| 95 | 
            +
            	
         | 
| 96 | 
            +
            License
         | 
| 97 | 
            +
            =======
         | 
| 98 | 
            +
            Soloist is MIT Licensed.  See MIT-LICENSE for details.
         | 
| @@ -10,14 +10,16 @@ class ChefConfigGenerator | |
| 10 10 | 
             
              def merge_env_variable_switches
         | 
| 11 11 | 
             
                return unless @hash["env_variable_switches"]
         | 
| 12 12 | 
             
                @hash["env_variable_switches"].keys.each do |variable|
         | 
| 13 | 
            -
                   | 
| 14 | 
            -
             | 
| 15 | 
            -
                     | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
                     | 
| 20 | 
            -
             | 
| 13 | 
            +
                  ENV[variable] && ENV[variable].split(',').each do |env_variable_value|
         | 
| 14 | 
            +
                    sub_hash = @hash["env_variable_switches"][variable][env_variable_value]
         | 
| 15 | 
            +
                    if sub_hash && sub_hash["recipes"]
         | 
| 16 | 
            +
                      @hash["recipes"] ||= []
         | 
| 17 | 
            +
                      @hash["recipes"] = (@hash["recipes"] + sub_hash["recipes"]).uniq
         | 
| 18 | 
            +
                    end
         | 
| 19 | 
            +
                    if sub_hash && sub_hash["cookbook_paths"]
         | 
| 20 | 
            +
                      @hash["cookbook_paths"] ||= []
         | 
| 21 | 
            +
                      @hash["cookbook_paths"] = (@hash["cookbook_paths"] + sub_hash["cookbook_paths"]).uniq
         | 
| 22 | 
            +
                    end
         | 
| 21 23 | 
             
                  end
         | 
| 22 24 | 
             
                end
         | 
| 23 25 | 
             
              end
         | 
    
        data/lib/soloist/version.rb
    CHANGED
    
    
| @@ -98,6 +98,10 @@ env_variable_switches: | |
| 98 98 |  | 
| 99 99 | 
             
              describe "environment variable merging" do
         | 
| 100 100 | 
             
                before do
         | 
| 101 | 
            +
                  FileUtils.stub(:pwd).and_return("/")
         | 
| 102 | 
            +
                end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                it "merges in if the variable is set to the the value" do
         | 
| 101 105 | 
             
                  @config = <<-CONFIG
         | 
| 102 106 | 
             
            cookbook_paths:
         | 
| 103 107 | 
             
            - ./chef/cookbooks/
         | 
| @@ -111,10 +115,6 @@ env_variable_switches: | |
| 111 115 | 
             
                  recipes:
         | 
| 112 116 | 
             
                  - pivotal_dev::foo
         | 
| 113 117 | 
             
                  CONFIG
         | 
| 114 | 
            -
                  FileUtils.stub(:pwd).and_return("/")
         | 
| 115 | 
            -
                end
         | 
| 116 | 
            -
             | 
| 117 | 
            -
                it "merges in if the variable is set to the the value" do
         | 
| 118 118 | 
             
                  ENV["RACK_ENV"]="development"
         | 
| 119 119 | 
             
                  @generator = ChefConfigGenerator.new(@config, "../..")
         | 
| 120 120 | 
             
                  @generator.cookbook_paths.should == [
         | 
| @@ -127,6 +127,40 @@ env_variable_switches: | |
| 127 127 | 
             
                    ]
         | 
| 128 128 | 
             
                end
         | 
| 129 129 |  | 
| 130 | 
            +
                it "splits the value on comma and applies all matching" do
         | 
| 131 | 
            +
                  ENV["ROLES"]="application,database"
         | 
| 132 | 
            +
                  @config = <<-CONFIG
         | 
| 133 | 
            +
            cookbook_paths:
         | 
| 134 | 
            +
            - ./chef/cookbooks/
         | 
| 135 | 
            +
            recipes:
         | 
| 136 | 
            +
            - pivotal_workstation::ack
         | 
| 137 | 
            +
            env_variable_switches:
         | 
| 138 | 
            +
              ROLES:
         | 
| 139 | 
            +
                application:
         | 
| 140 | 
            +
                  cookbook_paths:
         | 
| 141 | 
            +
                  - ./chef/app_cookbooks/
         | 
| 142 | 
            +
                  recipes:
         | 
| 143 | 
            +
                  - pivotal_app::application
         | 
| 144 | 
            +
                database:
         | 
| 145 | 
            +
                  cookbook_paths:
         | 
| 146 | 
            +
                  - ./chef/db_cookbooks/
         | 
| 147 | 
            +
                  recipes:
         | 
| 148 | 
            +
                  - pivotal_db::database
         | 
| 149 | 
            +
                  CONFIG
         | 
| 150 | 
            +
                  @generator = ChefConfigGenerator.new(@config, "../..")
         | 
| 151 | 
            +
                  @generator.cookbook_paths.should =~ [
         | 
| 152 | 
            +
                    "//../.././chef/cookbooks/",
         | 
| 153 | 
            +
                    "//../.././chef/app_cookbooks/",
         | 
| 154 | 
            +
                    "//../.././chef/db_cookbooks/"
         | 
| 155 | 
            +
                    ]
         | 
| 156 | 
            +
                  @generator.json_hash["recipes"].should =~ [
         | 
| 157 | 
            +
                    "pivotal_workstation::ack", 
         | 
| 158 | 
            +
                    "pivotal_app::application",
         | 
| 159 | 
            +
                    "pivotal_db::database",
         | 
| 160 | 
            +
                    ]
         | 
| 161 | 
            +
                end
         | 
| 162 | 
            +
             | 
| 163 | 
            +
             | 
| 130 164 | 
             
                it "can deal with only having environment switched recipes/cookbooks" do
         | 
| 131 165 | 
             
                  config = <<-CONFIG
         | 
| 132 166 | 
             
            env_variable_switches:
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: soloist
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 15
         | 
| 5 5 | 
             
              prerelease: false
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 0
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.0. | 
| 9 | 
            +
              - 8
         | 
| 10 | 
            +
              version: 0.0.8
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Matthew Kocher
         | 
| @@ -15,7 +15,7 @@ autorequire: | |
| 15 15 | 
             
            bindir: bin
         | 
| 16 16 | 
             
            cert_chain: []
         | 
| 17 17 |  | 
| 18 | 
            -
            date: 2011- | 
| 18 | 
            +
            date: 2011-04-19 00:00:00 -07:00
         | 
| 19 19 | 
             
            default_executable: 
         | 
| 20 20 | 
             
            dependencies: 
         | 
| 21 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -64,6 +64,7 @@ files: | |
| 64 64 | 
             
            - .rvmrc
         | 
| 65 65 | 
             
            - Gemfile
         | 
| 66 66 | 
             
            - Gemfile.lock
         | 
| 67 | 
            +
            - MIT-LICENSE
         | 
| 67 68 | 
             
            - README.markdown
         | 
| 68 69 | 
             
            - Rakefile
         | 
| 69 70 | 
             
            - bin/soloist
         |