Guest User

Untitled

a guest
Jul 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #-*-Ruby-*-
  2. require 'rubygems'
  3. require 'pp'
  4. require 'wirble'
  5. require 'hirb'
  6. require 'ap'
  7. if RUBY_VERSION[0..2] == "1.9"
  8. require 'flyrb'
  9. else
  10. require 'utility_belt'
  11. end
  12. require 'logger'
  13. # add pretty printing support to irb
  14. include PP::ObjectMixin
  15.  
  16.  
  17. # load wirble
  18. Wirble.init
  19. Wirble.colorize
  20.  
  21. # load hirb
  22. Hirb::View.enable
  23.  
  24. IRB.conf[:AUTO_INDENT] = true
  25.  
  26. if ENV.include?('RAILS_ENV')
  27. if !Object.const_defined?('RAILS_DEFAULT_LOGGER')
  28. require 'logger'
  29. Object.const_set('RAILS_DEFAULT_LOGGER', Logger.new(STDOUT))
  30. end
  31.  
  32. def sql(query)
  33. ActiveRecord::Base.connection.select_all(query)
  34. end
  35.  
  36. if ENV['RAILS_ENV'] == 'test'
  37. require 'test/test_helper'
  38. end
  39.  
  40. # for rails 3
  41. elsif defined?(Rails) && !Rails.env.nil?
  42. if Rails.logger
  43. Rails.logger =Logger.new(STDOUT)
  44. ActiveRecord::Base.logger = Rails.logger
  45. end
  46. if Rails.env == 'test'
  47. require 'test/test_helper'
  48. end
  49. else
  50. # nothing to do
  51. end
  52.  
  53. # annotate column names of an AR model
  54. def show(obj)
  55. y(obj.send("column_names"))
  56. end
  57.  
  58. puts "> all systems are go wirble/hirb/ap/show <"
  59.  
  60.  
  61. class Object
  62. def local_methods
  63. (methods - Object.instance_methods).sort
  64. end
  65. end
  66.  
  67. # to reload your rails app
  68. # reload!
  69.  
  70. # hash of http status codes
  71. # ActionController::StatusCodes::STATUS_CODES
  72.  
  73. # getting rails logs in the console
  74. # ActiveRecord::Base.logger = Logger.new(STDOUT)
  75. # ActiveRecord::Base.clear_active_connections!
  76.  
  77.  
  78. def hist
  79. puts Readline::HISTORY.entries.split("exit").last[0..-2].join("\n")
  80. end
Add Comment
Please, Sign In to add comment