ruby

Need recommendations to create an event-based messaging and badging system in Rails

I want to create an event-based notification and badging system that would award users when they accomplish certain goals. Goals might include: Posting 20 entries on a forum -> alert on homepage highlighting user, award of badge Logging in to the site 10 days straight -> congrats to message to user on homepage Commenting on 10 forum p...

Ruby: targeting multiple platforms in one project

Hello, fellow Rubyists! I am creating an [Iron]Ruby project that needs to support several environments (more specifically, WPF, Silverlight, and WinForms - but that's not as important). The following is an actual, concrete example of where I'm stuck: I have to implement a Bitmap class as part of a library, and this class will need to b...

If Java people go to Scala, C# go to F#, where do Ruby people go for functional nirvana?

I know alot of Java people have started looking at Scala since it runs on the JVM, and alot of people in the Microsoft world are looking at F#, but what does Ruby have as a natural functional successor? In a pure FP sense Ruby doesn't lack anything, instead it has too much some may say. A functional language forces the programmer to not...

Ruby Name Routes with permalinks and static pages

I have several static pages and a couple of dynamic pages. Static pages are under the "Info" controller. Dynamic pages are under "products". I want to access "products" from their :permalink I can only get map.info or map.products to work but not both. ActionController::Routing::Routes.draw do |map| map.resources :products map...

Ensure teardown runs in Test::Unit::TestCase?

I'm using Test::Unit::TestCase to write some unit tests. Currently, I have a setup function that moves and modifies some fixture files and folders on disk. (This is a necessary evil at the moment.) If a test crashes, the teardown method doesn't get called, leaving files and folders in the way. The next time I run a test, it complains...

Problem building Ruby on Mac OSX Snow Leopard

I'm having an issue compiling (make) ruby on Mac Osx . I get the following error: compiling racc/cparse mkdir -p ../../../.ext/i686-darwin10.2.0/racc gcc -I. -I../../.. -I../../../. -I../../.././ext/racc/cparse -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -D_XOPEN_SOURCE=1 -fno-common -pipe -fno-common -c cparse.c cc -dy...

Use HTTParty methods in a subclass

I'm trying to write an API wrapper in ruby and am stumped on how I can call HTTParty methods from a subclass. For instance, I want the user to create a connection to the api and then be able to query results from subclasses. module ApiWrapper class Connection include HTTParty base_uri '...' def initialize( ...

Moving From non-Java Ruby to Groovy: Language Differences

Using my not-outstanding Google skills, I have not been able to find a decent tutorial on Groovy for Ruby programmers. There are a lot of political pieces (Ruby is great! Groovy is great!) and tiny little contrasts, but I really don't care which is better. I know Ruby (and Java) relatively well, and I'd like to learn Groovy. Would anybo...

Parsing delimited text with escape characters

I'm trying to parse (in Ruby) what's effectively the UNIX passwd file-format: comma delimiters, with an escape character \ such that anything escaped should be considered literally. I'm trying to use a regular expression for this, but I'm coming up short — even when using Oniguruma for lookahead/lookbehind assertions. Essentially, all o...

Array to String Back to Array Conversion Problem

I'm saving a bunch of ID's to the session like this. session[:id_group] = 1,2,3,4,5 Because I need to save them to a data base with a form. In that form I have hidden-field : <%= form.text_field :group, :value => session[:id_group].inspect%> I use the inspect so that the value saved to the database gets to be [1,2,3,4,5] and not 1...

Why am I getting undefined method errors for "strip" and "downcase" when I run RSpec on my models?

I am running an RSpec test on a model and getting errors for string methods such as: "index, "downcase," and "strip." Any ideas why that is and how I can fix it? ...

How do I make yahoo unblock the images that come with the emails coming from our server?

How do I make yahoo unblock the images that come with the emails coming from our server? ...

Regular expression to put an alignment into a <td> tag

I have an html file that I need to take any tag and put an align='left' into it. So given the line : <td><img alt="" src="oooh.html_files/px" style="width: 20px; height: 1px;"/></td> I need it to do : <td align='left'><img alt="" src="oooh.html_files/px" style="width: 20px; height: 1px;"/></td> If it already specifies an alig...

take the table element while clicking on the same table element

I'm developing a project and I have a problem about this subject. I'm constructing ruby on rails project which will provide listing students with name. First of all , I will list my students information in a table and one part is missing. When the user clicks on Student Name , another table will appear and show the other information o...

What is rack middleware?

Hi, What is rack middleware? Thanks. ...

Easiest way to convert "a/b/c" to ["a/b/c", "a/b", "a"]

In Ruby, I'd like to convert a slash-separate String such as "foo/bar/baz" into ["foo/bar/baz", "foo/bar", "foo"]. I already have solutions a few lines long; I'm looking for an elegant one-liner. It also needs to work for arbitrary numbers of segments (0 and up). ...

How to determine search query forwarding user to my website?

Greetings, I'm trying to work out what query is being used to forward people to my website. I'd appreciate it if anyone could tell me what api call I should be looking into. I'm sure this is possible with javascript as well as ruby and php so any technology is fine. Just for learning sake I don't mind know what I should be using for ...

How can I write code without "needing" comments for readability?

Possible Duplicate: Is it possible to write good and understandable code without any comments? When coding often I hear that if comments are needed then it means that the code is too hard to understand. I agree that code should be readable but often the language itself makes the code hard to follow, because of "plumbing" and s...

Using ruby 'or equals' ||= on methods that return a hash or nil

I have a method that returns a hash, or nil: def person_of_age(age) some_hash = @array_of_hashes.select { |h| h.age == age }.last return some_hash end I want to use this hash like so: my_height = 170 my_age = 30 if my_height < self.person_of_age(my_age)['height'] puts "You are shorter than another person I know of the same age!"...

Matching patterns in URL with a language similar to regexp, but specific for URLs

I use matching URLs in a part of my code. Now I use regular expressions for this. This is fine, but does not always produces "nice", simply readable patterns. Is there any language defined for matching URLs? It should be like this: http://*.example.com/* so simply wild-cards and things useful for URL would be there. The best would if th...