Class: MTBuild::Application
- Inherits:
-
Rake::Application
- Object
- Rake::Application
- MTBuild::Application
- Includes:
- Rake::DSL
- Defined in:
- lib/mtbuild/application.rb
Overview
This subclasses the Rake::Application class to override default Rake behaviors with MTBuild-specific behaviors
Constant Summary collapse
- DEFAULT_RAKEFILES =
Default list of mtbuildfile names
[ 'mtbuildfile', 'MTBuildfile', 'mtbuildfile.rb', 'MTBuildfile.rb' ].freeze
Instance Attribute Summary collapse
-
#rakefiles ⇒ Object
readonly
List of rakefile names to look for.
Instance Method Summary collapse
- #create_default_task_if_none_exists ⇒ Object
- #default_task_name ⇒ Object
-
#init(app_name = 'mtbuild') ⇒ Object
Override init to pass mtbuild as the app name.
-
#initialize ⇒ Application
constructor
This overrides the default rakefile names with the mtbuildfile names.
- #run ⇒ Object
-
#standard_rake_options ⇒ Object
This modifies Rake’s command line options to do MTBuild-specific things.
Methods included from Rake::DSL
#application_task, #framework_task, #static_library_task, #test_application_task
Constructor Details
#initialize ⇒ Application
This overrides the default rakefile names with the mtbuildfile names
28 29 30 31 |
# File 'lib/mtbuild/application.rb', line 28 def initialize super @rakefiles = DEFAULT_RAKEFILES.dup end |
Instance Attribute Details
#rakefiles ⇒ Object (readonly)
List of rakefile names to look for
17 18 19 |
# File 'lib/mtbuild/application.rb', line 17 def rakefiles @rakefiles end |
Instance Method Details
#create_default_task_if_none_exists ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/mtbuild/application.rb', line 78 def create_default_task_if_none_exists if lookup(default_task_name).nil? task default_task_name do puts 'Nothing to do because no projects specified default tasks.' puts 'Use the -T flag to see the list of tasks you can build.' end end end |
#default_task_name ⇒ Object
87 88 89 |
# File 'lib/mtbuild/application.rb', line 87 def default_task_name 'all' end |
#init(app_name = 'mtbuild') ⇒ Object
Override init to pass mtbuild as the app name
43 44 45 |
# File 'lib/mtbuild/application.rb', line 43 def init(app_name='mtbuild') super end |
#run ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/mtbuild/application.rb', line 33 def run standard_exception_handling do init load_rakefile create_default_task_if_none_exists top_level end end |
#standard_rake_options ⇒ Object
This modifies Rake’s command line options to do MTBuild-specific things
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/mtbuild/application.rb', line 48 def # This hijacks the "--version" flag and displays the MTBuild version along # with the Rake version. = super.map do |opt| if opt.first == '--version' ['--version', '-V', "Display the program version.", lambda { |value| puts "mtbuild, version #{MTBuild::VERSION}" puts "rake, version #{Rake::VERSION}" exit } ] else opt end end # This adds MTBuild-specific options |= [ ['--super-dry-run', "Do a dry run printing actions, but not executing them.", lambda { |value| Rake.verbose(true) Rake.nowrite(true) } ], ] () end |