How to get Shoes to use an already installed gem? - ruby

I have a ruby gem I created and installed and want to be able to use it in a Shoes app. As expected, Shoes reports it cannot find the gem, understandably since the gem is only installed for the standard ruby distribution. Can help pointing towards documentation explaining how to get Shoes to find this gem would be most appreciated.
Thanks.

Unless things have changed since _why left, this is not possible. Shoes is a separate Ruby installation and therefore needs its own gems.
To install a gem, you can do something like this at the beginning of your Shoes app:
Shoes.setup do
gem 'json'
end
Edit: there's also this previous SO thread:
Using Ruby libraries and gems with a Shoes app

U can think Shoes as a ruby-distro, like jruby or other rubies, it maintains its own gems.
therefore you will need to install it via shoes way like Michael Kohl said

Related

Errors/Warnings in Ruby Wordnet Gem

I've noticed that there are a lot of errors/warnings with the ruby Wordnet gem.
Does anybody know how to get rid of them? Or if the Wordnet gem is being actively maintained? There also seems to be errors using the Wordnet gem with Ruby 1.9.2 (which I've been able to get around following steps in https://gist.github.com/1779371)
Thanks
Maybe have a look at the rwordnet gem instead?

Getting newer gems

I'm really just a beginner to ruby, so hopefully this is an easy one. I've got to the point where I'm starting to look into some of the gems that the community have put together. I decided to check out something that would help my application consume rss feeds. So, headed over to rubygems (which is where i thought people go to get these kinds of things) and searched for rss. I found this one;
http://rubygems.org/gems/simple-rss
instructions were to just install the gem with
gem install simple-rss
So far, so good. When i came to actually use the gem, the documentation I received from doing the above was a bit naff, so i searched a bit further and found the git repo;
https://github.com/cardmagic/simple-rss
The documentation there (their code examples) complain about missing methods etc. and after a bit of digging I came to the conclusion that I must have downloaded an older version of the gem than the git trunk.
So, my question is, should I be using rubygems to get the latest gems, and if not, what other resources are out there to help find the latest builds of the comminities gems?
As far as finding a good gem for a task — use Ruby Toolbox, since it also shows you how actively maintained a gem is. Here's, for example, a section on feed parsing.
If you want to get the latest gem code that hasn't been released yet, you could download the code directly from github and build the gem yourself. However, it's easier to use bundler for that. It allows you to create a Gemfile for your project looking something like the following.
gem 'simple_rss', :git => "git://github.com/cardmagic/simple-rss.git"
Then run bundle command to download and build these gems from their corresponding sources.
In general, bundler is a great solution for managing gem dependencies for any ruby project. It provides ways to quickly reference any released gems, automatically builds gems directly from a git source, git refs, or paths on your filesystem, and has other convenient features.
By far the best place for all things Ruby & Ruby on Rails for the devs is the Ruby Toolbox

Can gems be assigned different interpreters?

I fee like I've seen that this was possible in some documentation before, but now I'm not able to find it. Is it possible to have a gemfile like:
gem "somegem", :interpreter => :MRI
gem "othergem", :interpreter => :macruby
etc, etc
I am needing this because in macruby some gems do not work, so it'd be great if you could get around that this way.
Are you looking for the platforms parameters? :platforms => mri_19 and so on. They only alow you to specify which gems to run under the current platform not how to run the gems.
EDIT: Anyways if you are not building any Cocoa applications use CRuby (MRI) by default, as it the most complete implementation of Ruby, or try RVM for handling multiple Ruby installations.

Nothing known about.... when trying ri String#upcase Ruby

I have just installed the RVM and I am reading The Well-Grounded Rubyist book. In the first chapter I am supposed to try ri String#upcase to view documentation on the upcase method, however I get a message saying:
Nothing known about String#upcase
I found some posts here on SO telling me that it probably is because RDoc is not installed. However I do not understand how to fix it.
I am using Mac OSX 10.6, and latest RVM. I have only installed 1.9.2, in addition to the standard Ruby interpreter which come along with the Developer kit from Apple.
Did you generate the docs?
rvm docs generate
https://rvm.io/rubies/docs/
RDoc is installed, I'm not sure why that particular lookup does not work. Perhaps somebody else can shed some light on that.
However, if you just need to find out about how to use particular parts of the API, you can't go wrong with a google search. All of the Rdoc documentation is available online from numerous locations.
Here's String#upcase for example: http://ruby-doc.org/core/classes/String.html#M001155
It might be that docs aren't working because you're using the latest ruby version, 2.1, in which rvm has some problems. It doesn't generate docs, thus you can't retrieve the docs with ri.
**Error: **
Your ruby version 2.1.2 is not supported, only 1.8.7, 1.9.2, 1.9.3,
2.0.0

How to distribute a Ruby application with the required gems

I've developed a Ruby application (a small game), and I would like to 'distribute' it to other people.
However, I am not sure what to do about the required gems. If I just send my application to someone who have ruby installed, but not the required gems, I assume it will blow up. Can I package the gems locally? If so, would it conflict if the other person has a different version of the gem?
So, what is the smart/proper/good way of doing this?
The best way would probably be to just package your game as a gem as well, that way rubygems will take care of installing the dependencies. Here's the documentation explaining how to create your own gems.
If you'd rather not package your game as a gem, you could investigate the Bundler, which will be integrated into Rails 3.
In your environment.rb you can express your gem dependencies, eg.
config.gem "activemerchant", :lib => "active_merchant", :version => "1.4.1"
This isn't as automatic as gem dependencies, but it certainly usable. User must sudo rake gems:install to get your app to start.
If you're looking for a way to create OSX .dmg's and Windows Installers, there's a gem called releasy that will do all of that for you, and it is specifically tailored for releasing GUI apps written in Ruby. It bundles up Ruby and all your gem dependencies in to a single executable so that your end user doesn't have to install anything extra.
You will need access to a Windows/OSX environment to make the installers.

Resources