The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
What's in Camping 1.4?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
What's in Camping 1.4? Posted: Feb 23, 2006 4:06 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: What's in Camping 1.4?
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

Okay, you can try out Camping 1.3.69 from gems. Camping is a microframework. Railsish aesthetics for wee CGIs.

 gem install camping --source code.whytheluckystiff.net

Sessioning

To get sessions working for your application:

  1. require 'camping/session'
  2. In your application’s create method, add a call to Camping::Models::Schema.create_schema
  3. Throughout your application, use the @state var like a hash to store your application’s data.

More notes about this at CampingSessions on the wiki.

Helpers#URL

Builds a complete URL to a controller route or a path, returning a URI object.

Assuming the Hoodwink.d app is mounted at http://localhost:3301/hoodwinkd/, in a controller or view you’ll see the following results:

  >> URL()
  => (URI:http://localhost:3301/hoodwinkd/)
  >> self.URL
  => (URI:http://localhost:3301/hoodwinkd/)
  >> URL(Static, 'js/prototype.js')
  => (URI:http://localhost:3301/hoodwinkd/static/js/prototype.js)
  >> URL("/boingboing.net/setup")
  => (URI:http://localhost:3301/hoodwinkd/boingboing.net/setup)
  >> URL("http://google.com")
  => (URI:http://google.com/)

Find it also in the new docs.

Service Overrides

Adding stuff like sessioning and authentication demands hooks on the controller. Rails uses hooks like before_filter to do this. Camping doesn’t have bytes to spare to make this happen, but things have been re-stacked to let you slide in new service methods which intercept all controller calls.

 class LoginError < Exception; end
 module ClownsOnly
   def service(*a)
     unless @state.occupation == :clown
       raise LoginError, "For clown's eyes only." 
     end
     super(*a)
   end
 end

This service method can be slid into your application’s top module like so:

 Camping.goes :Blog

 module Blog
   include ClownsOnly
 end

Fully explained at Before and After Overrides on the wiki.

Read: What's in Camping 1.4?

Topic: Ruby: Un Lenguaje Libre para Programación Orientada a Objetos Previous Topic   Next Topic Topic: A Little Language Labeling

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use