ruby

Is there anything like Project Sprouts but implemented in Python?

Hi all Since our entire build system is written in Python, I'm wondering if there is anything like Sprouts that I could leverage to integrate Flex builds / development into our codebase? Sprouts looks nice and all, but I don't want to introduce another build-time dependency to our projects (namely Ruby). Thanks ...

Can a custom path be appended to the 'new' path for Rails routes?

What I'm trying to do: I'm building a system where there are different types of post. Setting aside the models, this question is about the routes and the controller Basically /posts/new should go to an index page of sorts, while /posts/new/anything should look up the type anything and then build a form for creating a new one. How I'm...

How to get a remote-file's mtime before downloading it in Ruby?

I have the below code, which simply downloads a file and saves it. I want to run it every 30 seconds and check if the remote-file's mtime has changed and download it if it has. I'll be creating a thread which sleeps 30seconds after every iteration of an endless loop for that purpose, but; how do I check a remote file's mtime without down...

ActiveMessaging, ActiveResources, or Ruby XMLRPC

I have a simple jruby+swt based client that collects data on an occasionally connected PC. Now I need to push those records to the server (Rails 2.3). Should I use ActiveMessaging, ActiveResources or Ruby XMLRPC. This is my current understanding: ActiveMessaging - best if server to client communication is needed ActiveResources - hy...

how to iterate within a state machine?

I am implementing a wizard like interface which will help a user configure application settings. I am using the AASM plugin to guide the user from state to state with the ability to go forward or backward through the configuration. I have implemented a skeleton of this core functionality and it is functioning as expected. The problem I...

Converting camel case to underscore case in ruby

Is there any ready function which converts camel case Strings into underscore separated string? I want something like this "CamelCaseString".to_undescore to return "camel_case_string" ...

How to tell ruby net libraries to use a particular network interface?

Hi, I'm doing some page scraping for a client and need to connect to their vpn server. So I have the vpn client running on my linux box, and this creates a new interface, say ppp0. Now, when I run Mechanize/open-uri, etc. I need to be able to bind specifically to this particular interface, because the other interfaces are to the intern...

Rake: How to specify that a task has multiple dependencies?

I would like to specify that :output_core depends on :build_core :build_extension depends on :build_core :output_extension depends on :build_extension and :output_core How would I specify that last one? That in order to run the :output_extensions tasks both :build_extensions and :output_core must have completed? ...

programmatically stop a windows service using ruby

Is there a way to stop a windows service (possibly on a remote machine) using ruby? ...

How do I limit the size of a Net::HTTP request?

I'm creating an API service which allows people to provide a URL of an image to the API call, and the the service downloads the image to process. How do I ensure somebody does NOT give me the URL of, like, a 5MB image? Is there a way to limit the request? This is what I have so far, which basically grabs everything. req = Net::HTTP...

Ruby: counting digits in a float number

Is there any worthy Ruby method to count the number of digits in a float? Also, how do I specify the precise when to_s float numbers? ...

before_filter running multiple time and growing

Hi, I have this funny situation whereby I see my before_filter executing multiple times for one access. My filter is called auth_user_filter and it logs using logger.info("Yada Yada Yada"). It gets set globally to run before all actions. When I access an action over my browser it prints the following (depending on what call it is) The...

Install Ruby Curb gem in windows XP

I'm trying to do file uploads with ruby 1.8 and it seems like there are no good out-of-the-box solutions. They all seem to need some 3rd party patch or fork of a project to work. I would use mechanize but I actually need to interface with an xml api and mechanize seems to be made specifically for dealing directly with webpages. I've trie...

Sprintf in Ruby

Sort of a quick question. I'm writing: puts "%.3f %.4f %.5f" % [3.998877, 3.998877, 3.998877] and get the following output: 3.999 3.9989 3.99888 sprintf simply rounds the numbers. How do I restrict that rounding? ...

SMTP error with Rails Exception Notifier plugin

Working on OS X, trying to get Rails Exception Notifier plugin to send out emails. I have verified the following: I can successfully send email from my app I am creating a test error (1/0 in one of my actions). Current plugin installed... script/plugin install git://github.com/rails/exception_notification.git In ApplicationController....

Sinatra "after" filter

Sinatra has a "before" filter, but is there an easy way to implement an "after" filter? ...

grabbing text between all tags in Nokogiri ?

what would be the most efficient way of grabbing all texts between html tags ? <div> <a> hi </a> .... bunch of texts surrounded by html tags. ...

put each text surrounded via html tag, into an array ?

using nokogiri, doc = Nokogiri::HTML(your_html) doc.xpath("//text()").to_s this does the job, however, it puts everything into one flat text. i need to take each text surrounded via html tags <b> text</b> <h1>text3</b> and put them into array. ["text", "text3"] what is the recommended action ? i thought of doing doc.xpath("*")....

Interesting String casting

How do I make the following string cast: "ln(5*x)" -> "Math.log(5*x)" ...

Authlogic throws errors on Heroku

I am trying to stage an app on Heroku that uses the Authlogic plugin. The Logs show me this error. I first thought there is a problem with the gem version, but I tried several: 2.1.1, 2.1.2, 2.1.3. But I tried deploying the authlogic example but it throws the same error. Thank you for your time. Processing UserSessionsController#new (...