Searching String(s) in file(s) using Ruby is very simiple. Here is the sample code to manipulate it.
# searching a string in a file
def print_line_containing(file, str)
File.open(file).grep(/#{str}/).each do |line| puts "#{line}" end
end
# searching multiple strings in a file
def print_line_containing(file, str1, str2)
File.open(file).grep(/#{str1}\s+#{str2}/).each do |line| puts "#{line}" end
end
# searching multiple strings in multiple files
def print_line_containing(file_array, str)
file_array.each do |file|
File.open(file).grep(/#{str1}\s+#{str2}/).each do |line| puts "#{line}" end
end
end
I hope this will help you all!
Saturday, June 13, 2009
Wednesday, June 10, 2009
Building Shopping Cart with Ruby on Rails in few minutes
we can easily build a shopping cart application in a fraction of few minutes.
http://code.google.com/p/substruct/
Use the above link and download the substruct application. Follow the instructions like installation, svn updating the substruct engine, and etc., from the left nav bar on that page.
Then you will get the shopping cart application with payment integration with the Active Merchant plugin.
Get use of open source and explore your thoughts with your application.
http://code.google.com/p/substruct/
Use the above link and download the substruct application. Follow the instructions like installation, svn updating the substruct engine, and etc., from the left nav bar on that page.
Then you will get the shopping cart application with payment integration with the Active Merchant plugin.
Get use of open source and explore your thoughts with your application.
Subscribe to:
Posts (Atom)