Sha256: 9596f7ff74dcfd894e94b72b77f0493cf5d6025d862def3c8e5eeebf67d6e3c4

Contents?: true

Size: 1.86 KB

Versions: 7

Compression:

Stored size: 1.86 KB

Contents

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

    def initialize
      super
      @rakefiles = ['Minafile', '.deploy.rb', 'deploy.rb', '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, no_report_time)
    end

    def top_level_tasks
      return @top_level_tasks if @top_level_tasks.include?('init')
      @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

    def no_report_time
      ['--no-report-time', nil,
       'Skip time reporting',
       lambda do |_value|
         set(:skip_report_time, true)
       end
      ]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mina-1.2.4 lib/mina/application.rb
mina-1.2.3 lib/mina/application.rb
mina-1.2.2 lib/mina/application.rb
mina-1.2.1 lib/mina/application.rb
mina-1.2.0 lib/mina/application.rb
mina-1.1.1 lib/mina/application.rb
mina-1.1.0 lib/mina/application.rb