Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

Oct 15, 2011

Welcome to Renee!

Renee is a new Rack-based library for describing web applications. Sinatra delivered a new simple way to think about building web applications. The popularity of Sinatra both as a library and as a concept shows now enduring the concept really was. Sinatra was different from Rails because the entire DSL was lightweight, easy to read and combined routing and actions into a single file. However, let's consider an example from Sinatra to see where we can improve upon this.

Consider:


get '/blog/:id' do
 Blog.get(params[:id])
end

This is not too bad so far. The repetition of :id is a bit un-DRY, but not bad. Let's keep expanding upon this.

get '/blog/:id' do
 Blog.get(params[:id])
end

put '/blog/:id' do
 Blog.get(params[:id]).update_attributes(params)
end

Now, we've retrieved blog in two places. Time to refactor. We'd normally create a before filter, with the same path.


before '/blog/:id' do
 @blog = Blog.get(params[:id])
end

get '/blog/:id' do
 @blog
end

put '/blog/:id' do
 @blog.update_attributes(params)
end


Now we've repeated the same path three times. With Renee, we can describe these kind of ideas in a simple, easy-to-read way. Here is the equivalent in Renee.


path 'blog' do
 var do |id|
 @blog = Blog.get(id)
 get { halt @blog }
 put { @blog.update(request.params); halt :ok}
 end
end


This web library is inspired by Sinatra, but offers an approach more inline with Rack itself, and lets you maximize code-reuse within your application.

Sep 10, 2011

RubyJS

RubyJS translates Ruby code into Javascript code.

NOTE that it executes the Ruby code before it translates it into Javascript.

This has the advantage of being able to (mis-)use all of Ruby's meta-programming tricks in the global scope (i.e. for defining classes and methods, NOT within methods!).

Aug 20, 2011

Ruby - Finding Unused Methods Statically

Laser can see when you don't use a method, even through some interesting cases with send and public_send See how it works, and when it doesn't!

Jul 22, 2011

Amazon Releases aws-sdk, An Official AWS SDK for Ruby Developers

Ruby is getting popular day by day!!!!
http://www.rubyinside.com/amazon-official-aws-sdk-for-ruby-developers-5132.html

Cool thing is it even supports SimpleDB in the form of ROM