ruby

Create ERD type diagrams from Rails code

I'm beginning to learn Ruby on Rails, and looking at other peoples code. Is there any way to take an exisiting codebase and create object relationship diagrams or Entity relationship diagrams (ERD's) ? I know Visio can do some things given a database, but I was hoping to produce diagrams of classes, objects and objects. ...

Can you ask ruby to treat warnings as errors?

Does ruby allow you to treat warnings as errors? One reason I'd like to do this is to ensure that if heckle removing a line of code means that a warning occurs, I have the option of ensuring that the mutant get killed. ...

How do I run my Specs with the previous version of Rspec?

I have been following an RSpec tutorial on one of my machines, in the hope of learning more about BDD and TDD. My setup was with Rails 2.2.2 and Rspec 1.1.12 Tonight I decided to continue on my primary machine and moved my code from my portable to my desktop. Not having RSpec, i installed the gem . . . sudo gem install rspec sudo gem ...

ruby-aaws Get specific Album

I am trying to get a specific music cd from Amazon using ruby-aaws. il = ItemSearch.new( 'Music', { 'Artist' => artist_title, 'Title' => album_name } ) rg = ResponseGroup.new( 'Large' ) req = Request.new(AMAZON_KEY_ID, AMAZON_ASSOCIATES_ID, 'de') resp = req.search( il, rg, 5) But this fails. It only s...

How to ensure only one instance of a ruby script is running at a time

I have a process that runs on cron every five minutes. Usually, it takes only a few seconds to run, but sometimes it takes several minutes. I want to ensure that only one version of this is running at a time. I tried an obvious way... File.open("/tmp/indexer_lock.tmp",'w') do |f| exit unless f.flock(File::LOCK_EX) end ...but it's n...

Ruby show progress when copying files

I'd like to be able to show the progress of a file copy operation when copying files using Ruby (currently using FileUtils.cp) I've tried setting the verbose option to true but that just seems to show me the copy command issued. I'm running this script from command line at the moment so ideally I'd like to be able to present something l...

how to force Qt widget to maintain equal height and width?

Hi all, I'm using Ruby Qt bindings. I'm trying to make a square widget (checker board), but it doesn't seem to work. This is the code that I tried What is the proper way to making a widget that maintains it's aspect ratio? ...

How do you copy and paste rich text to and from the wxRichTextCtrl?

I am using wxruby but as far as I can tell its not only a ruby problem. If I try to copy and paste rich text into the wxRichTextCtrl it loses all the formatting. What am I missing? Is there any way to make this work? ...

Ruby Grammar

I'm looking for Ruby grammar in BNF form. Is there an official version? ...

Need to write a ruby script to create a csv file of the data on the website

There is a website which gives me the information of pin codes of a particular state for example indian postal website, gives the details when I select the state in the drop down. I need to write the script in ruby which would create the CSV file with all the data for a particular state. Today is my first day on ruby and not sure how ...

What is the range of times that Ruby's Time class can represent?

Times farthest in the past and farthest in the future that can be represented? Is it absolute moments in time, or distance in time from the present moment? I couldn't find it in the docs for the Time class. Does it depend on the system? If so, how can I access it in my code? UPDATE After some experimentation, I found that it's from ...

Does ruby's object_id method refer to the memory location?

Or does this method just indicate a unique integer that each object has? ...

Is a symbol table in Ruby any different from a symbol table in other languages

The wikipedia entry on Symbol tables is a good reference: http://en.wikipedia.org/wiki/Symbol_table But as I try to understand symbols in Ruby and how they are represented in the Array of Symbols (returned by the Symbol.all_symbols method), I'm wondering whether Ruby's approach to the symbol table has any important differences from o...

Can you install documentation for existing gems?

Rubyinside mentioned a blog post on how to speed up gem installation by not installing RI or RDoc. Is it possible to install a gem and subsequently install documentation at a later date, so you can hack in haste and RTFM at leisure? ...

Anyone got Ruby to work with MySQL 5.1?

This has been asked before but not exactly in the same way (other users had Rails/servers issues, and I'm not having the issue with OLD_PASSWORDS) I'm trying to make my Ruby app work with MySQL using Ruby-MySQL, The setup is supposed to be quite simple: % ruby ./setup.rb % ruby ./test.rb hostname user passwd # ruby ./install.rb How...

Stubbing Chained Methods with Rspec

I want to call a named_scope that will only return one record, but the named_scope returns an array, that's not a big deal as I can just chain it with .first: Model.named_scope(param).first and this works, what I am struggling with is how to stub the chained call. Does anyone have a reference or an answer on how I would go about achie...

Using acts_as_list with has_many :through in rails

I have a rails app I'm trying to set up with sortable lists using the acts_as_list plugin. The position field in the db is getting updated, but when the page is rendered, the order is not considered. I'm looking for some help, I guess. Here are my models... class QuestionMembership < ActiveRecord::Base belongs_to :form belongs_...

What do you call the << operator in Ruby when it's used for appending stuff?

In other contexts I know this << is called the bitshift operator. Is there a name for it when it's just used for append operations like you would do in an array or string (not sure what else you can append with it)? I'd like to be able to use an English word to refer to it instead of saying "you know, the operator with the two left arro...

Switching test::unit with rspec under rails

Kinda odd question here: when you go with rpsec instead of test::unit on rails, what do you do with the test dir? Keep it (for any compatibility issues maybe?) or remove it? ...

What are those pipe symbols for in Ruby?

Hi, Apologies if this is an overly elementary question, but what are the pipe symbols for in Ruby? I'm learning Ruby and RoR, coming from a PHP and Java background, but I keep coming across code like this: def new @post = Post.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @post } end...