- gem install rubygems-update
- update_rubygems
Thursday, December 18
Tweak: updating ruby gems
Monday, December 8
Range Class in Ruby
x..y: includes the end values
(1..5).each do n
puts n, ' '
end
(1...5).each do n
puts n, ' '
end
In the first literal case, values 1, 2, 3, 4, 5 would be printed. Whereas, in the second litereral case 1, 2, 3, 4 only will be printed.Interestingly methods end/alias would still give the end value of the range. In such case, end_excluded? is apt choice to distinguish.
Wednesday, November 12
Integration Testing: xml_http_request

xml_http_request "/store/add_to_cart" , :id => ruby_book.id
and strangely I was getting syntax error. Seems the book did miss out another parameter which would define the method type. Referring to online documentation, made things clear.
xml_http_request(request_method, path, parameters = nil, headers = nil)
Performs an XMLHttpRequest request with the given parameters, mirroring a request from the Prototype library.
The request_method is :get, :post, :put, :delete or :head; the parameters are nil, a hash, or a url-encoded or multipart string; the headers are a hash. Keys are automatically upcased and prefixed with ‘HTTP_’ if not already.
Saturday, November 8
Ajax even @ home - I am serious

Have a nice weekend :)
Thursday, October 16
SnappyFingers - a new way of learning through FAQ's
Let me put it this way, just search through relevant topic and keep filtering the appropriate website(s). I feel many of us would like to understand a topic with basic and frequently asked questions What? Why? Where? How? Which? Who?
Matching to above criteria and thinking process, I found a new product in the market "relevant answers for your frequent questions" - SnappyFingers. It's a smart explorer that would fetch across the relevant answers for your questions. SnappyFingers made the process of finding answers pretty easier.
Thursday, September 4
My Experiments with Google Chrome - 3
Google's Chrome Terms of Service take out a royalty-free license for Google of any content submitted by users over the internet...
Read it from source... http://tapthehive.s483.sureserver.com/chrome.html
Wednesday, September 3
My experiments with Google Chrome -2
My experiments with Google Chrome -1
profile usage:
I extensively make use of this profile feature. I create multiple profiles, based on my work.
- To create new firefox extension.
- To test the extensions.
- For office work.
- ...
- ...
Though I prefer using stumble to bookmark my favorite pages, for quick reference I store some on Firefox bookmark tool bar. When I tried with chrome, it had imported bookmarks randomly from one of the firefox profiles.
Addon's:
I feel the usability of browser increases with these add-on's, extensions.
Google Chrome
I am always eager about the products that comes out of Google. I am under impression that whatever Google comes out with will have more usability, simplicity, to the point, light weight... and I can go on listing them.
From Google's official blog entry, I went through the story behind building the Google Chrome. It was quite impressive and it shows the approach is really good.
keep watching and experimenting...
Wednesday, August 27
RoR course: RSS Maker/Parser
I would like to share the details of how Ruby supports to generate and read the RSS. Before going into details, let us look into few basics of what we are going to deal with.
Note: An RSS document is often referred as “feed” or “web feed” or “channel”.
What is RSS?
- Really Simple Syndication.
- It is a easy way to share defined content and news/titles/posts from www
- RSS is written in XML
Why use RSS?
RSS can be updated automatically; this enables users to track/monitor their favorite sites, news channels, websites… without even going/visiting the sites. Since it is simple, light and fast-loading this can be used even in PDA’s, mobiles thus ensuring the accessibility even simpler.
Who should use RSS?
RSS is ideal to be used if the source is dynamic. In the sense that would change rapidly for say new sites, micro/web blogs… RSS is not meant for static pages, website that doesn’t have updates frequently.
With so many websites/blogs/calendars… everybody generating the RSS, the reading/grabbing job is taken care by “RSS/feed reader” or “aggregator”. These aggregators can be either desktop based or web based. The user needs to subscribe his favorite site feeds by submitting the RSS link provided by the site to these aggregators and they would send the user the subscribed updates as and when they occur.
Parser:
Parser identifies the feed Url provided and reads the document and we can publish the feed with our own display options. So all that we need is a simple feed url. Let us say we need to publish the feed content of particular site on our blog/site.
Since there are multiple versions of the RSS available based on the version we need to include/require those libraries while parsing the feed.
- A controller that would handle all the feed related actions, includes/refers the required libraries.
- An action/method that would use the rss/parser library to read the feed.
- Extract the necessary elements/content.
- Pass on the elements/content to the views.
require 'open-uri'
require 'rss/0.9'
require 'rss/1.0'
require 'rss/2.0'
require 'rss/parser'
require "rexml/document"
class RssFeedController <>
#This action is used to get the rss feed of the blog mentioned
def parse_feed
url = 'feed url'
rss = RSS::Parser.parse(open(url){|fd|fd.read})
item_rss=rss.items.collect{|item|item.title}
item_link=rss.items.collect{|item|item.link}
@p=item_rss.length
@postfeed=item_rss
@postlink=item_link
@link="url of the link"
return @postfeed,@postlink,@p,@link
end
end
The view part will be a list of articles/content displayed looping over the length of feed.
<%@postlength.times do|i|%>
<li>
<a class="define style" target="_blank" href="<%=@postlink[i]%>">
<%=@postfeed[i]%>
a>
li>
<%end%>
Thus we are done with parsing or reading the existing feed or RSS document.
The view part will be a list of articles/content displayed looping over the length of feed.
Maker:
Maker creates/generates the feed/RSS document of a site/blog. Since there are multiple versions of the RSS available based on the version we need to include/require those libraries while making the feed.
- A controller that would handle all the feed related actions, includes/refers the required libraries.
- An action/method that would use the rss/maker library to read the feed.
- Extract the necessary elements/content.
- Pass on the elements/content to the views (RHTML/RXML).
def generate_feed
version = "2.0"
content = RSS::Maker.make(version) do |m|
m.channel.title = "Title of the post/entry"
m.channel.link = "http://www.linktopost.com"
m.channel.description = "Describe the post"
i = m.items.new_item
i.title = "Ruby to generate RSS feeds"
i.link = "http://www.linktopost.com"
i.description = "Describe the post"
i.date = Time.now
end
end
As you find the above two actions were created for RSS 2.0, hence we have the elements as title, link, description, date… which are as pert RSS 2.0. Based on the version we are referring/using they would change accordingly.
This is a static content based on which we created the feed, to create a dynamic feed say for the posts, articles should iterate over them and pass the info accordingly.
In nutshell, Ruby provides the RSS support with
RSS::Maker.make
RSS::Parser.parse
There are umpteen number of rails plug ins were created and available for rails community that were built on the above mentioned core ruby classes.
Feed Fetcher
Feed Tools
Resource Feeder
Atom Feed helper
…
…
…
This document is prepared as part of Ruby on Rails course that I am writing in blog TechSavvy.
Have something to discuss/suggest/enhance: Reach me tosumanthkrishna (gmail)
References:
http://en.wikipedia.org/wiki/RSS
http://www.w3schools.com/default.asp