ruby

Mocking constructors in Ruby

I'm a Java-developer toying with Ruby, and loving it. I have understood that because of Ruby's metaprogramming facilities my unit-tests become much cleaner and I don't need nasty mocking frameworks. I have a class which needs the File class's services and in my test I don't want to touch my real filesystem. In Java I would use some virtu...

How do I set the HttpOnly flag on cookie in rails

The page http://www.codinghorror.com/blog/archives/001167.html explains why making HttpOnly cookies is a good idea How do I set this property in RubyOnRails ...

Refactoring in Ruby

Are there any programs or IDEs that support refactoring for Ruby or RoR? ...

How can I sort by multiple conditions with different orders?

I'd really like to handle this without monkey-patching but I haven't been able to find another option yet. I have an array (in Ruby) that I need to sort by multiple conditions. I know how to use the sort method and I've used the trick on sorting using an array of options to sort by multiple conditions. However, in this case I need the...

What's the best option for searching in Ruby on Rails?

There are several plugin options for building a search engine into your Ruby on Rails application. Which of these is the best? Thinking Sphinx UltraSphinx Sphincter acts_as_sphinx acts_as_ferret Ferret acts_as_xapian acts_as_solr Hyper Estraier ...

Which to use, eruby or erb?

What's the difference between eruby and erb? What considerations would drive me to choose one or the other? My application is generating config files for network devices (routers, load balancers, firewalls, etc.). My plan is to template the config files, using embedded ruby (via either eruby or erb) within the source files to do thing...

Why isn't there a viable mod_ruby for Apache yet?

As popular as Ruby and Rails are, it seems like this problem would already be solved. JRuby and mod_rails are all fine and dandy, but why isn't there an Apache mod for just straight Ruby? ...

In how many languages is Null not equal to anything not even Null?

In how many languages is Null not equal to anything not even Null? ...

XSLT processing in/from ruby

Can anyone recommend an efficient method to execute XSLT transforms of XML data within a Ruby application? The XSL gem (REXSL) is not available yet, and while I have seen a project or two that implement it, I'm wary of using them so early on. A friend had recommended a shell out call to Perl, but I'm worried about resources. This is fo...

Enums in Ruby

What's the best way to implement the enum idiom in Ruby? I'm looking for something which I can use (almost) like the Java/C# enums. ...

Which of these scripting languages is more appropriate for pen-testing?

First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm confortable with all of them, but the problem is that I can't focus just on one. If for example , I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's...

Best php/ruby/python e-commerce solution

I'm looking for an easy to skin and customize e-commerce package. I've been reading good reviews about Magento, but it seems to have problems with performance. I've tried osCommerce before and found it to be pretty painful to modify, but I hear zenCart is better... but the latest release of zenCart is nearly a year old, so not sure how...

Checking version of file in Ruby on Windows

Is there a way in Ruby to find the version of a file, specifically a .dll file? ...

What does BlazeDS Livecycle Data Services do, that something like PyAMF or RubyAMF not do?

I'm doing a tech review and looking at AMF integration with various backends (Rails, Python, Grails etc). Lots of options are out there, question is, what do the Adobe products do (BlazeDS etc) that something like RubyAMF / pyAMF don't? ...

How can I change the text color in the windows command prompt

I have a command line program, which outputs logging to the screen. I want error lines to show up in red. Is there some special character codes I can output to switch the text color to red, then switch it back to white? I'm using ruby but I imagine this would be the same in any other language. Something like: red = "\0123" # characte...

Mongrel hangs with 100% CPU / EBADF (Bad file descriptor)

We have a server with 10 running mongrel_cluster instances with apache in front of them, and every now and then one or some of them hang. No activity is seen in the database (we're using activerecord sessions). Mysql with innodb tables. show innodb status shows no locks. show processlist shows nothing. The server is linux debian 4.0 Ru...

SQLite3::BusyException

Running a rails site right now using SQLite3. About once every 500 requests or so, I get a ActiveRecord::StatementInvalid (SQLite3::BusyException: database is locked:... What's the way to fix this that would be minimally invasive to my code? I'm using SQLLite at the moment because you can store the DB in source control which makes ba...

How can I turn a single object into something that is Enumerable in ruby.

I have a method that can return either a single object or a collection of objects. I want to be able to run object.collect on the result of that method whether or not it is a single object or a collection already. How can i do this? profiles = ProfileResource.search(params) output = profiles.collect do | profile | profile.to_hash en...

Why don't modules always honor 'require' in ruby?

(sorry I should have been clearer with the code the first time I posted this. Hope this makes sense) File "size_specification.rb" class SizeSpecification def fits? end end File "some_module.rb" require 'size_specification' module SomeModule def self.sizes YAML.load_file(File.dirname(__FILE__) + '/size_specification_d...

Setting environment variables for Phusion Passenger applications

I've set up Passenger in development (Mac OS X) and it works flawlessly. The only problem came later: now I have a custom GEM_HOME path and ImageMagick binaries installed in "/usr/local". I can put them in one of the shell rc files that get sourced and this solves the environment variables for processes spawned from the console; but what...