ruby

Install sqlite3 on mac osx?

I just bought a new MBP I've read online Sqlite3 already exists on OSX. I've downloaded mac ports (and installed it) as well as the bin file for sqlite3 from the official web site. In a guide I'm reading about rails, which tells me to update sqlite3, I run the following in terminal: sudo port upgrade sqlite3 I receive the following ...

ruby at_exit exit status

Can i determine selves process exit status in at_exit block? at_exit do if this_process_status.success? print 'Success' else print 'Failure' end end ...

drop to irb prompt from ruby

Can I drop to an irb prompt from a ruby script? I want to run a script, but then have it give me an irb prompt at a point in the program with the current state of the program, but not just by running rdebug and having a breakpoint. ...

Unable to connect mysql from Sequel gem

When i try to connect to mysql from sequel. I am getting below errors? can you help me? require 'rubygems' require 'sequel' DB = Sequel.connect(:adapter => 'mysql', :user => 'root', :host => 'localhost', :database => 'scanty',:password=>'xx') DB.tables Sequel::DatabaseConnectionError: NameError uninitialized ...

Error running Heckle? `current_code': undefined method `translate' for Ruby2Ruby

Hi all, I'm trying to run Heckle, and I keep getting an error: > spec spec/controllers/my_controller_spec.rb --heckle MyController !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!! exception= has a thick skin. There's nothing to heckle. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (R...

Getting uninitialized constant error when trying to run tests

I just updated all my gems and I'm finding that I'm getting errors when trying to run Test::Unit tests. I'm getting the error copied below. That comes from creating new, empty Rails project, scaffolding a simple model, and running rake test. Tried Googling "uninitialized constant" and TestResultFailureSupport. The only thing I found was...

Rails not refreshing code

While developing a Rails app, I usually leave the dev server running locally (mongrel) as I work on the code. Changes in the code take affect after a quick refresh. EXCEPT changes havent been taking effect for a class I've been writing in the Lib in folder. Is this in any way a known problem? What could be causing this? It is very frustr...

how to write code blocks using maruku

how can i write code blocks in maruku for ruby,javascript currently i am using technique. but my first line moving to left. hash["test"] = "test" hash.merge!("test" => "test") h=HashWithIndifferentAccess.new h.update(:test => "test") {:lang=ruby html_use_syntax=true} ...

nested forms (design question)

Hi, I have a list of items displayed on my page. Item A [Edit] Item B [Edit] Item C [Edit] Each item is editable When you click on a edit icon. The edit form is displayed with a ajax call and the controller return a form. Edit form for Item A [Save] Item B [Edit] Item C [Edit] But all the list is bulk editable and so each item h...

How to debug/test email transfers in Sinatra/Ruby

Hey folks, Im using Pony to send email withing my sinatra applications. But the problem - i cant figure out how to debug or test it. Lest say, in php you can configure sendmail fake app (in php.ini) that will store all outgoing email as plain textfiles with all data in it. How about ruby apps? Is it possible? ...

How is Capistrano related to Rake?

I'm starting to read up on Capistrano after using Rake tasks to deploy apps for a long time. It's really striking how similar it is to Rake. A lot of parallel commands (like cap -T) and a lot of identical concepts (namespaces, tasks). Does anyone know the history behind that? Is Capistrano an extension of Rake, or built on top of it? ...

Indexing calculated field for search conditions in Thinking Sphinx

I have a products model set up that I am trying to search with Thinking Sphinx. The model has an attribute called status which can be Active, Not active or Active during specified dates. I would like to be able to restrict my search results to products that are active. I.e. has status of active or has status of active during dates and ...

Uninstall MacRuby

Does anyone know how to uninstall MacRuby? I was using RubyCocoa then decided to try out MacRuby, after installing MacRuby, RubyCocoa has stopped working. So I would like to remove MacRuby, but I cannot find any documentation on how to uninstall it. ...

Ruby On Rails and "external classes"

I have RSS-reader class for Ruby, and I'd want to use it in rails, where does the rss_reader.rb go? To "libs/rss_reader.rb"? I tried that, then requiring it in controller, but I get error: 'MissingSourceFile (no such file to load -- lib/RssReader)' ...

Creating an Excel list with Ruby

I'm generating an excel in ruby which each line represents the results of an nmap scan. An example of a line could look like that: ip, yes (because port is 22 open), no (because port 80 is not open), etc. I would like to be able to create a header line with a drop down list for each port that allow me to select if that port is open or ...

How to form "fuzzy date" in Ruby?

How do I form "fuzzy" date/time from RFC 2822 formatted (Sat, 18 Jul 2009 10:57:43 +0300) timestamp? With fuzzy date I mean like: "5 minutes ago", "2 days, 15 minutes ago". ...

Parallel Assignment and Ranges

I think the answer is simply, "no you can't do that," but my thoughts are pretty much always wrong about Ruby. I'm trying to do this in Ruby city, state, zip = (0..2) this results in city being a Range and the others being nil, which is not what I want. Is there any way to do this? ...

What is the second paramenter of TCPSocket.send in Ruby?

I am using this line to send a message via a Ruby (1.8.7) socket: @@socket.send login_message, 0 (This works fine) What is the second parameter for? I can't find the send method in the Ruby API docs... I first thought that it was some C style length of the message. This is why I used login_message.length as second parameter. That wo...

Ruby TCPSocket write doesn't work, but puts does?

I'm working on a Ruby TCP client/server app using GServer and TCPSocket. I've run into a problem that I don't understand. My TCPSocket client successfully connects to my GServer, but I can only send data using puts. Calls to TCPSocket.send or TCPSocket.write do nothing. Is there some magic that I'm missing? tcp_client = TCPSocket.ne...

Can you suggest any extended examples on object-oriented software design?

I am looking for instructional materials on object-oriented software design that are framed as extended examples. In other words, over the course of several lessons or chapters, the author would develop a moderately large piece of software and explain the design approach step by step. Ideally, the material would address not only the desi...