How to Use Another Gem Source With Bundler - ruby

So I know that I can specify another remote source in my Gemfile, like
source 'https://rubygems.org'
source 'http://my-gem-location'
For my use case I want this to be S3 (I can create an http address to the gem there).
What I am confused about is what format the gem should be at this endpoint. Right now its just a series of directories and .rb files which doesn't work. I get an error like:
Fetching source index from http://my-remote-repo
Retrying source fetch due to error (2/3): Bundler::HTTPError Could not fetch specs from http://my-remote-repo
Retrying source fetch due to error (3/3): Bundler::HTTPError Could not fetch specs from http://my-remote-repo
Could not fetch specs from http://my-remote-repo
I figured if its zipped or something that might help but my testing leads to nothing but this error. I also could not find much helpful documentation on hosting remote gems. Does anyone know how I can get this to work?

The gem should be in .gem format to do that you need to do:
gem build <yougemname>.gemspec
You can find comprehensive information on creating a gem here:
http://guides.rubygems.org/make-your-own-gem/
Hope it helps!

Related

Access gem source code in Cloud 9

I would like to open up and edit gem source code but I can't figure out how to in cloud 9.
Stack Overflow wants me to make this question longer but it really is that simple. Where is the damn code at?
You can find the location of gems by issuing one of the following commands:
rvm gemdir
gem environment (look for the gem path)
Cloud9 operates like any other terminal. The following is helpful if the gem has a unique name, as you will get fewer (better) results. I will use will_paginate for example:
sudo locate will_paginate
Since Cloud9 comes packaged with light permissions for the main user, you will benefit most from using sudo like above.
On my machine, the results include sub-directories in the two following locations:
/home/hstevens/.gem/ruby/gems/will_paginate-3.0.7
/usr/local/lib/ruby/gems/1.9.1/gems/will_paginate-3.0.7
Depending on whether you installed your gem as root or not, your results should include one or both of the above locations. (Actual paths may vary slightly.)

Issue in uploading gem to Geminabox

I stood up a Rack server with Geminabox, running on my machine at http://localhost:9292. Now I was trying to upload the gem to the server (from a different tab on the terminal acting like a client), but when I type:
gem sources -a http://localhost:9292
I get the following error:
Error fetching http://localhost:9292:
bad response Not Found 404 (http://localhost:9292/specs.4.8.gz)
There is a trailing colon and I'm a bit lost, any help on that?
Thanks!
You need to upload at least one gem before Geminabox starts to serve the necessary files.
(I know this is an old question but I came here from google so others might as well)

can you get the Gem object to return a list of available gems in the path?

I am having issues getting my local gems to work on my web server. I keep getting no such file to load errors even though I have added my local gem dir to my .gemrc paths. I am hoping to find a way to at least see what gems I DO have access to.
I have tried adding my local gem path a couple ways including
Gem.path.push "/myHome/usrName/ruby/gems
with no luck. How do I do something like
Gem.available_gems.each do |g|
puts g
end
?
Try using Bundler. It manages your gems for you and lets your project know where to find them when employed properly. On production servers it can install a local copy of the gem so that you don't need to worry about setting up your path vars correctly.

How to Look at a Gem's Code

I have a Gem that I found at RubyForge and want to peek inside to see what code it contains. Is it possible to do this without installing the Gem on my system?
Also, if I use RVM on Mac OS X, does that at all change how my gems get installed (assuming I have one gemset)?
gem unpack unpacks the gem without installing it.
Gems on RubyGems usually have a link to the source code (most often on GitHub), in which case you can easily browse the code (I use this A LOT).
The "homepage" link also tends to link to the repository.
If all else fails, go to GitHub and search for the name of the gem (you may need to match up the authors to ensure it's the right repository for the gem).
Edit:
Just noticed that you asked about gems on Rubyforge. In which case my first step would be to check RubyGems. But otherwise you will need to download the gem and peek inside it (it's just a compressed archive so you can open it up in something like 7-zip).
Many gems have their source freely readable. The way that always works is to install it.
If you just want to browse the source; go to the gem on http://rubygems.org find your gem and use the "Source code" link.
In case of RubyForge you can find the links under the SCM link in the menu.

Generating RDOCs for locally installed gems

I am trying to contribute to a gem I recently took interest in - Nesta. The developer has done a great job in creating one of the lightest, thinest CMSs you can find and I want to document it. I have read through the code and commented on a few methods to the best of my knowledge.
However, I seek to test this out locally by calling gem server and seeing the changes on my machine before pushing it online.
Things I have tried:
Manual edit.
Documented the file.
Fired up gem server.
Using the gem tool.
Documented the file.
Ran gem rdoc nesta --rdoc
Restarted gem server
All to no avail. Please help.
Thank you.
You can preview generated html pages without installing a modified version of the gem on your machine. Add this to nesta's Rakefile:
require 'rake/rdoctask'
Rake::RDocTask.new('doc') do |i|
i.rdoc_files = FileList['lib/**/*']
end
and type rake doc. Then view generated html/index.html file.
Are you sure you've installed the version that you've modified, not the original version?
If you've installed the modified version, but have forgotten to install the rdoc, see Can you install documentation for existing gems?

Resources