class Hyrb::Commands::Pipeline
Public Class Methods
new(task_class)
click to toggle source
Calls superclass method
Hyrb::Pipeline::new
# File lib/hyrb/command.rb, line 22 def initialize(task_class) super # Thor:Shell defines a constructor so have to do this here extend Thor::Shell end
Public Instance Methods
beep()
click to toggle source
# File lib/hyrb/command.rb, line 69 def beep print "\a" end
edit(path)
click to toggle source
# File lib/hyrb/command.rb, line 46 def edit(path) editor = [ENV['VISUAL'], ENV['EDITOR']].find { |e| e.present? } raise "Please set $EDITOR variable :)" unless editor cmd = "#{editor} #{path}" raise "Could not run '#{cmd}'" unless system(cmd) end
info(message)
click to toggle source
# File lib/hyrb/command.rb, line 65 def info(message) say message end
option_list(cache, attribute = nil, default = nil, &block)
click to toggle source
# File lib/hyrb/command.rb, line 53 def option_list(cache, attribute = nil, default = nil, &block) list = attribute ? cache[attribute] : cache choices = list.map.with_index(&block) say choices.join("\n") index = ask("Pick from #{attribute}:", default: default) if index.try :include?, "," index.split(",").map { |i| list[i.to_i - 1] } else list[index.to_i - 1] end end
prompt(prompt, hash, key, options = {})
click to toggle source
# File lib/hyrb/command.rb, line 29 def prompt(prompt, hash, key, options = {}) unless options.is_a?(Hash) default = options options = {} options[:default] = default end if options.delete(:always) options[:default] = hash[key] if hash[key] hash[key] = ask(prompt, options) else hash[key].blank? ? hash[key] = ask(prompt, options) : hash[key] end hash.save! if hash.respond_to? :save! end