Module: JazzFingers::Commands

Defined in:
lib/jazz_fingers/commands.rb,
lib/jazz_fingers/commands/sql.rb,
lib/jazz_fingers/commands/copy.rb,
lib/jazz_fingers/commands/caller_method.rb

Constant Summary collapse

SQL =
Pry::CommandSet.new do
  command "sql", "Send sql over AR." do |query|
    if defined?(Rails)
      pp ActiveRecord::Base.connection.select_all(query)
    else
      pp "Rails not defined"
    end
  end
end
COPY =
Pry::CommandSet.new do
  command "copy", "Copy argument to the clip-board" do |str|
    IO.popen('pbcopy', 'w') { |f| f << str.to_s }
  end
end
CALLER_METHOD =
Pry::CommandSet.new do
  command "caller_method" do |depth|
    depth = depth.to_i || 1
    if /^(.+?):(\d+)(?::in `(.*)')?/ =~ caller(depth+1).first
      file   = Regexp.last_match[1]
      line   = Regexp.last_match[2].to_i
      method = Regexp.last_match[3]
      output.puts [file, line, method]
    end
  end
end