- 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