Sha256: a8d9410b4ecac79c7280e170c2302659a39322242c278a602b74df64a54158cf

Contents?: true

Size: 1.82 KB

Versions: 14

Compression:

Stored size: 1.82 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.minor_bump
          false
        when 'release'
          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

14 entries across 14 versions & 1 rubygems

Version Path
deploy-context-2.1.0.1.gfc552cd lib/deploy-context/context/deploy.rb
deploy-context-2.1.0 lib/deploy-context/context/deploy.rb
deploy-context-2.0.11.1.g2fb12a4.1.g77162b5 lib/deploy-context/context/deploy.rb
deploy-context-2.0.11.1.g2fb12a4 lib/deploy-context/context/deploy.rb
deploy-context-2.0.11 lib/deploy-context/context/deploy.rb
deploy-context-2.0.10.1.g6db0997.1.gafb2bd3 lib/deploy-context/context/deploy.rb
deploy-context-2.0.10.1.g6db0997 lib/deploy-context/context/deploy.rb
deploy-context-2.0.10 lib/deploy-context/context/deploy.rb
deploy-context-2.0.9 lib/deploy-context/context/deploy.rb
deploy-context-2.0.8.1.gdd5846f lib/deploy-context/context/deploy.rb
deploy-context-2.0.8 lib/deploy-context/context/deploy.rb
deploy-context-2.0.7 lib/deploy-context/context/deploy.rb
deploy-context-2.0.6 lib/deploy-context/context/deploy.rb
deploy-context-2.0.5.1.g566bf75 lib/deploy-context/context/deploy.rb