I wonder if this has its place on StackOverflow, but since it IS programming-related, I will shoot it away.
Here's my problem. I am new to TDD and I love Ruby, so the obvious path I'm taking is testing stuff with rspec. Why obvious? I saw it in diverse screencasts and thought it was really neat. Then I saw "autospec" somewhere, and trie...
Hello,
I have this problem when I try to use "script/generate":
$ script/generate start
/Users/gst/.gem/ruby/1.8/gems/hpricot-0.8.1/lib/fast_xs.bundle: [BUG] Bus Error
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10]
Abort trap
I am using Snow Leopard on my 32-bit MacBook Pro. Just installed it.
I already tried to reinstall Ru...
I'm aware that Rails has a few different levels for logging, but how can I only log the things I want it to, or rather, I only want things in my log that I specify with logger.debug
Is it possible to create my own logging level?
Also (last part of my question I swear) it seems that when Rails is in development mode, it ignores my logg...
Let's say I have a hash in Ruby like this:
d = {1 => 'one', 3 => 'three', 2 =>'two'}
and I wish to get
x = [1, 2, 3]
y = ['one', 'two', 'three']
that is, I want the sorted keys in x, and the corresponding values in y. I potentially want to use a custom sort order for x.
What's the cleanest, simplest way to do this?
...
given an xpath say
can you do something like
doc.xpath("/html/body/a").wrap("<span></span>")
and wrap all the links with span tags ?
...
Ruby is the most popular language at Github by far. Compare that with the questions at Stack Overflow or the TIOBE index.
What is the reason for this difference in relative popularity in different places?
...
What's the best way to implement ActiveRecord's find() and save() methods for an ActiveMerchant ActiveMerchant::Billing::CreditCard object in a Ruby on Rails application?
I'd like my credit card objects to inherit from ActiveRecord and ActiveMerchant.
Caveat: I understand that saving credit card information to a database is always con...
I have a tables Foo and Bar. Foo has one Bar. When I query Foo, how can I order it by a date column in the Bar table?
Thanks
...
What I want to do is use a CGI script (written in Ruby) to read a binary file off of the filesystem (audio, specifically) and stream it to the browser.
This is how I am doing that so far,
require 'config'
ENV['REQUEST_URI'] =~ /\?(.*)$/
f= $config[:mdir] + '/' + $1.url_decode
f = File.open f, 'rb'
print "Content-Type: audio/mpeg\r\n"...
I'm writing a program that involves playing back sine waves and combinations of sine waves... it must run on Mac, and I'm looking for a simple API that I can use. I'm open to ObjC, C, C++, Ruby, Python, etc.... I don't care what language as long as it's just a few lines of code. But Ruby would be nice :-)
On Linux you can write to /dev/...
hi all,
i want to know whether there are libraries like java httpclient in ruby?
great thanks.
...
I'm getting error:
uninitialized constant ActionView::Helpers::JavaScriptElementProxy::ActionView
I've tried forcing a reinstall of jrails which didn't fix the error, and Googling the error has yet to yeild a result. Any suggestions? Ruby 1.9.1, Rails 2.3.4.
...
so i parsed an html page using nokogiri.
i want to wrap tags around each occurence of links
.wrap() doesn't appear to work properly.
puts doc.xpath("//a").wrap("<b></b>");
returns just plain regular unchanged html.
...
hi all,
i'm using windows xp sp2, and installed ruby through ruby 1.9 one click installer. then when i try to using ri, i get the following response, can anyone help me with my problem? great thanks.
C:\Documents and Settings\eyang>ruby --version
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
C:\Documents and Settings\eyang>...
I am doing Python challenge in Ruby. I need to read the file contents and comments from a Zip file. The content is no problem with the RubyZip gem but I am unable to get the comments out. Any ideas?
...
Hey there,
I'm currently learning RoR and I've got the following problem:
My Model, "DataFile", has a bunch of fields which I'd like to set from outside the Model, e.g.
file = DataFile.new
file.owner = 123
Now, as far as I know, I'd have to place an "attr_accessor :field" in my model, for every field that I'd like to modify from ou...
This is a pretty specific problem, but I'm wondering if anyone would have a brilliant solution. I'm trying to fit a string with a fixed font size in a box of arbitrary size, such that, if the whole string doesn't fit, I want to trim it and ad an ellipses (...).
So if my text is "the netherlands" I want to determine what portion of th...
As far as I understand JRuby, it is perfectly possible to use Java class inside JRuby code and vice versa, however, I still don't understand few things.
can JRuby work with Java Annotations?
is it possible to use reflection from JRuby on Java class?
is it possible to use reflection from Java on JRuby class?
do I have executable classes...
Is there a way to determine what version of Ruby is running from within Rails (either on the web or through script/console)? I have Ruby 1.8.6 installed but I've also installed Ruby Enterprise Edition 1.8.7-20090928 and want to ensure that it's using the right installation.
...
I really need help with Rubygems (that's the package manager for ruby). Since I'm behind a proxy, I've given up all hope of it working automatically, so I had to download a lot of packages manually and install them for rails to install. Now, I'm getting an error message:
Rails requires RubyGems >= 1.3.2 (...)
Once again, I manually dow...