ruby

Is Cucumber broken under Ruby 1.9.1 and Rails 2.3.2 ?

I'm installing Ruby 1.9 and Rails 2.3 in Ubuntu 9.04. I want to learn about Cucumber. Is Cucumber broken under Ruby 1.9.1 and Rails 2.3.2? ...

How do I get the contents of an http request in Ruby?

In PHP I can do this: $request = "http://www.example.com/someData"; $response = file_get_contents($request); How would I do the same thing in Ruby (or some Rails method?) I've been googling for a half an hour and coming up completely short. ...

Ruby templates: How to pass variables into inlined ERB?

Hello! I have an ERB template inlined into Ruby code: require 'erb' DATA = { :a => "HELLO", :b => "WORLD", } template = ERB.new <<-EOF current key is: <%= current %> current value is: <%= DATA[current] %> EOF DATA.keys.each do |current| result = template.result outputFile = File.new(current.to_s,File::CREAT|File::TRUNC|File::R...

Haml/Sass Syntax Highlighting in Notepad++?

Has anybody made this yet? ...

How to store ruport table data object in a database?

I intend to store a nightly build of report data in a DB and then use formatters when a user requests for a report in real-time. A few clues... The Ruport::Data::Table object - that contains the data - is a collection of Ruport::Data::Record objects, accessible via the 'data' attribute i.e. Ruport::Data::Table object *=> Ruport::Data:...

ruby soap datatime adds Z at the end

Hi I have some strange behavior with ruby. In a rake file I pass in a date to soap method. In the response it appends a Z at the end of the date. in a lib file, same thing, same requirements, it doesn't. I need the case where it doesn't. It executes the same. What could it be? <n1:startDate>2009-08-18T00:00:00-05:00Z</n1:st...

Sudo gem update --dry-run?

Is there a way to make RubyGems tell if there are any updates available? I find myself constantly running sudo gem update -- often several times every day. If I could run the command with a flag like --dry-run, then I could asses if the changed gems were significant to add (and also only run it when my tests on my current project were ...

CSS Validator - Ruby

Hey, I have the css-validator.war provided by W3C running locally on JBoss. I have whipped together a very quick script to test it out: require 'net/http' require 'uri' doc = ' * html { font-family: tahoma; background-color: black; } ' res = Net::HTTP.post_form(URI.parse('http://localhost:8080/css-validator/validator'), {'...

Ruby's ARGV can be empty on windows depending on a way to run script.

My demo.rb: puts ARGV.size ARGV.each do |a| puts "Argument: #{a}" end The result depends on how we run a script: > demo.rb foo bar 0 > ruby demo.rb foo bar 2 Argument: foo Argument: bar Why this happens? And can some thing be done with this? EDIT: Thanks to all replies! Here my settings: >assoc .rb .rb=rbFile >ftype rbFil...

Average from a Ruby Array

How would get find an average from an array? Say [0,4,8,2,5,0,2,6] would give 3.375 Thanks! ...

I cannot use passenger for my ruby on rails application on dreamhost.

I want to do some programming in ruby on rails on my Dreamhost server, so I connected via ssh and created a small application. Then I started the server and it worked. The problem is, that after some time the server kills itself. So I tried to activate Passenger in the user panel (which also has the advantage, that I don't have to connec...

Releasedate for Rails 3

Does anybody know when Rails 3 will be released? Tried to find info on the net - but nothing useful that I found... ...

Any way to unencrypt pkcs7 padded aes 256 cbc from ruby?

Im constantly getting "bad decrypt" whilst trying to unencrypt a string from a c# program using the same iv on both sides. This is getting a bit annoying and I cant really figure out the problem. This is the ruby code def unencrypt(message) c = OpenSSL::Cipher::Cipher.new("aes-256-cbc") c.padding = 1 c.decrypt c.key = key = Dig...

Why is Array.count available in dev mode but not production?

For a recent project, I had a couple views with code like this: <% if @users.count == 0 %> This worked perfectly in development mode... I rolled it out to prod mode and it exploded, saying that count was not a valid method of Array. I changed every instance to use Array#length instead and it seems to be working. 1) What is the reason...

Clear Unwanted Namespaces with LibXML-Ruby

I would like to parse an Atom Feed and create an Atom-compliant cache of each Entry. The problem is that some feeds (this one for example) have many namespaces other than the Atom one. Is it possible to keep intact all Atom nodes and remove each node that belongs to another namespace? Something like this: valid_nodes = entry.find('a...

Extending cucumber with modules and accessing Before/After hooks

I am trying to write a generic module to extend the World class. I need to access the Before and After hooks from within the module. I am doing this by using the extended method but Before/After does not seem to be available at this point. module MyWorld def MyWorld.extended(obj) obj.Before do # this doesn't work end e...

How would you go about making an online IRB that runs in the browser

Im wondering how to go about creating an online IRB that runs in the browser. I have an idea to include an irb console in my blog and give the option for users to send code blocks in my tutorials directly into the irb console so they can play around with it. _Why did this previously, but of course it is gone now: Cached Version ...

How can I tell if I'm running from JRuby vs. Ruby?

I have a script with a factory method that I would like to return a different implementation of some class depending on whether or not the script is running from JRuby or Ruby. Anyone have any ideas on how I could tell the difference from inside my script? Some initial thoughts I had were: Attempt to 'include Java' and rescue back to...

How is Array#Sort in Ruby so quick?

C# has BitArray, C has bit fields.. I couldn't find an equivalent in the Ruby core. Google showed me a BitField class that Peter Cooper has written for the same. I've been reading Jon Bentley's Programming Pearls and while trying out one of the first examples, which deals with a BitMap sort - I needed a type that is an array of bits. I ...

How to change the IdType in item_lookup from ASIN to ISBN, amazon-ecs for Ruby

That's my whole question! Doing something like this: Amazon::Ecs.item_lookup('9781934356166', :response_group => 'ItemAttributes,Images') Not sure where to change the option for the IdType to ISBN. I've tried putting it several places. Thanks! ...