irb

What alternatives to IRB are there?

有些话、适合烂在心里 提交于 2019-12-03 04:14:16
问题 In the python world, there are a number of alternative python interpreters that add cool additional features. One particularly useful example is bpython, which adds dynamic syntax highlighting, automatically pulls documentation, and displays live autocomplete information. In the Ruby world, I have yet to uncover any projects which add to the basic IRB interpreter even a subset of these features. Am I just not looking hard enough, or is this just something the Ruby community is lacking? 回答1:

Load and use fixture in rails console

大憨熊 提交于 2019-12-03 03:32:39
问题 I wonder if there's a way to load and/or use fixture in rails console. Actually, I'd like to create a user from my fixture users.yml to do some testing without having to go through all the "pain" of doing User.new(:name = "John", :email = "..") each time. I am currently in test environment ( rails c RAILS_ENV=test ). If it's not a good way to do things, please say it. I'm new to Rails so I'm here to learn :) 回答1: You should be able to load your fixtures prior to entering console. Like this:

How can I pass <arguments> to IRB if I don't specify <programfile>?

孤街浪徒 提交于 2019-12-03 02:40:39
Since: irb --help Usage: irb.rb [options] [programfile] [arguments] I know I can pass arguments to ARGV if I include a programfile eg: irb test.rb A B C where test.irb is simply "p ARGV" produces: ["a", "b", "c"] Making programfile be con in DOS... I can do following irb con A B C con(main):001:0> ARGV produces: ARGV => ["A", "B", "C"] but this is system dependent and has the side effect of echoing input :-( What i really like is something like irb -- a b c BTW: I know I can set ARGV inside irb but I my intention is to alias special == irb -rSpecialLibrary" so I can do something like: special

how to get the current working directory's absolute path from irb

女生的网名这么多〃 提交于 2019-12-03 01:36:03
问题 I'm running Ruby on Windows though I don't know if that should make a difference. All I want to do is get the current working directory's absolute path. Is this possible from irb? Apparently from a script it's possible using File.expand_path(__FILE__) But from irb I tried the following and got a "Permission denied" error: File.new(Dir.new(".").path).expand 回答1: Dir.pwd seems to do the trick. http://ruby-doc.org/core/Dir.html#method-c-pwd 回答2: File.expand_path File.dirname(__FILE__) will

How Do You Clear The IRB Console?

痞子三分冷 提交于 2019-12-03 00:18:58
问题 How do you clear the IRB console screen? 回答1: On Mac OS X or Linux you can use Ctrl + L to clear the IRB screen. 回答2: Throw this inside %userprofile%\.irbrc and you're good def cls system('cls') end From IRB clear screen on windows. 回答3: On *nix boxes `clear` on Windows system 'cls' # works `cls` # does not work on OSX system 'clear' # works `clear` # does not work 回答4: On Ubuntu 11.10 system clear will mostly clear the irb window. You get a return => True value printed. A big mess of ugly

Unicode characters in Ruby 1.9.3 IRB with RVM

China☆狼群 提交于 2019-12-03 00:15:44
Update : I found almost exact similar question , yet it has slightly different prerequisites and thus doesn't help much. Given: MacOS Lion 10.7.3 rvm 1.14.2 ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0] Ruby was installed with the following line: rvm install 1.9.3 --with-readline-dir=/usr/local/Cellar/readline/6.2.2/ When I fire up irb or rails c and start typing unicode characters, I get: \U+FFD0\U+FFBF\U+FFD1\U+FFD0\U+FFB8\U+FFD0\U+FFBC\U+FFD0\U+FFB5\U+FFD1 How do I get unicode characters displayed correctly when typing on Ruby/Rails consoles? P.S. Typing same characters

Is there something like bpython for Ruby?

时光毁灭记忆、已成空白 提交于 2019-12-02 19:09:04
IRb is pretty plain compared to bpython , even when using wirble . Is there any ruby equivalent of bpython? horseyguy Use Pry: http://pry.github.com It is written from scratch and let's you: view method source code view method documentation (not using RI so you dont have to pre-generate it) pop in and out of different contexts invoke at runtime, in any context syntax highlighting gist integration view and replay history open editors to edit method using edit-method obj.my_method syntax A tonne more great and original features You can extend irb to achieve all of bpython's functionality and

How do I introspect things in Ruby?

我与影子孤独终老i 提交于 2019-12-02 18:09:33
For instance, in Python, I can do things like this if I want to get all attributes on an object: >>> import sys >>> dir(sys) ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__', '__stderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_current_frames', '_getframe', 'api_version', 'argv', 'builtin_module_names', 'byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook', 'dont_write_bytecode', 'exc_clear', 'exc_info', 'exc_type', 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info', 'getcheckinterval', 'getdefaultencoding',

Neither ruby and nor irb can load .rb file in current directory

不羁岁月 提交于 2019-12-02 17:30:49
I'm having a really noob problem with importing files in Ruby. I'm making a Ruby app in Windows XP. All the class files for the app are in "C:/Documents/Prgm/Surveyor_Ruby/lib" . But when I require a file in another file, neither ruby nor irb can find the required file. The current directory's contents: C:\Documents\Prgm\Surveyor_Ruby\lib>dir Volume in drive C has no label. Volume Serial Number is AAAA-BBBB Directory of C:\Documents\Prgm\Surveyor_Ruby\lib 10/09/2010 06:32 PM <DIR> . 10/09/2010 06:32 PM <DIR> .. 10/08/2010 03:22 PM 5,462 main (commented).rb 10/08/2010 03:41 PM 92 question.rb 10

What alternatives to IRB are there?

做~自己de王妃 提交于 2019-12-02 16:37:30
In the python world, there are a number of alternative python interpreters that add cool additional features. One particularly useful example is bpython, which adds dynamic syntax highlighting, automatically pulls documentation, and displays live autocomplete information. In the Ruby world, I have yet to uncover any projects which add to the basic IRB interpreter even a subset of these features. Am I just not looking hard enough, or is this just something the Ruby community is lacking? What a coincidence. Rubyflow just yesterday announced the irbtools gem, which is a meta-gem containing lots