2014-07-07 14:49:42 +02:00
|
|
|
# vim FTW
|
|
|
|
Pry.config.editor = 'vim'
|
|
|
|
|
2014-10-09 14:36:06 +02:00
|
|
|
# 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
|
|
|
|
|
2014-07-07 14:49:42 +02:00
|
|
|
# Toys methods
|
|
|
|
# See https://gist.github.com/807492
|
|
|
|
class Array
|
|
|
|
def self.toy(n=10, &block)
|
|
|
|
block_given? ? Array.new(n,&block) : Array.new(n) {|i| i+1}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Hash
|
|
|
|
def self.toy(n=10)
|
|
|
|
Hash[Array.toy(n).zip(Array.toy(n){|c| (96+(c+1)).chr})]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-10-09 14:36:06 +02:00
|
|
|
# Ask for Apartment tenant
|
|
|
|
if defined?(Rails::Console) && defined?(Apartment)
|
|
|
|
available_tenants = Apartment.tenant_names.sort
|
|
|
|
default_tenant = available_tenants.first
|
2014-07-07 14:49:42 +02:00
|
|
|
|
2014-10-09 14:36:06 +02:00
|
|
|
puts "Available tenants: #{available_tenants.join(',')}"
|
|
|
|
print "Select tenant (#{default_tenant}): "
|
|
|
|
tenant = gets.strip
|
2014-07-07 14:49:42 +02:00
|
|
|
|
2014-10-09 14:36:06 +02:00
|
|
|
Apartment::Tenant.switch(available_tenants.include?(tenant) ? tenant : default_tenant)
|
2014-07-07 14:49:42 +02:00
|
|
|
end
|