I'm learning to code Ruby, starting to get into learning open source code. How do I turn the open source code I see on github to a runnable application? For example how do I turn source code from Pomodori's Github to the downloadable app from this page? I'm interested in being able to manipulate the source code, and then convert it to a runnable app to see the changes. Any tips are appreciated!
You can see Pomodori's only dependency (listed in it's Gemfile), is the hotcococa gem:
# A sample Gemfile
source "http://rubygems.org"
gem "hotcocoa"
Here is a tutorial for building a simple GUI application with hotcocoa. Hotcocoa, as my fellow posters have pointed out is built on Macruby.
I think going directly with Macruby itself, is a better bet. There are lots of tutorials, and it is relatively up to date. You can build a simple stopwatch app with macruby (full installation instructions are here).
Personally if I was learning ruby again, I'd start with David Black's The Well Grounded Rubyist, or if you are looking for free resources, by working through the bastards book or code academy's ruby course.
update: it occurred to me overnight that you may not be familiar with Ruby's REPL (read evaluate print loop) cli tool IRB, open terminal an enter:
$ irb
This loads an interactive ruby session, you can read more about irb on Ruby's official site.
Generally speaking, Ruby isn't compiled, like C, C++, etc. -- it is executed directly from its source code.
Compilation in other languages is basically good for 1) converting as much of the app to machine code as possible, so it's faster at runtime and 2) removing the source code from the end result. There are ways to do both of these things to some extent in Ruby, but they are highly dependent on the specific Ruby implementation (e.g. MRI, JRuby, MacRuby) as well as the operating system the app will run on.
As Wukerplank notes, Pomodori is written in MacRuby, which is a Mac-specific implementation that has a tool called macruby-deploy that can make actual OS X apps. Unfortunately, the last time I checked (in early 2014), MacRuby didn't run correctly on OS X 10.9; its development mostly stalled out in the 10.7/10.8 era when its principal author (Laurent Sansonetti) created the commercial product RubyMotion. RubyMotion may be something you'd like to investigate if you don't mind yearly subscription fees; it additionally targets iOS and its apps can go in the App Store; it does sacrifice some of Ruby's dynamism, however.
But again, generally speaking people run Ruby programs by calling the Ruby interpreter on them (e.g. ruby program.rb). Ruby interpreters these days do some just-in-time compilation to speed up execution, but the source code is still visible to the user of the code.
Related
I am a java developer and use the Eclipse IDE for developing java code. I use the built-in refactoring features a lot, since good refactoring support from the IDE helps to speed up and leads to higher code quality. I would not like to miss it and use a simple text editor instead. Now I am looking for an IDE for Ruby on Rails with good refactoring capabilities.
Basic refactorings
Wanted basic refactoring methods include:
Extract method
Extract variable
Rename (class, method, variable etc.)
and so on.
Aptana Studio 3, RadRails 2, RubyMine 3 and Netbeans 7
So far I've tried Aptana Studio 3 and was quite disappointed regarding its refactoring capabilities. Aptana RadRails 2 seemed much better for refactoring ruby code, but it lacks other nice features that the newer Aptana Studio 3 offers. Since Aptana Studio 3 seems to be RadRails' successor I would expect that it has at least the same refactorings as the older RadRails 2, but it does not. Using an old unmaintained IDE does not seem a good option. Receiving updates for the IDE should still be possible.
I've read that Jetbrains RubyMine 3 has decent ruby refactoring capabilities, but it costs money. I am rather looking for a free one. Netbeans 7 seems not to support Ruby on Rails anymore.
Are there good IDEs with refactoring support?
That confuses me, it seems like modern IDEs drop (refactoring) support for Ruby on Rails.
What are nowadays (Jan 2012) the most powerful IDEs for refactoring Ruby on Rails code?
Update: Netbeans 7
As suggested by Jörg W Mittag I've tried Netbeans 7 with the ruby plugin provided by the community. I have to say that this combination is much better than Aptana RadRails 2 or Aptana Studio 3 for developing Ruby on Rails apps. The integration of css and html for views is well done and the integration of rails tests into the JUnit Netbeans view comes in handy.
However, the refactoring support seems to be too basic. It supports rename, move, copy and safely delete of methods. It does not support to select lines of code and extract a method out of it nor the similar behaviour for extracting variables.
Update: RubyMine 3
dynex suggested to use RubyMine. I've just played around with it and think its suitability as an Ruby on Rails IDE is at least as good as Netbeans'. The refactor capabilities are by far the best I've seen in a Ruby on Rails IDE so far.
From what I've discovered it features renaming, moving, copying, safe deletion, method extractation, variable introduction, constant introduction, field introduction, parameter introduction, inlining, pulling members up, pushing members doen, module extraction and superclass extraction.
My conclusion is that from the set of IDEs I tested RubyMine was the only one with decent refactoring capabilities. RubyMine costs money, but it seems worth it. The free ones cannot compete regarding refactorings.
Thanks for all answers and comments.
RubyMine was my choice and I use refactoring once in a while. When using 'rename' it's never complete, but better than global-search-replace. Extraction etc works well.
Overall it's a great tool, albeit a memory hog, but I use it all the time now, especially for debugging.
I know, it costs money, but I wanted to put in a good word for them anyway...
Netbeans 7 seems not to support Ruby on Rails anymore
That's not true. Quite the opposite actually. Yes, Oracle dropped support for the Ruby on Rails plugin and gave maintenance over to the Ruby community. But the plugin is still available from the same place it was before, the community is still using the same infrastructure to develop, maintain and distribute the plugin as before. And since most of the people who originally wrote the plugin work for Google now, they can now again work on the code, now that it is no longer owned by the company that is suing their employer.
Thanks for this question firstly, coming from java platform I was not comfortable with the text editors or IDEs available for RoR. I just started using RubyMine for 2 days now and yes it has a reasonable support for refactoring compared to text mate editor. Apart from the other features mentioned here I like code formatting, column selection mode (especially for .haml files), I use Ctrl+Tab to browse between the tabs (as in Netbeans) and of course find usages. I am not yet comfortable with the git integration part yet, need to explore that. If I find anything amazing will update my post.
I'm trying to learn Lua, but I don't really know which binary to download. There's 2 choices:
Lua Binaries
Lua for Windows
The second option Lua for Windows seems to be the recommended option, but the installer weighs in at 26.6Mb, which is pretty hefty for what is supposed to be a v.lightweight language.
I'm thinking of using Lua as a scripting language for games, and perhaps as a fast development language for file processing like how Python or Ruby does it. So it must be something lightweight, not a 26.6Mb file.
Which is the appropriate one to download and start?
Luaforwindows, no doubt. It's simpler, easier and faster.
The installer comes with lots of stuff (Scite editor & several extra libs if I remember well). But the installer asks you before installing all those extra stuff. Just install the minimum and you will be fine.
Lua for Windows includes a handful of other, useful libraries and tools. The actual Lua executable included is still tiny, in the 1-2MB range as expected.
Having the extras there already will only make things easier, and disk space is cheap: go with Lua for Windows.
You may also want to check ZeroBrane Studio, which is only 4M download on Windows and is based on the same editor as SciTE that comes with Lua for Windows. ZBS also comes with 50+ Lua examples and few simple lessons to get started quickly with Lua programming.
Quoting from here.
Installation
The LuaBinaries files are intended for advanced users and programmers who want to incorporate Lua in their applications or distributions and would like to keep compatibility with LuaBinaries, so they also will be compatible with many other modules available on the Internet.
If what you want is a full Lua installation, please check other projects such as the Lua for Windows and LuaRocks.
Seems quite clear to me that you should download Lua for Windows.
I've spent a fair bit of time with PHP & Python frameworks and recently thought I'd branch out to rails. The framework itself I like, but I seem to spend at least half my development time navigating through odd bugs and/or version incompatibilities between rails/ruby/rake/gems.
I'm happy to battle through it all if it gets less of a hassle, but even after a month it seems like I spend 90% of my time chasing down other people's bugs & only 10% of my time chasing down my own. The only guy I've talked to (who used it extensively until 2008) suggests "For the past 2 years, that's pretty much rails"
Any opinion on this? Does it get better, or is this just par for rails development at the moment?
Running it through Ubuntu 10.04, if it matters.
Rails is in transition right now between 2.3x and 3.0 so you are going to find it quite challenging as much of the most recent documentation and rails plugin readmes are being updated for rails 3. There are several tools that are indispensable right now for negotiating this stuff. First, Rails 3 uses bundler to manage dependencies, it is a much more civil way to manage gems.
gem install bundler
cd my_rails_project
bundle install
RVM (ruby version manager) is awesome and I would recommend installing it. Then you can build gemsets and dependency sets on a per project basis. and you don't need to superuser access to install.
also, if it were me, I'd just go ahead and start in rails 3
gem install rails --pre
if you want to stay with rails 2.3.x use the rake task for installing declared dependencies.
rake gems:install
if the project is a good project, it will be pretty specific about what it needs (declared in the config/environment.rb file), then if it doesn't run, checkout the stack traces to see where its failing.
In my experience this is not par for Rails development.
While using gems read the README file on github project repos and have a look at the issues and wikis....that should give you a fair idea of which gem is compatible with your Rails version. Regarding the framework, it is pretty stable....major bugs or patches or releases are reported on weblog.rubyonrails.org
Things grow incrementally with each release and that is obvious. There are some deprecations which are well documented in the Rails code and are reported when you run the code.
Rails itself is pretty bug free. I've not witnessed a bug in the framework itself now for a while unless I've been duplicating open tickets.
Where the problems you're seeing have crept in have been over a couple of different areas:
We've moved as a community from Ruby 1.8.x to 1.9
over the last year or so, and some
gems have specific Ruby version
requirements you need to check out
before using them. Most of the more
popular gems are fine and tested to
work in multiple environments. Read the docs first.
Rails itself has matured
significantly over the last few
years, and that has meant many
features have been deprecated. Lots
of plugins out there were written
for an older version of the
framework and expect behaviour that
just isn't valid any more. Read the docs first.
Several different Ruby interpreters
are now available (which is great),
but these sometimes can have an
impact when it comes to 3rd-party
code, but that's rare. Basically,
some gems and plugins expect to be
running on a specific interpreter.
None of the really popular ones are
like this, but you need to be aware
some gem builders are idiots. Read the docs first.
You might notice there is a common theme to the end of each point: read the docs first. :-)
I would say your experience is not at all typical of most Rails developer's workflows, although we've all had a day of struggling from time to time.
You will learn quickly which gems to trust, which ones you'll need but may struggle with from time to time (mysql - building that kills me on OS X, every time), and which ones you should avoid.
Overall though, the development cycle is more fluid (and you'll develop more rapidly) with Rails once you've got your bearings and are adopting good practice. There's a reason why we all like TDD and BDD though - if nothing else it helps us get through a gem update knowing stuff still works when a developer we don't know has done something moronic. :-)
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I've seen a lot of blogs talk about RubyMine lately, as a best of breed Rails IDE. Currently, I am using NetBeans IDE for my Ruby and Rails stuff, but I was wondering if anyone here would personally recommend this IDE, and reasons why I should fork out $99 for it.
I used NetBeans for a while, before switching to RubyMine some month ago prior the first release.
I can say the IDE is worth the entire price.
RubyMine has the best autocomplete support I have ever seen. It's a really clever IDE, it can understand most of the Rails "magics" including method references by symbols
class Controller
before_filter :mymethod
def mymethod
end
end
metaprogramming, Rails/Ruby convention and so on.
Also, RubyMine 2.0 introduced i18n support for Rails and, having to maintain a couple of Rails apps localized in 5 different languages, I must say this is an awesome feature.
It supports the latest testing frameworks in the Ruby ecosystem, including Shoulda, Test::Unit, RSpec and Cucumber. Unfortunately it lacks RCov support, while I know Netbeans is going to integrate it.
A couple of co-workers are still using NetBeans and they often have problem with SVN because Netbeans doesn't auto-refresh the working copy when you update it outside the IDE.
RubyMine has an excellent SCM support and ships with SVN, CVS and even Git compatibility.
I don't want this answer to seems like a RubyMine promo, so I encourage you to give it a try for 30days then make a choice.
I've tried Netbean, RadRails and RubyMine. In my personal opinion it's well worth the money, and I heartily agree with weppos.
Your best bet it to try the evaluation version for a while and make your own mind up. I find IDE preferences are very subjective, the only real way to know if it's any good is to try it for yourself.
it is a little buggy and a big resource eater but has the better "intellisense", refactoring, and complementary areas support (haml) i ever seen for ruby/rails. it's appearance under mac os x is lame and is much less usable (in terms of UI usability) than any other ide. i guess that in the next major versions it will become the ruby/rails killer-ide. i would wait to buy it, as i see it as an immature project right now.
Suffice to say that Rubymine (2.5 EAP version) is the first IDE I actually like. Having used
to excellence of developing Rails apps in OS X with TexMate, when I switched the job and was forced to get along without OS X, I was quite satisfied to find Rubymine.
A veteran Emacs user (over 10 years) and recent Vim convert (gotta love the extremely powerful command system and short key bindings), I soon found that either the file navigation, cucumber editing or refactoring support was quite lacking in those. With Rubymine, I get TextMate-style file navigation which is just awesome, the only IDE which actually has a type inferencing engine and is able to capture many run-time errors during the editing phase, plus all the features I ever used in Rails projects.
Yes, I'm going to buy the software when they release 3.0 or so, and I don't know if I'll use TextMate in the future when I get again access to OS X. They say the OS X support is very good in Rubymine EAP versions, but what's nice that you can have that for every other OS as well.
Apologies for answering in short. I'll add that debugging via RubyMine is very convenient. Just set a breakpoint and try to hit the point. You can see all of your vars, set watches, and investigate objects right in the debug console.
I'd highly recommend it to any Ruby developer.
To me, there are 3 big advantages in RubyMine that other free or cheap editors/IDE's don't have (notably TextMate and Ruby VIM):
The ability to browse all the gem sources, navigate to the definition of a library method deep in a gem in a single keystroke (CTRL + B on Linux, Cmd + B on Mac), or related docs (CTRL + Q on Linux).
Graphical debugger integration. If you are debugging with print statements and the command line debugger is too cryptic too you (can't see the forest for all the trees), then the time savings alone of debugging a running test suite or live server are worth the price of RubyMine (if you value your time at all).
The continued dedication of the JetBrains team to keep up and integrate with all the whims and trends of the open source tool chain. In the 3 years, I've used RubyMine exclusively, I've seen them follow and integrate with every thing that's gaining traction. Their responsiveness is unmatched. Just 3 examples of this: Native cucumber specs in 2009, RVM in 2010, CoffeeScript in 2011.
I use it, and as of right now, don't think it's quite worth it - if you like working with a full IDE, RadRails is as good (though in different ways), and free. I admit, I haven't got all the keyboard shortcuts in RubyMine down, so I'm not as productive with it as I hope to be, but I find myself doing stuff at the command line more than I think should be necessary with a 'real' IDE. It's been pretty stable for me (on linux), the source control integration is good, and it's not as slow as it used to be (though I still end up in vim at times, if I don't want to load it). I'm hoping a 'plugin' ecology will develop around it. Overall, it's a pretty good product, but not (yet?) worth the $99 over RadRails (haven't used NetBeans)
I've used Netbeans for a while(1+ year) now. and have tried RadRails too. but i choose RubyMine cause:
the base IDE is very solid and has a
ton of plugins
it's generally more intelligent and have good refactoring abilities.
it supports a good number of other frameworks and technologies outside ruby and rails (like SaaS, haml, cucumber, shouldr, rspec...etc).
it supports my favorite version control system: git.
all in all i think if you take some time to learn its key mappings, you can be very productive with it. you wouldn't need to use a shell at all(well sometimes you might need to but...you get the idea).
just my 2 cents
I've been using Rubymine to develop Rails apps for a while now.
There was a point a few months ago when I would have been hesitant to recommend paying for it.
However the rate at which it has been improving and adding new features is really impressive.
If you're doing BDD (with Cucumber) then it's worth buying just for the step completion and navigation.
Also the features that have come from IntelliJ like Javascript, HTML, CSS, VCS support etc are excellent.
I am a former NetBeans user. I LOVE RubyMine! It has excellent rvm, git, Rspec and cucumber integration, all of which are in my stack. Go with it. You won't be sorry.
I used both Redmine and Textmate but I tend to spend more time coding in textmate. It's a matter of preference whatever gets the job done quicker is the best tool in my opinion.
Good Luck #johnrlive
I love how "project aware" RubyMine is. Coming from ST2 (which is still use daily), it's hard not to miss the elegance of an editor like ST2 but working on large scale projects with versioning, RubyMine is the IDE of choice for me. I just wish the would improve the editor and UI.
I just started to explore the IDE concept, being a happy TextMate programmer until just a couple days ago. But now that I've played with both NetBeans and RubyMine, I gotta say RubyMine rocks. NetBeans is cool for the price, but it's slow, slow, slow. Sometimes windows will lock up for long periods of time while something is apparently "thinking" - of what, I can't imagine. On the other hand, even as a fairly novice Ruby programmer, I was able to get RubyMine conversing with Git and AutoTest within a few minutes -- in short I got up and running and back to programming pretty quickly. On the flip side, I still haven't figured out how to get it to work with Heroku or Growl, but I'm still pretty new at it.
I would say depends on what your looking for. Netbeans is definitely a very capable and sufficient IDE. Rubymine shines in its autocompletion and really easy Git integration. If you have a lot of money to spare I would say ruby mine is the way to go. However, in my case, as I am a broke college student Netbeans and/or text mate does the job fine. Spending an additional minute on git outside of netbeans and using my extra monitor for documentation has worked well for me thus far.
I have just bought a MacBook for some ruby development and like the look of Aptana Studio as a really nice IDE.
The question I have, however, is that I want to know (before getting too deep into it, and potentially wasting time) is can I create plain old .rb files without the rails framework attached? Also, can I execute the ruby file straight from the IDE, or will I have to use Terminal?
As I said, I am only just learning Ruby and I am working through some books I have bought, and while I do wish to get into rails soon, I feel its important to learn the language properly, before asking rails to do a lot of stuff for me.
Any other thoughts on best practices and other potential IDE's would also be appreciated.
For just fooling around with Ruby I suggested an editor, the command line, and IRB. You will have more fun and learn more, quicker.
After that, get into IDEs and Rails and all the complexity that comes with them.
I'd recommend Netbeans (Ruby Edition obviously) or Jetbrain's RubyMine over Aptana. I've had issues with Aptana and Ruby when I tried it. Rubymine is still in public preview release status, but it will be a paid product when it's released in a month or so. It's developed by the same people who made IntelliJ IDEA. Netbeans actually works very well with ruby and rails and it's free. Both allow you to execute ruby from within the IDE and have rails support.
I've also found irb very useful, Netbeans allows you to run irb from within the IDE as well. Having code completion and inline documentation helpful when starting out.
Yes, you can create plain old ".rb" files inside RadRails or Aptana Studio, and they don't have to be inside a Rails project or "attached to the rails framework". You can also run or debug a ruby script inside the IDE by right-clicking the file or inside the editor and choosing one of the Run As > Ruby Application or Debug as > Ruby Application entries. With Studio 3 you can even run them from an embedded Terminal view. RadRails 2.x had a Rails Shell where you could run or debug files from a command-line interface as well.
As the developer on RadRails, I'm a bit biased - but I would agree that users should be pretty familiar with using the command line whether they decide to use an IDE for daily programming or not. And of course, having an interactive REPL like irb to play with is another useful tool in getting started. Heck, you can even just use the online one first before installing ruby: http://tryruby.org/