Just out of interest, are there any easy to setup and work with code coverage tools for jRuby-1.5.3 and jRuby-1.6.5:
Testing coverage (C0, C1, C2)
Performance (Memory use, memory leaking)
Best practices
That would be a great idea to write down your thought, as I'm trying to break through this for almost a week.
Thank you.
To question #1, so far as I know, code coverage for JRuby 1.6.x running in 1.9 mode is blocked on this open defect: JRuby 6106
If you're running in 1.8 mode, you should be able to use the rcov gem.
Related
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.
I was using NetBeans but it seems that support for Ruby is officially dead (with some community element just starting up). I've seen threads for hacking ruby-debug to support Ruby 1.9 debugging in NB but I just feel like that's not the way to go. I just installed Aptana3 which will happily hit breakpoints but there's no support for watch expressions which limits visibility. I can't seem to find a straight answer as to why it's not supported or whether there are any plans to include it.
Is there a clear winner for debugging Rails3/1.9.2 in some sort of text editor?
RubyMine 3.0 by Jetbrains will let you debug Rails 1.9.2 like NetBeans used to do. While RubyMine is not free, it is affordable and a great Rails development environment.
Notice
I do not work for JetBrains, I'm just a very satisfied customer.
I'm using Netbeans and JRuby to develop a Rails web application.
But for deployment, I will be using Heroku.
Since Heroku uses the Ruby-C implementation, I was wondering my use of JRuby can cause problems? Is this approach a safe thing to do?
You can develop in NetBeans and use C-Ruby (aka MRI Ruby). Just install Ruby separately, go to Ruby Platforms, and select it. I highly recommend you install a separate Ruby anyway, whether or not it is MRI Ruby, because if you use the built-in NetBeans version of JRuby (which is often not the latest) and then upgrade NetBeans, you'll lose all the gems you've installed. Installing Ruby/JRuby outside of NetBeans helps you to better manage the versions and gems.
Now to answer your questions: Likely you will not encounter problems with basic Rails applications. If you ever have the need to use non-native libraries you may run into issues. Some gems (e.g. Nokogiri) have a C version and a Java version so you'd be OK, but if you wanted to use a plugin that relied on RMagick, for example, you'd struggle, as you'd probably go a different route if you were developing and deploying with JRuby.
Bottom line: I wouldn't recommend it. I'd recommend using the same platform for both. But you can use MRI Ruby in NetBeans.
funny thing: I stumbled in your question while looking for a tool chain to do it the other way round (developing in MRI Ruby, deploying with JRuby). Of course you can not use any Java classes and internals, but this for sure is obvious to you. According to my results thus far you shouldn't encounter any process structural issues, because MRI Ruby adheres to the shared nothing principle whereas your requests in the development app share the VM at least. Maybe to be shure you should hae a look at http://kenai.com/projects/jruby/pages/DifferencesBetweenMriAndJruby and read it in a reverse sense, especially the "Native Endian is Big Endian" paragraph when un-/packing Strings or Arrays.
You will save yourself a lot of trouble if you develop on the same platform as you deploy. This goes for OS as well, especially Windows then deploying on Linux, less so with OSX, but still sometimes an issue. You will be troubleshooting on your deployment system and that just isn't the same as catching something as you code it in development. I recently started using JRuby for a project and there are quite a few differences and different gems altogether in some cases.
As for loosing installed gems etc. take a look at using Bundle while you are at it, that will also save you some trouble down the line with gem versions out of sync.
My current Rails development environment is Aptana + RadRails plugin on Windows XP and it's a little slow running tests, rake, and generators.
If you've evolved and proven your Windows Ruby on Rails development environment into something you're happy with and is fast, please share the details below.
Many thanks,
Eliot
http://www.akitaonrails.com/2009/1/13/the-best-environment-for-rails-on-windows
try this guide
To add on to Omar: instead of dealing with VMWare, you could install Portable Ubuntu, which runs inside Windows. Though you will get a performance hit from doing so, it will give you a Linux environment to work in and you won't have to worry about installing another operating system.
Although I work primarily with Ubuntu now, I was using a windows machine with Vim on it. Vim has a plugin called rails.vim. It understands the rails structure very well. These the things I found very useful.
Navigation between model, controller, unit test, functional test within 3-4 keystrokes using :RModel, RUnittest, :RFunctionaltest, RController.
Ability to run a unit/functional/integration test right away using :Rake
A quick jump to console using :RConsole
A quick jump to helpers using :RHelper
the goto file 'gf' shortcut now behaves in a predictable manner. It even looks up files inside gems you have installed.
The video on the site hardly does any justice to it. If you are not a vim user, then I would suggest E text editor. It is not free but worth every penny you pay.
I am led to believe that Rails (well, Ruby, really) on Windows is generally slow, compared to *n[iu]x, but since I haven't experienced the latter, I remain blissfully ignorant. In particular, there's a lag while the Rails environment loads that is tedious even on a fairly fast (3GHz Xeon) box.
On top of that, there's the overhead that an IDE brings. Of the more recent, I've tried NetBeans and RubyMine. Both are very capable and a little slow, compared to my normal working environment of command line and test editor, which pretty much suffice 95% of the time: I find I don't need much IDE support when I'm developing test-first. I still find myself mostly using SciTE, largely because of the "Run" command being easily accessible. With a little tweak to the "require test_helper" line in my tests, a single test execution is no more than a F5 away, and the whole suite available from the command line with a quick "rake".
If I need to debug into the framework to clear up (usually) some misunderstanding on my part, then I currently lean towards NetBeans, where the debugger seems a little more intuitive. I suspect RubyMine may have more power, but I haven't found myself needing it yet.
Irrespective of all the above though, the key to performance on Windows is the time to execute `environment.rb' and that's not an easy nut to crack. (Here's hoping I'm totally wrong and I've missed something super-cool, btw.)
I would seriously consider against Rails development inside Windows and my reasoning behind it is because you won't be using a Windows machine in production.
You will most likely be running some sort of Linux machine because Passenger wont work on Windows, mongrel_cluster (last time I checked) also doesn't run on Windows and IIS is a nightmare. Trust me, consistency between development and production is a huge bonus.
If you must run Windows, then I would recommend running Rails inside a Virtual Machine with a Linux distribution of your choice. That way you could use something like e-texteditor (which comes highly recommended as a great alternative to Textmate) and have a Samba share to a git/svn repository on your Virtual Machine.
Check VMWare Server out and install CentOS / Ubuntu. It's free and will give you an insight into development in Linux which is ultimately where you want to be at.
I'd recommend jruby for windows.
Ruby in Steel isn't bad if you want to use Visual Studio.
It's got it's issues, but it's not as "slow" as the eclipse variants I've tried.
RadRails so far has the most complete code completion I've seen, as it knows about your models and such far more than Ruby in Steel. Even if it's slow to load the data for it, at least it's there.
If there are not immutable reasons that you are using Windows XP, you should just switch to Linux. There are none of the weird compatibility issues that arise on Windows. If your application will eventually be deployed to a linux machine, it's easier to develop on. Plus, it would solve your performance issues.
https://help.ubuntu.com/community/RubyOnRails
If there are constrains that make Windows absolutely necessary, please revise and specify.
I currently use TextMate for all my Rails development, and I like it very much, but I wonder if I'm missing anything by not using an IDE. Has anyone switched from using TextMate or another powerful text editor to a Ruby IDE? Am I missing anything?
JetBrains, the people who created the legendary IDEA IDE for Java, have RubyMine in beta. DHH has mentioned it, so it must be good!
TextMate is king for Development on Mac, it's not too bloated and has so many good bundles made by the developers that use those particular languages. Can't be beat in my opinion.
I think IntelliJ/RubyMine is pretty good because I've been coding Java for a while. There's some feature holes for Rails development, but I expect that Jetbrains will quickly fix those in coming versions.
I just got turned onto Textmate because my laptop is a Powerbook 12" G4. Running IntelliJ is pretty snappy, but it makes the fans run constantly with a volume approaching "airplane engine". Working with Textmate keeps my laptop quiet.
In my opinion textmate is the best IDE if you have a Mac. It is highly customizable and you can pretty much do everything you want with it. Plus a lot of developers are using textmate for rails and therefore creating scripts and features that you can import and use.
I'm using Aptana with radrails when I'm on windows, but it's not as good. Plus you can't customize it as much. The other issue is that since it's based on eclipse it's quite ressource intensive and from my experience it's not as stable as textmate.
Aptana has some cool features, like being able to call script/generate and rake tasks directly from the interface, but this is something I could live without.
Aptana RadRails is one of the best Ruby IDEs out there, with Rails support, HTML editors, etc. It is a plugin for Eclipse, and is also supplied standalone.
I use Netbeans because I like the test support and test coverage features combined with the fact that I can use it for multiple languages & environments. They really try to provide a complete environment but I find I still have to step out to the command line a lot - starting thinking_sphinx, running cucumber, tailing logs etc.. so it is never quite comprehensive. It is also slow as hell on my slow as hell laptop.
I used the eclipse rails plugin for a while and it is also pretty good but Netbeans had a pretty good feature surge for 6.5. that won me over.
If you're on Windows you may want to look at "Ruby in Steel"
I've just found it and have not worked with it much nbut the experience so far is good. So if you use VisualStudio for your job this may be a nice addon to help get Ruby into the same environment.
On a mac it is probably not worth it as TextMate is very optimized for Rails development through bundles. I did use AptanaIDE when I was on Windows though. The main problem here is not the IDE itself but the fact that it is not useable (as in snappy enough) on the machine I had. And strangely enough for a Ruby programmer I believe that a program that makes editing unformatted text feel sluggish on a 1Ghz/Gbyte machine is doing something wrong.
Has anyone switched from using TextMate or another powerful text editor to a Ruby IDE? Am I missing anything?
Yes, I recently switched from Vim to RubyMine. (And I also used TextMate before that.) Personally I think the tradeoff is worthwhile, because of how well designed and well implemented RubyMine is. So the quality of the tool makes up for the heavier footprint.
The things I felt I was "missing" with Vim included well-implemented code completion, open files by typing partial filename, click on a symbol to go to the declaration, and a lot of other stuff.
I really like Komod for Ruby and Python development.