Sha256: e9484f0e8a647d705b40a5b4d4b2fc9839984d35e931d49d973dbb7b03161ff2

Contents?: true

Size: 1.94 KB

Versions: 25

Compression:

Stored size: 1.94 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
          true
        when 'always'
          puts "\nAlways in execution\n"
          while true do
            context.cycle
          end
          true
        when 'bump'
          puts "\nBump minor version\n"
          context.patch_bump
          true
        when 'release'
          puts "\nBump major version\n"
          context.minor_bump
          true
        when 'upgrade'
          puts "\nBump major version\n"
          context.major_bump
          true
        when 'test'
          puts "\nExecute tests\n"
          context.cucumber_test(context)
          true
        when 'reset'
          puts "\nReset versionning\n"
          system('rake')
          # context.cucumber_test(deployer)
          true
        else
          puts "Unknown setting #{action}"
          false
        end
      end
      context.commit
      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

25 entries across 25 versions & 1 rubygems

Version Path
deploy-context-2.1.32 lib/deploy-context/context/deploy.rb
deploy-context-2.1.31.1.g6ccfd57 lib/deploy-context/context/deploy.rb
deploy-context-2.1.31 lib/deploy-context/context/deploy.rb
deploy-context-2.1.30.1.gdf915e9 lib/deploy-context/context/deploy.rb
deploy-context-2.1.30 lib/deploy-context/context/deploy.rb
deploy-context-2.1.29.1.gb63f262 lib/deploy-context/context/deploy.rb
deploy-context-2.1.29 lib/deploy-context/context/deploy.rb
deploy-context-2.1.28 lib/deploy-context/context/deploy.rb
deploy-context-2.1.27.1.gd07a6e7 lib/deploy-context/context/deploy.rb
deploy-context-2.1.27 lib/deploy-context/context/deploy.rb
deploy-context-2.1.26.1.gb2b5290 lib/deploy-context/context/deploy.rb
deploy-context-2.1.26 lib/deploy-context/context/deploy.rb
deploy-context-2.1.25.1.g100c5d2 lib/deploy-context/context/deploy.rb
deploy-context-2.1.25 lib/deploy-context/context/deploy.rb
deploy-context-2.1.24.1.g5c354df lib/deploy-context/context/deploy.rb
deploy-context-2.1.24 lib/deploy-context/context/deploy.rb
deploy-context-2.1.23.1.g8776c45 lib/deploy-context/context/deploy.rb
deploy-context-2.1.23 lib/deploy-context/context/deploy.rb
deploy-context-2.1.22.1.g7cd8ccb lib/deploy-context/context/deploy.rb
deploy-context-2.1.22 lib/deploy-context/context/deploy.rb