Class: Jets::Commands::RakeCommand
- Inherits:
-
Object
- Object
- Jets::Commands::RakeCommand
- Defined in:
- lib/jets/commands/rake_command.rb
Class Method Summary collapse
- .formatted_rake_tasks(all = false) ⇒ Object
- .help_message(namespaced_command) ⇒ Object
-
.namespaced_commands ⇒ Object
Useful for CLI.lookup.
-
.perform(namespaced_command, thor_args) ⇒ Object
Same signature as Jets::Commands::Base.perform.
- .rake_tasks(all = false) ⇒ Object
Class Method Details
.formatted_rake_tasks(all = false) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/jets/commands/rake_command.rb', line 26 def formatted_rake_tasks(all=false) rake_tasks(all).map do |t| comment = "# #{t.comment}" if t.comment [ t.name_with_args, comment ] end end |
.help_message(namespaced_command) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/jets/commands/rake_command.rb', line 44 def (namespaced_command) task = rake_tasks(true).find { |t| t.name == namespaced_command } = "Help provided by rake task:\n\n" << "jets #{task.name_with_args.dup}\n" << " #{task.full_comment}" end |
.namespaced_commands ⇒ Object
Useful for CLI.lookup.
22 23 24 |
# File 'lib/jets/commands/rake_command.rb', line 22 def namespaced_commands formatted_rake_tasks(true).map(&:first) end |
.perform(namespaced_command, thor_args) ⇒ Object
Same signature as Jets::Commands::Base.perform.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/jets/commands/rake_command.rb', line 4 def perform(namespaced_command, thor_args) if thor_args.first == "help" puts (namespaced_command) return end require_rake ARGV.unshift(namespaced_command) # Prepend the task, so Rake knows how to run it. rake.standard_exception_handling do rake.init("jets") rake.load_rakefile rake.top_level end end |
.rake_tasks(all = false) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/jets/commands/rake_command.rb', line 33 def rake_tasks(all=false) require_rake Rake::TaskManager. = true rake.instance_variable_set(:@name, "jets") Jets::Commands::RakeTasks.load! tasks = rake.tasks tasks = tasks.select(&:comment) unless all tasks end |