Does an (experimental) class browser exist for Ruby?
I am talking about a class browser/editor combination similar to that of most Smalltalk implementations (i.e. focused on [runtime] classes/objects instead of .rb files)
P.S.: it looks like pry is already able to do a lot of the things that would be needed by a smalltalk style class browser? https://speakerdeck.com/u/rahult/p/pry-an-irb-alternative-on-steroids
P.S.2: Looks like the Seaside Smalltalk framework has a web browser based class browser
P.S.3: MagLev/Webtools is the closest I have found yet:
P.S.4: Apparently http://tibleiz.net/code-browser/index.html has Ruby support and is able to present a Smalltalk like class browser:
Check out the maglev/webtools project on github, as well as the rubymirrors gem. It already provides a class browser and workspace for multiple Ruby implementations, and a graphical debugger works on MagLev as well (not so much on MRI).
If you want to build one, the easiest would be to use MOOSE and build the browser with Glamour, on top of a Ruby parser written in PetitParser. Then you could use Pharo as your Ruby IDE.
You can have a look at the Maglev Database Explorer [1, 2] as well.
[1] Video: http://www.youtube.com/watch?v=27mS1BNP7wQ
[2] Gem: https://github.com/matthias-springer/maglev-database-explorer-gem
There is. It is called Reflexive. https://github.com/dolzenko/reflexive
(I've never taken the time to try it though, so I am curious about other experiences with it.)
I have no experience with it (and it is old), but may be rbbr still works.
Related
We are currently running rspec tests that check for specific libraries/models to be loaded. Specifically, we want to test that when creating an object, we get the correct Watir object back: Watir::Browser for FF and Chrome, and Watir::Safari for Safari.
We already tried doing this: Unload a ruby class but it just deletes the constant, which isn't what we want.
Normally, this wouldn't be a problem but due to compatibility problems with safariwatir and watir-webdriver, this is not the case. It errors out with:
superclass mismatch for class UnknownObjectException
And to 'fix' this, we basically have to choose which webdriver to load(hence the original logic - which we plan to test)
Is there a way to solve this? Our tests pass, not just when ran as a whole. So we basically have to skip a step just to circumvent the require problem.
New Anser: NEWS FLASH webdriver now supports Safari! ditch safariwatir and do it all with webdriver. I just found this out today at the Test Automation Bazaar, so don't have much in the way of details.. I'd expect to see some blog postings about this from the Watir community in the next week or so once people recover from the conference.
UPDATE: Details now up on the watir-webdriver blog regarding how to make things work with Safari
Classes in Ruby are objects, but the idea of classes as a 'one per execution/objectspace" only exists because Ruby class objects are assigned as constants.
Since your classes are namespaced with theater module, you can check the type of an object dynamically. If that isn't enough, you can duck-type. Since you mentioned compatibility issues, there are methods that exist for one that do not for another (which you can test for) or there are methods that return different values for each (which you can test for.)
I've handled something similar to this by using conditional logic when I require the 'watir' gem, so that only one version ends up being required based on what the environment is configured for. I can provide more details later, perhaps after the watir test automation bazaar is over and I have a little time to think and dig out some code samples for you.
I am interested in creating a command line application with ruby that would require moderately complex interaction with the user. I would like to use ncurses for this.
What is the best gem for working with ruby and ncurses, or should I be using stdlib utilities in ruby?
Ruby includes bindings for the curses library. Despite what the name implies, it will use ncurses if possible.
Third party libraries often provide abstractions on top of either Ruby's curses or their own bindings. For example, ncursesw also wraps the panel, menu and form extensions. When I worked with Ruby's curses, I created my own Window class with proper border support.
If the basic methods are sufficient, I don't see any reason to add a dependency to your project. However, if you want to do fancy things more easily, you should use a library that provides support for what you need.
I have found ncursesw on this Rubygems seach. Seems to be a good gem to start with.
This one appears to have the best readme https://github.com/seanohalpin/ffi-ncurses
Does anyone know of a program that has support for code completion for Sketchup Ruby API?
Here are some Ruby IDEs that have code completion:
JetBrains RubyMine: http://www.jetbrains.com/ruby/
NetBeans Ruby plugin: http://wiki.netbeans.org/Ruby
Unfortunately, it looks like you might need to do some work to get the Sketchup API symbols loaded into your IDE of choice. If I come across anything, I'll edit this answer.
You might also try posting to their mailing list to see if they have any ideas: http://groups.google.com/group/google-sketchup-developers
I found a code-completion addon for Notepad++. I added the SketchUp Ruby API methods to the Ruby code completion. Though I think it needs updating to support SU8's methods. I don't remember where I found it, but pretty sure it was somewhere on the SketchUcation forum: http://forums.sketchucation.com/
I'll post back if I find it.
How do I best navigate the core docs? What are others doing when curious about what methods are available on standard classes?
This other SO question is the same, but the accepted answer isn't cutting it for me.
I was trying
f = File.open("some-file.txt","w+")
and then wanted to check what methods I have available on f after this. I tried the following:
ri File.open -> Nothing known about File.open
The core docs tells that File at least doesn't define "open". But the page doesn't mention which modules File mixes in, or inherits from. So I wrote a script:
p File.open("foo.txt", "w+").methods
But this seems quite inefficient (not to mention a raw list of methods isn't the best documentation).
I used pickaxe. It wasn't the be all and end all, but it was pretty decent.
Now I guess it would have to be http://ruby-doc.org
You can just do ri File and it will give you full info on the File class (including the methods it implements and its superclass) or ri open (which will tell you all the places open is implemented if there are several).
You can access the documentation on your system from a browser. This details how to set it up.
Honestly, I usually just go to google and enter "Ruby [method name]" and what I want is almost always in the top three results. If it's not, I fall back to rubybrain.
I use http://apidock.com/ruby for Ruby documentation and the site also features Rails and RSpec documentation.
I found Fxri is useful when you want to browse what method is avaiable for certain object.
It is default in Ruby windows install package.
https://rubygems.org/gems/fxri/
I am primarily a fluent .NET developer (as can be seen from the amount of posts and threads I make about .NET), but I thought it would be good to learn RoR.
In doing so, I have a few questions about the architecture of the language (Ruby) and the framework (RoR):
1) In .NET, every object is derived from System but inherits System.Object. So when I type System., I get a list of namespaces and then in those namespaces, classes and more namespaces.
Does Ruby not have this sort of hierarchy?
2) In some cases, I don't get the intellisense. For example, I wrote the class as outlined here (http://wiki.rubyonrails.org/rails/pages/HowToSendEmailsWithActionMailer) but in the line recipients user.email, nothing comes up when I type "user.".
Any idea why?
Thank
Dave Thomas (Pragmatic Programmers) has an excellent screencast series on the Ruby object model/metaprogramming. We watched this in a local Ruby user's group. The series isn't free, but it's not expensive either. You might want to check out the free preview to see if you think it is worth your time.
And to give you an answer. Yes, everything in Ruby derives from Object. You can find the docs on this at http://corelib.rubyonrails.org/. Look for the Object class.
I'm not sure why you aren't getting intellisense, partly because you haven't specified your IDE. It's possible that you can't because you've added the method dynamically and no intellisense is available.
If we compare .NET to Rails then yes, there is this kind of hierarchy there. And in general, you can achieve this kind of hierarchy in any Ruby application via using modules.
I guess it's because of Ruby's dynamic nature.
Ruby is a pure OO language meaning that everything from classes to objects derive from the Object class.
Download NetBeans. There is full intellisense support for Ruby and Ruby on Rails.
http://www.netbeans.org/features/ruby/index.html
Intellisense support probably won't get you what you think it will get you. Because Ruby is a dynamic language, Intellisense, or code completion, is difficult. What you will find is that either the drop down is so flooded with possible completions as to be useless. Or in your case nothing at all.
It's not 100% useless, but I have never found it terribly valuable.