ruby

Hpricot, Get all text from document

Hi Guys, I have just started learning Ruby. Very cool language, liking it a lot. I am using the very handy Hpricot HTML parser. What I am looking to do is grab all the text from the page, excluding the HTML tags. Example: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Data Protectio...

Where is the ruby standard library directory placed on a Mac?

I want to read some ruby code. And I think this is the good place to start dig in. But I cant find it. ...

Write to XML in ruby

I am completely new to Ruby. All I want is to produce a simple XML file. <?xml version="1.0" encoding="ASCII"?> <product> <name>Test</name> </product> That's it. ...

Importing CSV file into Rails sqlite3 database

Hi, I have created Rails database using the following schema: ActiveRecord::Schema.define(:version => 20090807141407) do create_table "trunks", :force => true do |t| t.integer "npa" t.integer "nxxFrom" t.integer "nxxTo" t.string "trnk" t.datetime "created_at" t.datetime "updated_at" end end In my CSV...

Looking for non-Rails content management system

I'm looking for a CMS writen in Ruby and not based on Ruby on Rails, are there some projects? ...

Type-indifferent comparison in Ruby

I'm sure this is a basic question in Ruby: Is there a way to check if a == b even if a is an integer and b is a string? I realize that I can do a.to_s == b.to_s but I'd like to know if there's some other, better way. Edit: The question originally had a typo and said a.to_s and b.to_s which was edited after parsenome pointed out...

Ruby: com object output parameter

I'm working with WIN32 COM Object from Ruby via win32ole library require "win32ole" #~loading com object o = WIN32OLE.new('{1A80830AF-4CA5-11D4-BC26-991045698E9C}') #~invoking "Process" method o.Process(parameter_1,parameter_2) "Process" method has two parameters: parameter_1 is input xml string and parameter_2 is output xml string ...

Ruby method, Proc, and block confusion

I have a couple questions about Ruby's methods, procedures, and blocks that strike me as rather odd. They're not so much about syntax or function as the logic behind the decisions made. Question 1: Why is it that blocks can be passed to methods (e.g. each) but they cannot be assigned to a variable? I know you can pass them around in ...

Inserting a string after a certain character in Ruby

Hi, I have to insert a string after a certain character using Ruby. For example, if I have a line like the following: (N D CGYRWIFGD2S7 0 1 N)(N D CGYCGYOVFBK0 0 N N)(ISA N N N CGYCG3FEXOIS N PUB NONE N N 0)(ISA N N N CGYCGYFGAOIS N PUB NONE N N 0)(ISA N N N CGYCG2FGAOIS N PUB NONE N N 0)(N D CGYCGYOVFBK1 0 N N)(N D CGYLOCFGA2S7 0 N N...

Get Search Engines to link to sub-pages instead of index

I wrote a blogging system from scratch (http://seanhess.net). I have the last 10 posts displayed on the index page /, and each post has it's own page /post/a_simple_post. I'm getting a good rank in google when I search for specific info from my posts, but google links to the index page instead of the post page. How do I get the search en...

How to get Sinatra to auto-reload the file after each change?

I am using # my_app.rb load 'index.rb' and start the sever like this ruby my_app.rb but it never reload any changes I made in index page. Did I miss anything here? thanks ...

Equivalent of Django Signals for Rails?

In Rails, the closest I've seen to Django Signals are Observers. The problem with them is that they're restricted to triggering callbacks on hardcoded events related to a model's lifecycle. Django signals can be created anywhere, triggered anywhere and handled anywhere. The model lifecycle callbacks are just regular signals that happen ...

Refresh Button on a Rails View

Hi, I have a list view in my RoR web app. The view is a result of a scaffold operation. I want to add a button that will refresh the page. I prefer not to use javascript for this one, is there another way? Creating a button via button_to or form_tag ends up adding a new blank row in the database when it is clicked. Thanks! Shay. ...

db:migrate order in Spree

I'm using spree and created a new payment gateway extension. The problem is, my newly created payment gateway gets created first before the core payment gateway of spree. Here's the error message. doesn't exist: SHOW FIELDS FROM gateway_options ...

How do you consume a json or xml web service in Rails or Ruby?

An external web service is sending json or xml towards my app. What would be the best way to consume this data? Is there a built-in library in Rails or Ruby to do this or do I need to use a gem for this? ...

Ruby url to html link conversion

I'm building a simple chat app with Rails. when a user types in a url, I want it to be output as an html link (ie, "url"). I was wondering if there is any library or well known way to do this in Ruby. If not, I've got some decent regex sample code to work with... ...

Best practices to parse emails with Ruby

Hello Ruby/Rails/Merb developers! Im currently working on a web project that will have a feature to communicate with clients by email. So, let`s say i created account for a customer in my admin panel, then created a topic/thread to discuss questions, tasks and other work-related stuff. So, the customer will receive email notification. A...

has anyone tried installing ruby & rubygems from source on ubuntu (preferably unbuntu 9)?

The Ruby on Rails website recommends installing Ruby from source under Linux. I encountered a number of C library problems building ruby from source on a clean install of Unbuntu 9. All the instructions I found on the net about installing ruby on ubuntu have involved using the prepackaged (.deb-based) ruby. Clearly this isn't what the r...

Is there a way I can find out why a module fails to load? some kind of trace/verbose mode?

The ruby extensions in the "ext" directory of my ubuntu ruby interpreter i.e. zlib, etc, io, ... fail to load. I mean they're recognized as extensions - I don't get a "no such file" error, yet they fail to load (i.e. return false). Running this: puts require 'zlib' prints "false" Is there a way of tracking down why a module fails...

calling another method in super class in ruby

class A def a puts 'in #a' end end class B < A def a b() end def b # here i want to call A#a. end end ...