ruby

Passenger installation with nginx fails

Hi all, I'm running an ubuntu 9.10 server on an amd-64 platform. Everything's pretty much standard, and I've got Sinatra 0.94 running on a ruby 1.8 installation. I want to install passenger in order to easily configure ssl. The problem is, it fails to find the installer. I run sudo gem install passenger or sudo gem install -r ...

Rubygems auto install from source code

Hi all, I was wondering if there was a solution to automatically - from my ruby source code - ask Gem to install various librairies my code my require to work? From what i read on the internet, it seems we are obliged to either use an install script that directly runs "gem install ..." commands or do it manually or some people have pos...

How can a Ruby script detect that it is running in irb?

I have a Ruby script that defines a class. I would like the script to execute the statement BoolParser.generate :file_base=>'bool_parser' only when the script is invoked as an executable, not when it is require'd from irb (or passed on the command line via -r). What can I wrap around the statement above to prevent it from executing ...

Sinatra does not support multiple lines ?

For the following code, why does only "World" gets printed get '/' do "Hello" "World" end ...

Rails: Proper work flow to shred XML data into relational SQL database

I have a Rails project and I used Migrations to setup the database schema (I'm using sqlite3). I have a XML file that I want to insert into my database. What's the best way to approach this? I'm thinking there's some Ruby script that I can write once and use to parse the XML file and insert it into my database, but intuitively it feels l...

Making calls to a ruby lib from a java web app

We have a j2ee/spring/hibernate/tomcat web application already running on production. We are planning to integrate with a 3rd party service(recurly) which provides a ruby client lib. They don't have a java client lib yet. Their service is RESTful and their client is a thin custom wrapper over ActiveResource. I can think of a few ways to ...

How to generate XML file using Ruby and Builder::XMLMarkup templates?

As you all know, with Rails it is possible to use Builder::XMLMarkup templates to provide an http reponse in XML format instead of HTML (with the respond_to command). My problem is that I would like to use the Builder::XMLMarkup templating system not with Rails but with Ruby only (i.e. a standalone program that generates/outputs an XML f...

generating excel documents with RUBY

I need to generate excel documents with ruby (from rails) on a Linux Machine. I know of Spreadsheet::Excel, but it doesn't support formulas, and uses a pretty old format.. Is there any other option, not necessarely free or opensource, that is a bit more powerful? thanks ...

How to use bundler (0.9.1.pre1) with Rails and CouchRest

I want to use the current version of bundler (there have been quite some changes from 0.8 to 0.9) to mange the gems of my Rails app. First I created a Gemfile in the root of the app folder and added all the needed gems to it. Then I placed (as recommended in the manual) the following code to my config/environment.rb: begin # Require t...

Rails Rake Tasks, output a message during and at the end.

Hi, I've made a rails rake task that uploads/crops/re-sizes (with paperclip) silly amounts of images. I wanted to know how to output a message to the terminal when it was running (e.g. chipolata.jpg processed) and at the end, it takes a good few minutes to run and a little feedback would be good. Thanks. ...

Ruby On Rails Development Machine

Hi Folks, I'm starting with Ruby-On-Rails development on Linux machine. I want to know which Linux distribution will be best suited to do ROR development. Also what will be the best (free) IDE for ROR on Linux. ...

Describing class relationships in ruby

I've never done any straight ruby coding - only worked with the Rails framework. I am not sure how to describe the relationships between Classes, other than inheritance relationships. For example, a School object may have many Student objects. I would like to be able to make calls like "myschool.student[2].first_name" and "mystudent.sc...

Choice of tool-set: scala, ruby, java and more

I'm part of a group that starts a new development project from scratch. Currently it is on hobby-basis but we aim to make it our living in the time frame of 1-2 years. We are senior developers coming from a multitude of languages and techniques with much of the focus on Java for the last few years. Now, we're thinking of choice of tools...

Ruby net http time out

I'm trying to write my 1st Ruby program, but have a big problem. The code has to download 32 mp3 files over http. It actually downloads a few, but then timeouts. I've tried setting a timeout period, but it makes no difference. Run the code under Windows, Cygwin and Mac OS X with the same result. This is the code: require 'rubygems' requ...

Rescue RuntimeError in Rake

I have a custom Rakefile which calls different file tasks. Sometimes a file that is expected doesn't exist, and rake throws a RuntimeError and fails. However, I'd like to do a few things before it fails. So is there any way I could rescue a RuntimeError? Or is there some sort of a magic task which gets called before a complete fail? ...

Problem with a regex

I want a regex that will match: A type with an ID: [Image=4b5da003ee133e8368000002] [Video=679hfpam9v56dh800khfdd32] With between 0 and n additional options separated with @: [Image=4b5da003ee133e8368000002@size:small] [Image=4b5da003ee133e8368000002@size:small@media:true] I have this so far : \[[a-zA-Z]*=[a-zA-Z0-9]*[@[a-zA-Z]*:...

Rack-Bug panels won't appear in my Rails app

I've installed Rack-Bug for my Rails app, but can't get the panels to appear. project: http://github.com/brynary/rack-bug additional instructions: http://wiki.github.com/brynary/rack-bug/security yet more instructions: http://stackoverflow.com/questions/1912983/rack-bug-installation-issue-server-does-not-start (the docs really suck for ...

Replace words from a dictionary

I have an array of hashes, each hash has two keys : "from" and "to" @dictionary = [{:to=>"lazy", :from=>"quick"}, {:to=>"flies", :from=>"jumps"}, {:from => "over the", :to => "under the"}] I have some long string @text = "quick brown fox jumps over the lazy dog" How can I replace all occurences of "from" sentences to "to" sentences...

Algorithm for sorting a nested/adjecency model in Ruby

I've been trying to find a good way of doing this, either on the client side in Javascript or at the last minute within the server. This is a Rails application but it is a pretty generic question. I have a model that is hierarchical, and is currently stored in a nested set model. The model then has: parent_id, lft, and rgt I would lik...

Getting some elements in a string using a regex

Context Using Ruby I am parsing strings looking like this: A type with an ID... [Image=4b5da003ee133e8368000002] [Video=679hfpam9v56dh800khfdd32] ...with between 0 and n additional options separated with @... [Image=4b5da003ee133e8368000002@size:small] [Image=4b5da003ee133e8368000002@size:small@media:true] In this example: [Im...