ruby: repeat last command and handle apartment with pry
This commit is contained in:
parent
8160879f46
commit
1110603d22
24
ruby/pryrc
24
ruby/pryrc
@ -1,6 +1,12 @@
|
|||||||
# vim FTW
|
# vim FTW
|
||||||
Pry.config.editor = 'vim'
|
Pry.config.editor = 'vim'
|
||||||
|
|
||||||
|
# Repeat last command on enter
|
||||||
|
# https://github.com/pry/pry/issues/607
|
||||||
|
Pry::Commands.command(/^$/, "repeat last command") do
|
||||||
|
_pry_.input = StringIO.new(Pry.history.to_a.last)
|
||||||
|
end
|
||||||
|
|
||||||
# Toys methods
|
# Toys methods
|
||||||
# See https://gist.github.com/807492
|
# See https://gist.github.com/807492
|
||||||
class Array
|
class Array
|
||||||
@ -15,16 +21,14 @@ class Hash
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if defined?(Rails) && Rails.env
|
# Ask for Apartment tenant
|
||||||
require 'logger'
|
if defined?(Rails::Console) && defined?(Apartment)
|
||||||
|
available_tenants = Apartment.tenant_names.sort
|
||||||
|
default_tenant = available_tenants.first
|
||||||
|
|
||||||
if defined?(ActiveRecord)
|
puts "Available tenants: #{available_tenants.join(',')}"
|
||||||
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
print "Select tenant (#{default_tenant}): "
|
||||||
ActiveRecord::Base.clear_active_connections!
|
tenant = gets.strip
|
||||||
end
|
|
||||||
|
|
||||||
if defined?(DataMapper)
|
|
||||||
DataMapper::Logger.new($stdout, :debug)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
Apartment::Tenant.switch(available_tenants.include?(tenant) ? tenant : default_tenant)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user