Class: Object
- Inherits:
- BasicObject
- Includes:
- ConvertableToFile, UtilityBelt::AmazonUploadShortcut, UtilityBelt::Google, UtilityBelt::Pastie, UtilityBelt::Twitty
- Defined in:
- lib/utility_belt/not.rb,
lib/utility_belt/with.rb,
lib/utility_belt/is_an.rb,
lib/utility_belt/google.rb,
lib/utility_belt/pastie.rb,
lib/utility_belt/twitty.rb,
lib/utility_belt/language_greps.rb,
lib/utility_belt/language_greps.rb,
lib/utility_belt/command_history.rb,
lib/utility_belt/convertable_to_file.rb,
lib/utility_belt/irb_verbosity_control.rb,
lib/utility_belt/amazon_upload_shortcut.rb,
lib/utility_belt/rails_verbosity_control.rb
Overview
Rails verbosity: weblog.jamisbuck.org/2007/1/8/watching-activerecord-do-it-s-thing Marcel said they toyed with making this the console default on core
Defined Under Namespace
Classes: Not
Instance Method Summary collapse
- #grep_classes(search_term) ⇒ Object
- #grep_methods(search_term) ⇒ Object
-
#handling_jruby_bug(&block) ⇒ Object
hack to handle JRuby bug.
- #history(how_many = 50) ⇒ Object (also: #h)
-
#history_do(lines = (Readline::HISTORY.size - 2)) ⇒ Object
(also: #h!)
-2 because -1 is ourself.
-
#history_to_vi ⇒ Object
(also: #hvi)
TODO: history_write should go to a file, or the clipboard, or a file which opens in an application.
- #history_write(filename, lines) ⇒ Object
- #log ⇒ Object
- #quiet ⇒ Object (also: #q)
- #verbose ⇒ Object (also: #v)
- #with(object, &block) ⇒ Object
Methods included from UtilityBelt::AmazonUploadShortcut
Methods included from ConvertableToFile
Methods included from UtilityBelt::Twitty
Methods included from UtilityBelt::Pastie
Methods included from UtilityBelt::Google
Instance Method Details
#grep_classes(search_term) ⇒ Object
15 16 17 18 19 |
# File 'lib/utility_belt/language_greps.rb', line 15 def grep_classes(search_term) classes = [] ObjectSpace.each_object {|object| classes << object.name if object.is_a? Class and not object.name.blank?} classes.find_all {|klass| klass.downcase.include? search_term.downcase} end |
#grep_methods(search_term) ⇒ Object
24 25 26 |
# File 'lib/utility_belt/language_greps.rb', line 24 def grep_methods(search_term) methods.find_all {|method| method.downcase.include? search_term.downcase} end |
#handling_jruby_bug(&block) ⇒ Object
hack to handle JRuby bug
61 62 63 64 65 66 67 68 69 |
# File 'lib/utility_belt/command_history.rb', line 61 def handling_jruby_bug(&block) if RUBY_PLATFORM =~ /java/ puts "JRuby IRB has a bug which prevents successful IRB vi interoperation." puts "The JRuby team is aware of this and working on it." puts "(http://jira.codehaus.org/browse/JRUBY-2049)" else yield end end |
#history(how_many = 50) ⇒ Object Also known as: h
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/utility_belt/command_history.rb', line 29 def history(how_many = 50) history_size = Readline::HISTORY.size # no lines, get out of here puts "No history" and return if history_size == 0 start_index = 0 # not enough lines, only show what we have if history_size <= how_many how_many = history_size - 1 end_index = how_many else end_index = history_size - 1 # -1 to adjust for array offset start_index = end_index - how_many end start_index.upto(end_index) {|i| print_line i} end |
#history_do(lines = (Readline::HISTORY.size - 2)) ⇒ Object Also known as: h!
-2 because -1 is ourself
47 48 49 |
# File 'lib/utility_belt/command_history.rb', line 47 def history_do(lines = (Readline::HISTORY.size - 2)) irb_eval lines end |
#history_to_vi ⇒ Object Also known as: hvi
TODO: history_write should go to a file, or the clipboard, or a file which opens in an application
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/utility_belt/command_history.rb', line 72 def history_to_vi handling_jruby_bug do file = Tempfile.new("irb_tempfile") get_lines(0..(Readline::HISTORY.size - 1)).each do |line| file << "#{line}\n" end file.close system("vim #{file.path}") end end |
#history_write(filename, lines) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/utility_belt/command_history.rb', line 52 def history_write(filename, lines) file = File.open(filename, 'w') get_lines(lines).each do |l| file << "#{l}\n" end file.close end |
#log ⇒ Object
4 5 6 7 |
# File 'lib/utility_belt/rails_verbosity_control.rb', line 4 def log ActiveRecord::Base.clear_active_connections! ActiveRecord::Base.logger = Logger.new(STDOUT) end |
#quiet ⇒ Object Also known as: q
23 24 25 |
# File 'lib/utility_belt/irb_verbosity_control.rb', line 23 def quiet IRB.hide_results end |
#verbose ⇒ Object Also known as: v
18 19 20 |
# File 'lib/utility_belt/irb_verbosity_control.rb', line 18 def verbose IRB.show_results end |
#with(object, &block) ⇒ Object
17 18 19 |
# File 'lib/utility_belt/with.rb', line 17 def with(object, &block) object.instance_eval &block end |