JewelryPortfolio

Surely also lazy developers like to showcase their jewelry portfolio on their GitHub pages.

Imagine writing an erb template once and use rake release to release your gem with Jeweler as usual, but in addition re-generate and push the index.html for your GitHub pages. If that sounds good to you, you’re in luck. Because that’s exactly what this add-on for Jeweler does.

Usage

GitHub pages repository

First things first; create a GitHub pages repository if you haven’t done so already. See github.com/guides/pages for more info.

Then create the following files, and content, in the master branch of your pages repository (for a more elaborate example see: http://github.com/alloy/alloy.github.com/tree/master):

  • Rakefile:

    require 'jewelry_portfolio/tasks'
    JewelryPortfolio::Tasks.new do |t|
      t.     = 'Fingertips'
      t.name        = 'passengerpane'
      t.version     = '1.2.0'
      t.summary     = 'A short summary about the project.'
      t.description = 'A longer description about the project.'
    end
    

    The account is only necessary when you haven’t configured github.user in the local or global git config. (For more info see: github.com/guides/local-github-config.) Or if you want to override the account that was retrieved from the git config.

    The other attributes are only necessary when there’s no gemspec file in the work directory.

  • template.html.erb:

    This is the main template file which will be used to generate the index.html file. All repositories and their gem specifications are available as the local variable repos. See JewelryPortfolio::Template and JewelryPortfolio::Repo for more information.</em>.

    <html>
      <head>
        <title>Alloy&rsquo;s jewelry</title>
      </head>
    
      <p>This is an overview of the available gems by Eloy Duran, aka `alloy'.</p>
    
      <body>
        <% repos.each do |repo| %>
          <%= repo_partial(repo) %>
        <% end %>
      </body>
    </html>
    
  • repo.html.erb:

    This file is completely optional; it’s just a showcase of using a repo partial.

    <div>
      <h1><a href="<%= repo.url %>"><%= spec.name %> <%= spec.version %></a></h1>
      <p><%= spec.description %></p>
      <p>Install: <code>$ <%= repo.gem_install_command %></code></p>
      <p>Clone: <code>$ git clone <%= repo.clone_url %></code></p>
    </div>
    

Now you can generate the index.html file with:

$ rake portfolio:generate

Since you haven’t added any projects yet the generated index will be pretty dull. But for now just release this version:

$ rake portfolio:release

Whenever you update the template you can use these tasks to preview and/or release it.

Add super-cow powers to your project’s Rakefile

Update the Rakefile of the project that you would like to include in your jewelry portfolio like so:

begin
  require 'jeweler'
  Jeweler::Tasks.new do |s|
    # ...
  end

  # Add the following to your Rakefile to use JewelryPortfolio
  begin
    require 'jewelry_portfolio/tasks'
    JewelryPortfolio::Tasks.new do |t|
      # Only specify the account if it's different from `github.user' in the git config.
      t. = 'Fingertips'
    end
  rescue LoadError
    puts "JewelryPortfolio not available. Install it with: sudo gem install Fingertips-jewelry_portfolio -s http://gems.github.com"
  end

rescue LoadError
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
end

From now on, whenever you use the release rake task, the GitHub pages index.html will be re-generated and pushed to GitHub after releasing the gem.

If you just want to re-generate, or release, the jewelry portfolio use the aforementioned portfolio:generate and portfolio:release rake tasks.

Note that it isn’t necessary to use Jeweler to be able to use JewelryPortfolio.

Copyright © 2009 Fingertips, Eloy Duran. See LICENSE for details.