Regentanz

Regentanz (German: rain dance) is a Ruby library to connect to Google’s innofficial (ie. undocumented and unsupported) weather API.

Installation

The gem is not published yet and can be installed from github:

git clone git://github.com/kaupertmedia/regentanz.git
cd regentanz
gem build regentanz.gemspec
gem install regentanz-<gemversion>.gem

Much easier using bundler:

# Gemfile
gem 'regentanz', :git => "git://github.com/carpodaster/regentanz"

Usage

Supply a location and a language to retrieve weather:

weather = Regentanz::GoogleWeather.new(:location => "Berlin, Germany", :lang => :en)
weather.current   # current condition
weather.forecast  # array with forecast conditions

It uses file-based caching by default, other cache backends will follow. See Regentanz::Cache::Base for details (and if you want to create your own backend).

Configuration

Regentanz can either be configured through a configure block or directly via its configuration object. It uses sane defaults so there should be no need for configuration to start right off. If you’re using Regentanz with Rails, a file in config/initializers is your friend.

Configure block:

Regentanz.configure do |config|
  config.cache_backend Regentanz::Cache::File 
  config.cache_dir "/path/to/cache_file"
end

Direct configuration:

Regentanz.configuration.cache_dir = "/some/other/path"

See Regentanz::Configuration for a full list of configurable options.

Credits

Regentanz is based upon and extracted from a standalone Ruby class made for berlin.kauperts.de by kaupert media gmbh.