What is it?

This extension provides interface to libtransmission library which you can find at http://transmission.m0k.org/. You don't have to install it explicitly, since this gem comes with all required source files. I've tested it on Linux, FreeBSD and Mac OSX. It is definitely not going to work on Windows.

Installation

The only prerequisite for this library is that your Ruby must be compiled with pthread support enabled:

    $ ./configure --enable-pthread
    $ make
    $ make install

Having done that, you should be able to install this gem without problems:

    $ gem install transmission.gem

Synopsis

Assuming that you have 'progressbar' gem installed:

    $ gem install progressbar

You can use this script to download with a torrent file:

    require "rubygems"
    require "transmission"
    require "progressbar"

    session = Transmission.new
    torrent = session.open(ARGV[0])
    torrent.download_to File.expand_path('~/tmp')

    # starts a new native thread in background
    torrent.start

    progress = ProgressBar.new(" Downloading", 1.0)
    trap("INT") do
      torrent.stop
      progress.finish
      exit
    end

    until torrent.just_finished?
      progress.set(torrent.stat.progress)
      sleep 0.5
    end
    progress.finish

Enjoy.