Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
|Failed to load latest commit information.|
LandSpeeder =========== LandSpeeder is a simple rails plugin that let's you use ActiveRecord as a short-term cache. I use it to wrap around slow XML-RPC API calls to make my rails apps move a little quicker. You can always get the latest version of this plugin from Github: - http://github.com/jamesotron/LandSpeeder [web url] - git://github.com/jamesotron/LandSpeeder.git [clone url] If you're using LandSpeeder in production please email me and give me your feedback to email@example.com. Feel free to fork LandSpeeder on github and or send me patches, I'm always interested in use cases. LandSpeeder is released under the Mozilla MPL 1.1, all code is copyright 2009 James Harton. Example ======= Install LandSpeeder using the plugin script: $ ./script/plugin install git://github.com/jamesotron/LandSpeeder.git From http://github.com/jamesotron/LandSpeeder * branch HEAD -> FETCH_HEAD * Generating model and migration... exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/speeder.rb create test/unit/speeder_test.rb create test/fixtures/speeders.yml create db/migrate create db/migrate/20100210013406_create_speeders.rb * Backing up existing model speeder.rb * Making model polymorphic... * You probably want to run rake db:migrate now. * Done. LandSpeeder will generate a model and migration called Speeder, which you can safely remove if you don't want to use the default model. If you want to use the default Speeder model then run $ rake db:migrate to create the table in your database. Now on any models you want you can simply add an acts_as_landspeeder line and then use the accellerate function to overload accessors (or associations): class Channel < ActiveRecord::Base require 'rss' require 'open-uri' acts_as_landspeeder accellerate :title do # Download our RSS feed and parse out the feed title. open(self.url) do |s| RSS::Parser.parse(s.read,false).channel.title end end end >> rubyforge = Channel.find_or_create_by_url("http://rubyforge.org/export/rss_sfnewreleases.php") => #<Channel id: 1, url: "http://rubyforge.org/export/rss_sfnewreleases.php", title: nil, created_at: "2010-02-10 02:29:07", updated_at: "2010-02-10 02:29:07"> >> rubyforge.title => "RubyForge New Releases" >> rubyforge => #<Channel id: 1, url: "http://rubyforge.org/export/rss_sfnewreleases.php", title: "RubyForge New Releases", created_at: "2010-02-10 02:29:07", updated_at: "2010-02-10 02:29:12"> You can force a cache expiry by calling the method with an excelmation mark on the end. (eg: title!) Copyright (c) 2009 James Harton, released under the Mozilla Public License version 1.1