Deploy A Free, Ruby Powered Blog In 5 Minutes with Toto and Heroku »
Created at: 05.02.2010 22:22, source: Ruby Inside, tagged: Cool Tutorials
Toto (GitHub repo) is a new lightweight Ruby and Rack-based blogging engine designed specifically for "hackers" by Alexis Sellier. Content is managed entirely through Git - so everything is version controlled - and articles are stored as text files with embedded YAML metadata. At only 300 lines, it's easy to hack to your own taste, too.
Alexis has decided to push Toto by demonstrating how easy it is to deploy - for free - on the Heroku platform. You can literally get a blog up on Heroku within 5 minutes, even if you haven't already got a Heroku account (I just tried it).
How To Do It
Here are the basic steps:
- Sign up for an account at Heroku.com - all you have to do is provide an e-mail address, validate it, then enter a password.
gem install herokugit clone git://github.com/cloudhead/dorothy.git your-blog-dir- cd your-blog-dir
heroku create- Use the URL returned by
heroku createand add a line in to theToto::Server.newblock inconfig.rulike:set :url, 'http://your.heroku.url.here' - git commit -am "Added URL"
- git push heroku master
- You're live!
It's that simple - I just tried it (see http://furious-fire-87.heroku.com for a live demo)! Beyond this stage, you need to check out Toto's documentation and actually add some posts to your Toto install, customize the template, and what not.
If you're interested in lightweight systems like Toto, check out Scanty and Jekyll (which includes a blog-like system but at heart is designed to cope with full sites).
more »
Rails 3.0’s ActiveModel: How To Give Ruby Classes Some ActiveRecord Magic »
Created at: 13.01.2010 18:46, source: Ruby Inside, tagged: Cool Ruby on Rails Tutorials
One of the biggest benefits of bringing Merb developer Yehuda Katz on board to work on Rails 3.0 has been his relentless pursuit of extracting out all of Rails' magical abilities from their monolithic encasings and into separate, manageable chunks. A case in point is ActiveModel, a new library that provides the model related parts of ActiveRecord but without the database requirements.
Get Rails-like Model Behavior on Any Ruby Class
In extracting the model-building parts of ActiveRecord, ActiveModel makes it possible to add model-like behavior to any Ruby class, with no Rails or databases required. In his latest blog post, ActiveModel: Make Any Ruby Object Feel Like ActiveRecord, Yehuda shows off how to get Rails-style models with validations, serialization, callbacks, dirty tracking, internationalization, attributes, observers and all the other Rails goodness.
Example Code
I've taken Yehuda's main example of using ActiveModel on a non Rails class and extended it with some code that actually uses the model:
require 'active_model' class Person include ActiveModel::Validations validates_presence_of :first_name, :last_name attr_accessor :first_name, :last_name def initialize(first_name, last_name) @first_name, @last_name = first_name, last_name end end a = Person.new("Fred", nil) a.valid? # => false a.last_name = "Flintstone" a.valid? # => true
Installing ActiveModel
If you're interested in ActiveModel and not so much in Rails 3.0, installing it is reasonably easy (though not as easy as only installing a gem just as yet):
- Go to or make a temporary directory
git clone git://github.com/rails/rails.gitcd railsrake gemgem install activesupport/pkg/activesupport-3.0.pre.gemgem install activemodel/pkg/activemodel-3.0.pre.gem
Once this is all done, the code example above will work.
As an aside, if you fancy having a go with the full pre-release (a.k.a. "pre") version of Rails 3.0, check out Dr Nic's slightly out of date but otherwise useful guide.
more »
Cramp: Asychronous Event-Driven Ruby Web App Framework »
Created at: 08.01.2010 01:36, source: Ruby Inside, tagged: Cool Miscellaneous
Cramp (GitHub repo)is a new, asychronous evented Web app framework by Pratik Naik of 37signals (and the Rails core team). It's built around Ruby's EventMachine library and was designed to use event-driven I/O throughout - making it ideal for situations where you need to handle a large number of open connections (such as Comet systems or streaming APIs.)
Out of the box, Cramp relies on Rails 3.0-pre's ActiveSupport and ActiveModel libraries (and won't work with earlier versions). Using these, it presents you with two layers to develop: controllers and models. Cramp controllers are ostensibly Rack compliant (Rack was designed primarily for synchronous scenarios) but Thin is currently the only HTTP daemon that can run Cramp apps due to its asynchronous app support.
Cramp models are built around a custom asynchronous MySQL-only ORM built on top of Arel and ActiveModel. Compared to the controllers, it seems to be at a very embryonic stage though it supports data methods like all, first, each, where, select, group, order, limit and offset. For basic CRUD functionality, it should do the job fine.
Pratik has a basic "hello world" example to show off the general structure of a Cramp app:

To learn more, read Pratik's Introducing Cramp blog post. He's presented a lot of examples to get you going.
more »
CoffeeScript: A New Language With A Pure Ruby Compiler »
Created at: 05.01.2010 01:03, source: Ruby Inside, tagged: Cool
CoffeeScript (GitHub repo) is a new programming language with a pure Ruby compiler. Creator Jeremy Ashkenas calls it "JavaScript's less ostentatious kid brother" - mostly because it compiles into JavaScript and shares most of the same constructs, but with a different, tighter syntax.
To get a feel for the language, check out this example code (CoffeeScript on the left, resulting JavaScript on the right):

As a Ruby project, you can get the CoffeeScript compiler installed with a simple gem install coffee-script or check out the code from/on GitHub. The code is worth a look as it's notably quite vanilla with hand crafted Ruby covering the lexer and code generation and Racc built code for the parser.
more »
Friendly: Easy Schemaless “NoSQL” Data Storage with MySQL in Ruby »
Created at: 21.12.2009 15:49, source: Ruby Inside, tagged: Cool Elsewhere
Friendly is a new Ruby ORM (a la ActiveRecord) that lets you easily use NoSQL ideas on regular database engines, such as MySQL. Developer James Golick has written a blog post introducing Friendly that goes into detail on how it works - with code examples. Effectively you get schema-less, document-like storage (with indexes!) but based around MySQL.
If you're not familiar with "NoSQL", it's a blanket/branding term (somewhat like AJAX or Web 2.0) that covers non-relational forms of databases that, typically, have no need for SQL. A common subset of NoSQL technologies is the "document-based database," as provided by systems like CouchDB or MongoDB (for which RailsTips author John Nunemaker has evangelized strongly).
An issue many people are having with the various NoSQL systems available is that they're not all "battle hardened" or as familiar to administer than their existing MySQL or Postgres systems. Social aggregator FriendFeed wrote about how they use MySQL to store schema-less data, and Friendly is based on the same techniques.
more »
