Sha256: bf2e546238e47397f27c7a997801d45157c11d2ab35ba7b9ad6ee2f6c17f9ec0

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

module Mina
  class Application < Rake::Application
    include Configuration::DSL

    def initialize
      super
      @rakefiles = ['config/deploy.rb', minafile]
    end

    def name
      'mina'
    end

    def run
      Rake.application = self
      super
    end

    def sort_options(options)
      not_applicable_to_mina = %w(quiet silent verbose dry-run)
      options.reject! do |(switch, *)|
        switch =~ /--#{Regexp.union(not_applicable_to_mina)}/
      end

      super.push(version, verbose, simulate, debug_configuration_variables)
    end

    def top_level_tasks
      @top_level_tasks << :debug_configuration_variables
      @top_level_tasks << :run_commands
    end

    private

    def minafile
      File.expand_path(File.join(File.dirname(__FILE__), '..', 'Minafile'))
    end

    def version
      ['--version', '-V',
       'Display the program version.',
       lambda do |_value|
         puts "Mina, version v#{Mina::VERSION}"
         exit
       end
      ]
    end

    def verbose
      ['--verbose', '-v',
       'Print more info',
       lambda do |_value|
         set(:verbose, true)
       end
      ]
    end

    def simulate
      ['--simulate', '-s',
       'Do a simulate run without executing actions',
       lambda do |_value|
         set(:simulate, true)
       end
      ]
    end

    def debug_configuration_variables
      ['--debug-configuration-variables', '-d',
       'Display the defined config variables before runnig the tasks.',
       lambda do |_value|
         set(:debug_configuration_variables, true)
       end
      ]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mina-1.0.0.beta2 lib/mina/application.rb