ruby

Converting UTF8 to ANSI with Ruby

I have a Ruby script that generates a UTF8 CSV file remotely in a Linux machine and then transfers the file to a Windows machine thru SFTP. I then need to open this file with Excel, but Excel doesn't get UTF8, so I always need to open the file in a text editor that has the capability to convert UTF8 to ANSI. I would love to do this pr...

Open an IO stream from a local file or url

I know there are libs in other languages that can take a string that contains either either a path to a local file or a url and open it as a readable IO stream. Is there an easy way to do this in ruby? ...

What is a Ruby equivalent for Python's "zip" builtin?

Is there any Ruby equivalent for Python's builtin zip function? If not, what is a concise way of doing the same thing? A bit of context: this came up when I was trying to find a clean way of doing a check involving two arrays. If I had zip, I could have written something like: zip(a, b).all? {|pair| pair[0] === pair[1]} I'd also acce...

Access Ruby objects with Python via XML-RPC?

Hello I am trying to export a Ruby framework via XML-RPC. However I am having some problems when trying to call a method from a class not directly added as a handler to the XML-RPC server. Please see my example below: I have a test Ruby XML-RPC server as follows: require "xmlrpc/server" class ExampleBar def bar() return "hello ...

In Ruby's Test::Unit::TestCase, is there a way for a test method to access the total number of methods about to be tested?

i.e. as I compose my test suites to include other suites as well as test cases, is there a global count of how many tests the TestRunner has executed, will be executing? Any way I can progammatically access that count? ...

How to keep track of information over several calls to render :partial

I am using attribute_fu to render a nice block of rows for a particular table. <%= f.render_associated_form(@foo.bars, :new => 5) %> I would like to have the bar partial have some notion of a bit of state. (Because the notion is specific to the view, I do not want to externalize this to the Bar model itself and calculate it in the co...

Running into issues when running Rails on Ubuntu

First some background. I am trying to run Community Engine on a fresh install of Ubuntu. CE is a open src social networking plugin running on Rails. I was able to get CE up and running on my windows box w/o issue. I have decided to use Ubuntu 8.10 as my development environment now, and am stuck on this issue. I have researched this for t...

What IDE / Editor do you use for Ruby on Linux?

I've been using vim, but after reading this question was wondering what is being used in the linux world. ...

What is the best way to handle constants in Ruby when using Rails?

I have some constants that represent the valid options in one of my model's fields. What's the best way to handle these constants in Ruby? ...

Paypal Website Payments Standard with a Ruby/Rails application

Hi. I would like to implement a payment solution with my Rails site using Paypal Website Payments Standard. (See https://www.paypal.com/IntegrationCenter/ic_standard_home.html). I don't want fancy gateways, and I don't want to go through the hassles related to storing credit card information. I also want to use Paypal IPN for notificat...

Can Ruby import a .NET dll ?

I am interested in using/learning RoR in a project where I have to use a .NET dll. Is Ruby capable of importing a .NET dll? ...

How do I geo-search multiple models with ThinkingSphinx?

Hello, I have two models indexed for searching (User and Item). I'm trying to do a geo-search across models: ThinkingSphinx::Search.search('keywords', :geo => [ degrees_to_radians(params[:lat].to_f), degrees_to_radians(params[:lon].to_f) ], ) But I only get an error: Sphinx Error: index item_core,item_delta,user_core,user_delt...

Where is the best place to add methods to the Integer class in Rails?

Where is the best place to add a method to the integer class in Rails? I'd like to add a to_meters and to_miles methods. ...

How can I test views in a Rails plugin?

I'm writing a Rails plugin that includes some partials. I'd like to test the partials, but I'm having a hard time setting up a test that will render them. There's no associated controller, so I'm just faking one: require 'action_controller' require 'active_support' require 'action_pack' require 'action_view' class MyTest < Test::Unit...

Finding all occurrences of a sequence of chars when preceded by a specific string

Hi, I'm trying to extract all matches from a EBML definition, which is something like this: | + A track | + Track number: 3 | + Track UID: 724222477 | + Track type: subtitles ... | + Language: eng ... | + A track | + Track number: 4 | + Track UID: 745646561 | + Track type: subtitles ... | + Language: jpn ... I want all occurr...

What's the best way to unit test protected & private methods in Ruby?

What's the best way to unit test protected and private methods in Ruby, using the standard Ruby Test::Unit framework? I'm sure somebody will pipe up and dogmatically assert that "you should only unit test public methods; if it needs unit testing, it shouldn't be a protected or private method", but I'm not really interested in debating t...

Getting rendered images to the browsers in Rails

I am writing a Rails app that processes data into a graph (using Scruffy). I am wondering how can I render the graph to a blog/string and then send the blog/string directly to the the browser to be displayed (without saving it to a file)? Or do I need to render it, save it to a file, then display the saved image file in the browser? ...

piston git support?

I found piston seems a decent tool for managing rails plugins, but when I try to do piston convert for my project with git based plugins, it just went dead completely and seems its trying to look for .svn with svn tools. I am on piston 1.4.0, is that git natively supported or I would have to build from edge? ...

Good ruby gem sources?

What good ruby gem sources would you recommend, besides http://gems.rubyforge.org/ and http://gems.github.com/? It seems that RubyForge is missing most of the gems I look for these times... ...

How do you use Ruby/DL? Is this right?

I am trying to write an interface between RSPEC (ruby flavoured BDD) and a Windows application. The application itself is written in an obscure language, but it has a C API to provide access. I've gone with Ruby/DL but am having difficulties getting even the most basic call to a DLL method to work. Here is what I have so far, in a fil...