Ruby Gem Dialog [duplicate] - ruby

This question already has answers here:
Case expression different in Ruby 1.9?
(5 answers)
Closed 9 years ago.
I'm trying to use the ruby dialog gem. It seems to throw some syntax errors, particularly from when statments that use a colon after the conditional.
when File: f.path
Was this syntax that was used in earlier versions of ruby, or another error entirely?

This gem is pretty old (March 28, 2008) probably written by times where ruby 1.8 was used. You're probably using ruby >= 1.9, which does not allow you to use case statement like this (with colons). If you want to use this gem you'd probably need to switch to ruby 1.8.

Related

Are Ruby keyword arguments supported by Eclipse's dynamic languages toolkit?

I have Ruby code that uses "keyword arguments" like so:
def run_cmd(command, arg1: true, arg2: nil)
...
end
When I run the code, it works as expected, but my IDE doesn't seem to know how to interpret this. It renders the formatting of my entire file incorrectly because of these keyword arguments. Are keyword arguments not supported by Eclipse's Dynamic Languages Toolkit? (I'm using DLTK version 2.0.0) If not, is there a different Eclipse plug-in I should be using for Ruby?
You don't even need to know anything about Ruby or DLTK to answer this question, just common sense is enough:
Keyword arguments were added in Ruby 2.0, which was released in honor of Ruby's 20th anniversary on February, 24th 2013. Eclipse DLTK 2.0.0 was released on June, 24th 2010, over ten years ago and almost three years before Ruby 2.0.
So, by the simple laws of phyics and some common sense, it is immediately clear that DLTK 2.0.0 cannot possibly support Ruby 2.0 keyword arguments, because they simply did not exist back then.
As a general rule, you should expect some breakage and limitations when using ten year old IDEs.

what causes the Ruby binaries to have different version numbers in the path [duplicate]

This question already has answers here:
Why are we installing Ruby 1.9.2/1.9.3 gems into a 1.9.1 folder?
(2 answers)
Closed 7 years ago.
look at this error message
/Users/abc/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/json/common.rb:155:in initialize': A JSON text must at least contain two octets! (JSON::ParserError)
from /Users/abc/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/json/common.rb:155:innew'
Under what circumstances does ruby use two version numbers?
in this case I see ruby-2.2.2 and 2.2.0
2.2.0 is the ABI version (usually only interesting to people writing extension libraries) whereas 2.2.2 is the version of the Ruby implementation and in case of MRI (used by you) also the language version. See this official post for more details about its current versioning scheme.

Is it possible to run a program step by step in Ruby? [duplicate]

This question already has answers here:
How to debug Ruby scripts [closed]
(17 answers)
Closed 8 years ago.
As I have a beginner level in Ruby, I'd like to be able to run my programs step by step to understand better what it does and be better able to debug what I type wrong.
Like with VBA for instance, where you can add "watch" to some variables and see at each step what your instructions do VS what you expect to see.
EDIT : would a debugger work on cloud9 ?
Yes. It sounds like you're looking for a step debugger like 'ruby-debug'
Please see this post: How do I debug Ruby scripts?
Another useful post (external): http://pivotallabs.com/ruby-debug-in-30-seconds-we-don-t-need-no-stinkin-gui/
For Ruby 2.0+, use byebug.
For Ruby < 2.0 use debugger or Ruby-debug.
You can also use the pry-debugger gem to tell Ruby to drop into Pry from a running script.
You might want to use JetBrains RubyMine, a Ruby IDE.
Or you could get started with using a REPL like Pry with pry-debugger.

Tips for ruby migration from 1.8? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am looking at migrating to the new ruby. The question is what is the new ruby? 1.9.3 with some patchlevel or 2.0 with some patchlevel?
Has anyone tried doing the migration? I know a lot of code is not going to be backward compatible but how do you manage production then - keep using old ruby for old code and new ruby for the latest stuff? Kind of hack it in with RVM? But then again will 1.8 code run side by side with say 1.9?
Also if I want to test for the existing code compat levels between 1.8 and 1.9 what would you recommend?
To answer your questions:
What is the new ruby? — On ruby-lang.org you'll find that currently Ruby 2.0.0-p274 (and Ruby 1.9.3-p448) are the most recent releases. If you are migrating to a new version, you should always chose the latest patchlevel.
Has anyone tried doing the migration? — Yup. I've been using both RVM and rbenv to manage different Ruby installs and gemsets (they both get the job done). This way, you can run different code in production.
...test for the existing code compat levels... — This SO answer (gee... from 2008 :-)) is pretty much comprehensive. If you have code using 1.8-specific behaviour, write an extensive test suite, switch to Ruby 2.0.0 and compare the results.
Btw.: The only problems I had when switching from Ruby 1.8.7 to 1.9.3 were encoding related, some of which could be resolved with a simple #encoding: UTF-8 comment. Other (I/O-related) code has needed some refactoring, though.
I also had some trouble with the built-in (but switchable) Syck and Psych YAML parsers, which behave a little different when it comes to serializing BigDecimal values, but that is caused by a Rails monkey patch (upgrading Rails from 2.3.x to 3.2.x or 4.0.0 is another level of pain :-)).

Ruby parsing for Notepad++ Function List panel [duplicate]

This question already has answers here:
Does anyone have parsing rules for the Notepad++ Function List plugin for Ruby and Rake
(4 answers)
Closed 9 years ago.
As of version 6.4, Notepad++ now includes a Function List panel in the core application. What needs to be added to the functionList.xml to get it to correctly parse the functions out of a Ruby file?
I have a work-in-progress on Gist:
https://gist.github.com/monban/6133403
It reads functions, but does not correctly parse classes / modules. Please feel free to fork and improve.

Resources