Module: Rake::TaskManager
- Defined in:
- lib/rake/typo.rb
Instance Method Summary collapse
-
#[](*args) ⇒ Object
Wrap the ‘TaskManager#[]` method to capture calls to `#fail` to append possibly misspelled commands.
- #orig_access ⇒ Object
Instance Method Details
#[](*args) ⇒ Object
Wrap the ‘TaskManager#[]` method to capture calls to `#fail` to append possibly misspelled commands.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rake/typo.rb', line 37 def [](*args) task_name = args.first begin orig_access(*args) rescue => e msg = "#{e}" candidates = Rake::Typo.candidate_tasks(task_name, Rake.application.tasks) unless candidates.empty? msg += "\n\n" msg += "Did you mean #{candidates.size == 1 ? "this" : "one of these"}?\n\n" candidates.each do |c| msg += "\t#{c.name}\n" end end # abort, not fail as in the original, just # to have a friendlier message without a # stacktrace. abort msg end end |
#orig_access ⇒ Object
32 |
# File 'lib/rake/typo.rb', line 32 alias_method :orig_access, :[] |