Class: Magica::Application

Inherits:
Rake::Application
  • Object
show all
Defined in:
lib/magica/application.rb

Overview

:nodoc:

Constant Summary collapse

DEFAULT_MAGICAFILES =
[
  'magicafile',
  'Magicafile',
  'magicafile.rb',
  'Magicafile.rb'
].freeze

Instance Method Summary collapse

Constructor Details

#initializeApplication

Returns a new instance of Application.



11
12
13
14
# File 'lib/magica/application.rb', line 11

def initialize
  super
  @rakefiles = DEFAULT_MAGICAFILES.dup << magicafile
end

Instance Method Details

#handle_optionsObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/magica/application.rb', line 25

def handle_options
  options.rakelib = ['rakelib']
  options.trace_output = $stderr

  OptionParser.new do |opts|
    opts.on_tail('-h', '--help', '-H', 'Display this help message.') do
      puts opts
      exit
    end

    standard_rake_options.each { |args| opts.on(*args) }
    opts.environment('RAKEOPT')
  end.parse!
end

#nameObject



16
17
18
# File 'lib/magica/application.rb', line 16

def name
  'magica'
end

#runObject



20
21
22
23
# File 'lib/magica/application.rb', line 20

def run
  Rake.application = self
  super
end

#sort_options(options) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/magica/application.rb', line 40

def sort_options(options)
  # rubocop:disable Metrics/LineLength
  not_applicable_to_magica = %w[verbose execute execute-continue libdir no-search rakefile rakelibdir require system no-system where no-deprecation-warnings]
  # rubocop:enable Metrics/LineLEngth

  options.reject! do |(switch, *)|
    switch =~ /--#{Regexp.union(not_applicable_to_magica)}/
  end

  super.push(version, clean, clean_all, rebuild, target)
end

#top_level_tasksObject



52
53
54
55
56
57
# File 'lib/magica/application.rb', line 52

def top_level_tasks
  unless File.exist?('Magicafile')
    @top_level_tasks.unshift(warning_not_init.to_s) unless default_tasks.include?(@top_level_tasks.first)
  end
  @top_level_tasks
end