midna

Ruby interface to the Midna API.

This gem chats with the Midna API so you don’t have to. It will give you objects in the Midna namespace, which you can query like Active Record:

Midna::Channel.all
Midna::Channel.find(code)			# alphanumeric; like NL1
Midna::Episode.find(id)			# aflevering ID/episode ID from the omroep player
Midna::Broadcast.all(code)		# code is Channel code

All of these methods will return hashes or arrays of hashes.

Also, Midna is Zelda’s goth sister.

Installation in Rails

Install this plugin as a gem.

For Rails 2, in config/environment.rb

  config.gem 'midna'

For Rails 3, in Gemfile

  gem 'midna'

Then run rake gems:install.

Usage in plain Ruby

First install the gem on your machine like usual:

$ gem install midna

Use sudo if your setup requires it. After this you can require it in your code and work with Midna from there.

require 'rubygems'
require 'midna'

puts Midna::Channel.all
# => [{"name"=>"Nederland 1", "code"=>"NL1"}, {"name"=>"Nederland 2", "code"=>"NL2"}, {"name"=>"Nederland 3 & Z@pp", "code"=>"NL3"}]

Configuration

If you are using rails, create a file called config/initializers/midna.rb with the following configuration. If you are using the gem, execute these lines before you first call any Midna objects.

The gem connects to midna.omroep.nl by default. You can override this by setting the base_uri:

Midna.base_uri = 'http://some.other.host'

Prerequisites

The HTTparty gem.

gem install httparty

Copyright © 2010 Joost Baaij. See LICENSE for details.