Sha256: fc53c384af56d3b91d4a3492aab3cd2a69a8c43ba8e4fb331586be3b5218406c

Contents?: true

Size: 1.92 KB

Versions: 28

Compression:

Stored size: 1.92 KB

Contents

module Context
  module DeployHelper
    def get_context_folder(context, folder)
      File.join(context.context_folder, folder)
    end

    def build_folder(context)
      get_context_folder(context, 'build')
    end
  
    def contexts_container(context)
      get_context_folder(context, 'contexts')
    end
    
    def chef_exec(commands)
      system("chef exec #{commands.join(' ')}")
    end
    
    def git(commands)
      chef_exec(['git'] + commands)
    end
    
    def gem(commands)
      chef_exec(['gem'] + commands)
    end
    
    def rake(commands)
      chef_exec(['rake'] + commands)
    end
    
    def cucumber(commands = [])
      chef_exec(['cucumber'] + commands)
    end

    def execute_action(context, action)
      state_action = if action.nil?
        context.cycle
        false
      else
        case action
        when 'once'
          puts "\nExecute only once\n"
          context.cycle
          false
        when 'always'
          puts "\nAlways in execution\n"
          while true do
            context.cycle
          end
          false
        when 'bump'
          puts "\nBump minor version\n"
          context.patch_bump
          false
        when 'release'
          puts "\nBump major version\n"
          context.minor_bump
          false
        when 'upgrade'
          puts "\nBump major version\n"
          context.major_bump
          false
        when 'test'
          puts "\nExecute tests\n"
          context.cucumber_test(context)
          false
        when 'reset'
          puts "\nReset versionning\n"
          system('rake')
          # context.cucumber_test(deployer)
          false
        else
          puts "Unknown setting #{action}"
          false
        end
      end
      if state_action
        puts "Action #{action} executed correctly in context #{context}"
      else
        abort("Failed to execute action #{action} in context #{context}")
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
deploy-context-2.1.19 lib/deploy-context/context/deploy.rb
deploy-context-2.1.18.1.gdf72b60 lib/deploy-context/context/deploy.rb
deploy-context-2.1.18 lib/deploy-context/context/deploy.rb
deploy-context-2.1.17 lib/deploy-context/context/deploy.rb
deploy-context-2.1.16 lib/deploy-context/context/deploy.rb
deploy-context-2.1.14.1.gddf0839 lib/deploy-context/context/deploy.rb
deploy-context-2.1.14 lib/deploy-context/context/deploy.rb
deploy-context-2.1.13 lib/deploy-context/context/deploy.rb
deploy-context-2.1.12 lib/deploy-context/context/deploy.rb
deploy-context-2.1.11 lib/deploy-context/context/deploy.rb
deploy-context-2.1.10 lib/deploy-context/context/deploy.rb
deploy-context-2.1.9 lib/deploy-context/context/deploy.rb
deploy-context-2.1.8 lib/deploy-context/context/deploy.rb
deploy-context-2.1.7 lib/deploy-context/context/deploy.rb
deploy-context-2.1.6.1.g45c69eb lib/deploy-context/context/deploy.rb
deploy-context-2.1.6 lib/deploy-context/context/deploy.rb
deploy-context-2.1.5.1.gf2bec3a lib/deploy-context/context/deploy.rb
deploy-context-2.1.5 lib/deploy-context/context/deploy.rb
deploy-context-2.1.4.1.g36d6011 lib/deploy-context/context/deploy.rb
deploy-context-2.1.4 lib/deploy-context/context/deploy.rb