ruby

How to Generate a DSA signature?

I'm using Sparkle in my Application to do updates but in the documentation it says to generate a DSA Signature and provides a tool to do is (the tool is coded in ruby) but i don't know how to use it. Can someone help? This is where the documentation is (Step 3): http://sparkle.andymatuschak.org/documentation/pmwiki.php/Documentation/Bas...

Ruby: change each value in a hash with something like #collect for arrays?

Hi! I'd like to replace each value in a hash with value.some_method. For example in a simple hash {"a" => "b", "c" => "d"} every value should be .upcase-d so it looks like {"a" => "B", "c" => "D"}. I tried #collect and #map but always just get arrays back. Is there an 'elegant' way to do this? Thanks in advance, Adam Nonymous UPDAT...

How do I pass data using sessions in Ruby CGI?

I am working on a guess-a-number game with Ruby that will be online. I know I need to pass the SESSION somehow to keep the number that they are guessing, but I have tried a ton of methods with no luck. My code is here. Any thoughts on what I can do get this code working? I have declared each of my sections. ...

Get COM object for embedded IE browser with ruby win32api

Alright this is a pretty complicated problem but it looks like the hard work has been done already by the autoit IE.au3 project. So now it just takes someone experienced with ruby and win32api, and possibly autoit as well to figure out how to translate a function written in IE.au3 to ruby. The end result is I want to use Watir with an em...

What are the main differences between Sinatra and Ramaze?

I'm looking for a lightweight Ruby web framework and have come across Sinatra and Ramaze. Both seem extemely light, concise and simple. But I don't know enough about either to say what the main distinctions are. Perhaps someone with experience with one or both of these could comment? ...

Ruby String Translation

I want to find the successor of each element in my encoded string. For example K->M A->C etc. string.each_char do |ch| dummy_string<< ch.succ.succ end However this method translates y->aa. Is there a method in Ruby that is like maketrans() in Python? ...

How can I use the progress bar in Shoes?

Ok, so I'm not real sure about lots of things in Shoes, but my trial and error approach has failed me so far on this one. I've got a class that does some sort of computation that takes a while, and I want to throw up a progress bar for the user to look at while it finishes. My computationally intensive method yields its percent complet...

Ruby On Rails Active Record question, related to has_one

I have a Show model that has_one :venue, which is accomplished with each show having a venue_id And my Venue model belongs_to :show However I am having a problem accessing the venue by doing show.venue Consider the following code where s is a Show instance logger.info("*********************") logger.info("#{s.inspect}") ...

What's the best way to programmatically output a file in the format of a Word document in Ruby?

I need to output a file in the format of a Word document from a Ruby-based web app (Rails/Sinatra) based on some textual content in the app. Is there library support in Ruby for creating and structuring a Word document? ...

What's the difference between Rack and Passenger?

I'm trying to deploy a Sinatra app to Dreamhost and it says the following: Since DH supports Passenger, which in turn supports Rack-based ruby applications, DH does indeed support Sinatra. I'm having difficulty parsing that statement - what's the difference between Rack and Passenger (and why is Sinatra "Rack-based")? ...

Finding the last (rightmost) match for an arbitrary regular expression in ruby

I'm working on a text editor in ruby, and I need to support a "Find" feature with user-provided regular expression patterns. Here's a simple (familiar) use-case: Joe User is editing a text file, and has positioned the cursor somewhere in the middle of the file. He wants to search backwards from the current cursor location for the n...

How do you call attr_accessible dynamically in Rails?

I have a rather unique class that allows its child classes to declare virtual fields. The child can declare virtual fields stored as XML by calling a method of the parent class like this: class Child1 < Parent create_xml_field ["readings", "usage"] end I have managed to get it working via a nasty work around. The create_xml_field me...

What's this &block in Ruby? And how does it get passes in a method here?

Saw this piece of code in a RoR book. This first one is from a View and the second one is a helper module. I don't understand how that &block and the attributes={} thing work. Can anyone guide me to a tutorial of some kind explaining this? <% hidden_div_if(@cart.items.empty?, :id => "cart") do %> <%= render(:partial => "cart", :object ...

Best practices on processing email sent to app specific address in rails?

Hello all, We would like to implement a feature by which users could send an email to an application specific address and we will parse the message and take certain actions on it, similar to 37signals's backpack (and probably some of their other apps). If anyone has done something similar, could you fill me in on how you did so? I'm un...

Weird characters being saved in my database...

Here is a screen shot of weird characters in my database. I know that this character combination is for a crazy apostrophe. Should I just let these characters stay in my database? Or should I strip them out and replace with normal apostrophes? If I should strip, is there on ruby function to ensure that all characters that save to my d...

How to generate external secure form for clients in Rails

Hello, I'm using Ruby on Rails to make an application where businesses can create accounts and add information about their clients. I would like to be able to generate a form that they can put on their website to automatically enter the clients' info into their account. I know I might be able to do something like: <% form_tag my_site_u...

what could be causing this rails ioerror closed stream?

I have a rails application, running in development mode ( with a sqlite database ). The application's purpose is to allow users to upload files through a java client. If a user wants to upload a folder, all the files inside it will be recursively uploaded. If a user wants to upload a file, the file will be uploaded normally. Here's t...

What does the right arrow do in this code: "Ramaze.start :port => 80"

Ramaze.start :port => 80 If my understanding is correct, the line above is a method call in Ruby and you could also write it as: Ramaze.start(:port => 80) But in either case, what does it mean when you put the => character between the symbol :port and the number 80? Is that a way of creating a Hash? When the Ramaze.start method rec...

Ruby Iteration Question : Binary->Decimal Program

I am learning Ruby and thought of making a Binary->Decimal converter. It gets a binary string and converts to decimal equivalent. Is there a way to keep track of the current iteration step in ruby so that the variable 'x' can be removed? def convert(binary_string) decimal_equivalent = 0 x=0 binary_string.reverse.each_char...

Best practices for populating rails with processed data

I've been working for some months on a program for processing some data, and it's now at a stage where rather than displaying information (stored using ActiveRecord) via the command-line, I'd like to display the processed information via a Rails app. The first question I'm facing is whether I should have the data processing and the data...