module Pult::Panel::Provider::Rake
Constants
- COMMAND
- FILE
- PATH
Public Class Methods
mixin!(panel)
click to toggle source
# File lib/pult/panel/provider/rake.rb, line 8 def self.mixin! panel app_dirs = Pult::Panel::Provider.app_dirs(panel) app_dirs.map{|a, d| [a, "#{d}/#{FILE}"] }.each do |app, rake_file| hash = pult_hash rake_file panel[app]&.merge! hash end end
pult_hash(file)
click to toggle source
# File lib/pult/panel/provider/rake.rb, line 18 def self.pult_hash file hash = {} maker = lambda do |task, command| n = -1 task.split(':').reduce(hash) do |h, t| count = task.count(':') (n += 1) && n == count ? h[t] = "#{command} #{task}" : h[t] ||= {} end end for command in COMMAND tasks = self.tasks command, file tasks.sort.reverse.each{|task| maker.(task, command) } break if hash.any? end { PATH => hash } end
tasks(command, file)
click to toggle source
# File lib/pult/panel/provider/rake.rb, line 40 def self.tasks command, file app_dir = Pathname.new(file).dirname.to_s runner = Pult::Executor.run! "#{command} --tasks", app_dir tasks = runner[:stdout].split(/\n/).map do |s| s.sub(/^#{command} (\S+).*/, '\1') end # temp ignore params tasks.map{ |t| t.sub /\[.+/, '' } end