Sha256: 2582fe8fd2b2dd0823d7b642f68e6a6f6365caf48bab48e8b061684148f582c1

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module Mina
  module DSL
    extend Forwardable
    def_delegators :configuration, :fetch, :set, :set?, :ensure!
    def_delegators :commands, :command, :comment

    def configuration
      Configuration.instance
    end

    def invoke(task, *args)
      Rake::Task[task].invoke(*args)
      Rake::Task[task].reenable
    end

    def commands
      @commands ||= Commands.new
    end

    def reset!
      @commands = Commands.new
    end

    def run(backend)
      error! "Can't use run block inside another run block. #{caller[2]}" if set?(:run_bock)
      set(:run_bock, true)
      invoke :"#{backend}_environment"
      yield
      commands.run(backend)
      @commands = Commands.new
      set(:run_bock, nil)
    end

    def on(stage)
      old_stage, commands.stage = commands.stage, stage
      yield
      commands.stage = old_stage
    end

    def in_path(path, indent: nil)
      real_commands = commands
      @commands = Commands.new
      yield
      real_commands.command(commands.process(path), quiet: true, indent: indent)
      @commands = real_commands
    end

    def deploy(&block)
      run :remote do
        set(:deploy_block, true)
        command deploy_script(&block), quiet: true
        set(:deploy_block, false)
      end
    end
  end
end
extend Mina::DSL

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mina-1.2.5 lib/mina/dsl.rb