Accessing rdoc files from one place - ruby

In Ruby, if you run the command gem server it will present you with a web page of documentation for all the gems you have installed on your machine. Can something similar be done for your local documentation, so that all of your local rdoc documentation is in one easy to access place? Any advice would be much appreciated, thanks.

Though this question is a bit old, here's what I would do:
Create gems out of your projects. You don't have to publish them just keep the gemspec on your local
Generate your local documentation from the root of your projects. This should give you two separate docs folders (if you have two projects)
Use gem server --dir=/path/to/project/one --dir=/path/to/project/two
OR
You can generate the documentation for each project using rdoc in their root folder
Then open each doc/index.html as a separate tab in your browser ;)

Related

How to find apps on Github, that use a specific Ruby gem?/contain a specific line of code?

I am trying to use a gem. Let's say, gem "milia", and want to find other people that use it in their apps in order to benchmark. Is there a way to search for apps that have this line of code in their Gemfile?
A workaround is to:
search for reverse dependencies on RubyGems (eg. for milia)
find the list of projects consuming the gem
check if each project are using a github repo (check github badge or home page on rubygems)
Ok, now it can easily be done in github by looking at /network/dependencies path like https://github.com/jekuno/milia/network/dependencies

Releasing Ruby Application for Specific users

I am new to Ruby and I have written a small app, that consists of around 50 .rb files and 6 folders. The purpose of app is to be an SDK for Ruby users, to interact with my API. It also uses few gems. Now I want to release this app for specific users, but looking at the internet for the solution really confused me (may be just because I'm new to it) and MOST of the posts found were for Rails
Being through several posts, what I find to be reasonable is to make a gem out of it and publish this gem at rubygems.org. (but this also makes it fully public)
Question:
Is this the correct approach in my specific scenario?
How can I manage the dependencies? (This part is very confusing, I will need more guidelines on this)
How to limit audience? (I have personal git server, would this be of any help)
Other Info:
App is developed in Ruby version 2.1.8, It makes http Get/Post requests using TLS, and is NOT a Rails or web app
I have been through several SO posts like THIS, THIS etc. But I couldn't understand it for my case.
I created a project in Jetbrains' IDE, called RubyMine. My project doesn't have bin folder, etc. but only my own folders and .rb files. And most of the solutions also talk about bin.
Any help will be appreciated.
Gemfury is probably what you're looking for. You'll package your library as a gem the same way as if you were going to publish it publicly on RubyGems, but Gemfury lets you restrict access to it to only the people you want to allow.

What's the most common way for including a howto/documentation in a ruby-gem?

I saw that if the gem is installed also the rdoc is generated and you can access the rdoc by
gem server #->localhost:8808
I am thinking of the most common ways how to describe a ruby-developer how to use the gem that was installed. Where i am coming from (java) the apidocs/howtos e.g. are already included in the jars.
I saw that there is a kind of README.rdoc file -convention(?) and thought maybe that's where the ruby-developer will start looking after downloading a gem?
It depends on the developer.
If the README is heavily marked up (e.g., lots of Markdown or RDoc) it's often most convenient to use gem server to access the Gem documentation from a local gem doc server.
Or follow the www link in the gem server listing, or read the file manually.
Additional documentation source is generally included in the doc directory, built using normal Ruby tools (rake and/or rdoc).
I'm not entirely sure what you're asking, though. First, Java libraries generally don't include the API docs or source, they're generally bundled separately, particularly if you're using Maven. Gems include the source, so RDoc can always be generated.
In Java, examples are only present if (a) the developer (IMO abuses) Javadocs by including the examples in the API docs, or (b) examples are included in the source and you have the source. It's rare there are "howtos" in a downloaded Java library, unless it was developed using Maven, you package the site, and the site includes usage pages beyond the normal API reports.

Packaging precompiled binaries inside of a gem

I've got a ruby web app that uses lilypond to generate sheet music based on user input. I'd like to move the hosting to heroku (I've recently used heroku on a few projects and really liked it, plus my traffic is low enough that it'd be free host it on heroku, for a while at least). However, heroku's dyno architecture doesn't allow you to ssh in and install whatever packages you want...instead, you give it a gems manifest, and it will install the gems for you.
So, if I'm going to deploy to heroku, I'm going to need to package lilypond as a gem. I've released a few pure-ruby gems, but haven't dealt with native extensions or precompiled binaries, or anything like that.
Is it possible to take some precompiled binaries and package it inside a gem? Ideally, this would include binaries for OS X (which I develop on) and debian linux (which is what's running on heroku), and would install the proper binary when the gem was installed.
it is possible, since precompiled binary gems for windows are the norm. Take a look at rake compiler, perhaps.
also https://github.com/rdp/ruby_tutorials_core/wiki/gem (https://en.wikibooks.org/wiki/Ruby_Programming/RubyGems) might help
-r
I think you've got a few options here:
You could get the Lilypond source and package it into a gem with a native C extension. There are some useful guides on how to do that at http://guides.rubygems.org/c-extensions/ and http://patshaughnessy.net/2011/10/31/dont-be-terrified-of-building-native-extensions
There's also a gem called gitara but I haven't been able to find any information about using it on Heroku. It might be worth emailing the author and asking if he knows anything about that.
You could create a Heroku buildpack that installs Lilypond as part of your deployment. I wasn't able to find any for Lilypond, but there are plenty of examples that do similar things - for example, this one installs Imagemagick (which is included by default on Heroku, so probably not necessary anymore - but hopefully the code is helpful). More documentation at https://devcenter.heroku.com/articles/buildpack-api and https://devcenter.heroku.com/articles/buildpack-binaries
Based on my reading, I think the buildpack option is the best way to go.
Hopefully this helps!
Instead of precompiling, you should be able to just list the gem in your .gems file, see the Heroku documentation. Of course, this requires your gem builds the native code correctly - this is still a task, but hopefully an easier one.

What are the steps needed to create and publish a rubygem of your own?

So you've created a ruby library.
How do you create and publish your rubygem? And what common pitfalls and gotchas are there pertaining to creating and publishing rubygems?
There are several tools to help you build your own gems. hoe and newgem are the best-known, and have a lot of good qualities. However, hoe adds itself as a dependency to your gem, and newgem has become a very large tool, one that I find unwieldy when I want to create and deploy a gem quickly.
My favorite tool is Mr Bones by Tim Pease. It’s lightweight, featureful, and does not add dependencies to your project. To create a project with it, you just run bones <my_project_name> on the command line, and a skeleton is built for you, complete with a lib directory for your code, a bin directory for your tools, and a test directory. The configuration is in a Rakefile, and it’s clear and concise. Here's the configuration for a project I did a few months ago:
load 'tasks/setup.rb'
ensure_in_path 'lib'
require 'friend-feed'
task :default => 'test'
PROJ.name = 'friend-feed'
PROJ.authors = 'Clinton R. Nixon'
PROJ.email = 'crnixon#gmail.com'
PROJ.url = 'friend-feed.rubyforge.org'
PROJ.rubyforge_name = 'friend-feed'
PROJ.dependencies = ['json']
PROJ.version = FriendFeed::VERSION
PROJ.exclude = %w(.git pkg)
Mr Bones has the standard set of features you’d expect: you can use it to package up gems and tarfiles of your library, as well as release it on RubyForge and deploy your documentation there. Its killer feature, though, is its ability to freeze its skeleton in your home directory. When you run bones --freeze, a directory named .mrbones is copied into your home directory. You can edit the files in there to make a skeleton for your gems that works the way you work, and from then on, when you run bones to create a new gem, it will use your personal gem skeleton. You can unfreeze Mr Bones by running bones --unfreeze and your skeleton will be backed up, and the default skeleton will be used again.
(Editorial note: I wrote a blog post about this several months ago, and most of this is copied from it.)
I recommend github as a place to start, especially for open source projects.
And try a google search as well... Very first search result for me...
http://www.5dollarwhitebox.org/drupal/creating_a_rubygem_package
You may also want to checkout the Hoe gem, which can automate the gem creation process.
See: http://nubyonrails.com/articles/tutorial-publishing-rubygems-with-hoe
I actually wrote a tutorial on exactly this, and I wrote it as I was learning. It's more focused on the game I'd written than a library. Also, it assumes you want to build the gem via rake rather than on your own:
Part 1 on how to create the gem.
Part 2 on how to run binaries installed by your gem, and get to resources.
hoe no longer adds itself as a dependency as off rubygems 1.2. Its rake tasks are focused on deployment of the rubygem to rubyforge. If you just want to serve the gem from github I think there some new hoe-esque rake task tools to help.

Resources