Given a Rakefile that executes some RSpec tests by way of a Spec::Rake::SpecTask, how can I programmatically determine the number of tests that passed, failed, and are pending once the task that ran the tests is finished?
...
Hi!
I've got some form for user registration and want to localize it via locales yml files. Especially errors from validations.
For example, locale file:
tr:
activerecord:
errors:
models:
user:
attributes:
name:
blank: "can't be blank"
it will return: name can't be blank in er...
I've got a single table inheritance structure in my application whereby Admins and Mods extends a User class. The table uses a discriminator value so each record has a type of either "admin" or "mod"
When it comes to finding a user (on login) I'd like to write the following:
current_user = User.find(params[:email => email])
However, ...
I have a Ruby app with a lot of classes/modules, and some of them are not used. Is there an easy way of finding out which?
I was thinking to do a profile, and then work with it's output. Any other ideas?
...
Is there a way to ignore XML namespaces with libxml? My problem is that the namespaces are incrementally named (i.e. ns1:, ns2:, ns3:, ns4:) depending on the records returned. This will error of I don't declare the namespace prior to parsing the data, any ideas would be much appreciated...
...
I'm using Rails with jQuery, and I'm working on a page for a simple site that prints each record to a table. The only editable field for each record is a checkbox. My goal is that every time a checkbox is changed, an ajax request updates that boolean attribute for the record (i.e., no submit button).
My view code:
<td>
<% form_remote...
I would like to be able to gather all records in a table where the user_id is not null.
This is what I have but it doesn't seem to be working (even though I've had it working in a seperate project):
named_scope :all_registered, :conditions => ["user_id != ?", nil]
...
How can I parse strings in ruby like many command line utilities do? I've got strings similar to "command [--opt1=...] [--enable-opt2] --opt3=... arg1" and methods similar to command(opt1,opt2,opt3,arg1...). I want to let arguments to come in random order, some of them can be optional.
At the moment I wrilte regexp every time I need to ...
When I recently asked about the uses of Ruby someone told me it was good for prototyping. I basically know what that means, quickly get the very base of your app up and working, see if there are conceptual problems and then add the rest.
Am I right with how I understand prototyping?
What would be a concrete example of prototyping a Sna...
I am starting out on Ruby and have heard that there is a 'Ruby way' of coding. What are some projects, apart from Ruby on Rails, that are suitable for study and is agreed upon as well designed?
...
I'm looking for some general guidance on serializing objects in a database.
What are serialized objects?
What are some best-practice scenarios for serializing objects in a DB?
What attributes do you use when creating the column in the DB so you can use a serialized object?
How to save a serialized object?
And how to access the serializ...
I'm trying to connect, read and write from a UNIX socket in Ruby. It is a stats socket used by haproxy.
My code is the following:
require 'socket'
socket = UNIXSocket.new("/tmp/haproxy.stats.socket")
# First attempt: works
socket.puts("show stat")
while(line = socket.gets) do
puts line
end
# Second attemp: fails
socket.puts("sho...
Hello,
I'm accessing a remote database using a local-to-remote port forwarding from my windows box. It works like a charm using putty for port forwarding but it fails when I try to forward using Ruby/Net::SSH. Here is my code snippet:
require 'rubygems'
require 'net/ssh'
Net::SSH.start(remote_host, user_name, :password => password) do...
I'm using modules as namespaces in ruby. How would I go about autoloading...something like autoload :"App::ModuleA", 'app/module_a that doesn't throw a "must be constant name" error?
...
I had asked a question about parsing a file in ruby. I accepted an answer and wrote the following ruby script:
file = File.open('X:myfile.txt', 'r')
file.each_line do |line|
ccyy = line[53...57]
mmdd = line[57...61]
line[53...57] = mmdd
line[57...61] = ccyy
File.open('c:\myfile_MODIFIED.txt', 'a') do |f2|
...
Hey everyone,
I am currently doing some XML parsing and I've chosen to use Hpricot because of it's ease of use and syntax, however I am running into some problems. I need to write a piece of XML data that I have found out to another file. However, when I do this the format is not preserved. For example, if the content should look like t...
I'm trying to get a better grasp of the inner workings of background jobs and how they improve performance.
I understand that the goal is to have the application return a response to the user as fast as it can, so you don't want to, say, parse a huge feed that would take 10 seconds because it would prevent the application from being abl...
I am just trying to get a simple tarantula request working, but finding it difficult without an api.
If I have a simple test like tarantula_crawl(self) I get an error like
1) Error:
test_tarantula(TarantulaTest):
RuntimeError: 9 failures
tarantula (0.3.3) [v] lib/relevance/tarantula/crawler.rb:221:in generate_reports'
tarantula ...
So...basically, I want this in my drop down:
•Nothing
•Option 1
•Option 2
•Option 3
Link to another page
Link to another page
I tried throwing a link_to to a select tag... that didnt work...
any ideas?
...
Hi,
i've got a strange behavior or autospec. On autospec run i see in console
/opt/local/bin/ruby /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.7.3/bin/cucumber --profile autotest-all --format rerun --out /var/folders/xx/xxbiSMYpEjesle1hezvfDU+++TI/-Tmp-/autotest-cucumber20100603-46558-rwbmlp-0
Missing these required gems:
cucumber-ra...