ruby

How do I count users shirt size?

Event has_many :squads, :dependent => :destroy has_many :users, :through => :squads, :source => :squad_users Squad has_many :squad_users, :dependent => :destroy has_many :users, :through => :squad_users User has_many :squad_users has_many :squads, :through => :squad_users has_many :events, :through => :squads SquadUser belongs_...

Is there a good process monitoring and control framework in either Ruby or Perl?

I came across God which seems good but I am wondering if anyone knows of other process monitoring and control frameworks that I can compare god with. God has the following features: Config file is written in Ruby Easily write your own custom conditions in Ruby Supports both poll and event based conditions Different poll conditions can ...

Odd ActiveRecord behavior - behaves differently based on order of associations

I've found pretty odd behavior of rails's activerecord. This occurs in rails 2.3.9 and does not in rails 3. Here is how you can reproduce it. (Or just clone github repo example I created: git clone git://github.com/gonchs/rails-2.3.9-odd-association-behavior-example.git ) class User < ActiveRecord::Base has_one :parent has_one :con...

Intermittent RingNotFound error on windows

Am running a rails application which launches a series of relatively long running scripts using delayed_job and Rinda to farm out the work. At the moment am using a single delayed_job process (rake jobs:work, as am stuck on Windows), a ring server process (started with RingyDingy), and a single service process ( pretty ordinary ) The...

anemone scrubbing a certain page depth

I am not understanding how to use the tentacle part of the anemone. If I am interpreting it right I feel i could use it to only scrub a certain page depth away from the root. Anemone.crawl(start_url) do |anemone| tentacle.new(i think but not working) anemone.on_every_page do |page| puts page.depth puts page.url e...

simple ruby script that tests out mail lib not working, please help

Using irb the mail library worked fine, now I am creating my first ruby script. I am getting the error: testmail.rb:3:in `require': no such file to load -- mail (LoadError) from testmail.rb:3 Below is the file testmail.rb: #!/usr/bin/env ruby require 'mail' if __FILE__ == $0 Mail.defaults do retriever_method :pop3, { ...

Parsing Kconfig using racc

I'm trying to parse kernel config using racc. Everything was ok until it reached ---help--- part. I'm getting error: /Users/user/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/racc/parser.rb:348:in `on_error': (Racc::ParseError) parse error on value "\t Say yes to build a 64-bit kernel - formerly known as x86_64\n\t Say no to build a 32...

How to match the brother of a certain XML element in ruby?

I played around with nokogiri in ruby and the XML searching feature, e.g.: a = Nokogiri.XML(open 'a.xml') x = a.search('//div[@class="foo"]').text which works quite nice. But how can I specify to match the next (brother) element on the same level (and only the next)? For example for this input: <div> <div>...</div> <div>...</di...

Cannot click a submit button with webrat

Hi, using Ruby and webrat, I've got difficulties to click the OK button in the following HTML form : <form name="frmLogin" id="frmLogin" action="logininstit.do" method="post" validation="N" onkeydown="performDefaultButton(event, this, 'valider', false);" onkeypress="performDefaultButton(event, this, 'valider', true);" onsubmit="return ...

How can I set scheme to a URI object in Ruby

I'm trying to parse a URI from user input. I'm assuming some users won't put the scheme in their URI's and I wan't to default to "http" I wrote the following code which I thought should work. But it dosen't. require 'uri' uri_to_check = URI::parse("www.google.com") uri_to_check.scheme = "http" unless uri_to_check.scheme puts uri_t...

How to convert these kind of characters to their corresponding unicode characters in Ruby?

I want to know how to convert these kind of characters to their unicode form, such as the following one: Delphi_7.0%E6%95%B0%E6%8D%AE%E5%BA%93%E5%BC%80%E5%8F%91%E5%85%A5%E9%97%A8%E4%B8%8E%E8%8C%83%E4%BE%8B%E8%A7%A3%E6%9E%90 The unicode characters of the upper string is: Delphi_7.0数据库开发入门与范例解析 Anybody knows how to do the conversion ...

Ruby Accessing Array Elements

I have an array that looks like this. [{"EntryId"=>"2", "Field1"=>"National Life Group","DateCreated"=>"2010-07-30 11:00:14", "CreatedBy"=>"tristanoneil"}, {"EntryId"=>"3", "Field1"=>"Barton Golf Club", "DateCreated"=>"2010-07-30 11:11:20", "CreatedBy"=>"public"}, {"EntryId"=>"4", "Field1"=>"PP&D Brochure Distribution", "DateCreated"=...

Good resources to learn MacRuby

I do not know Ruby and I am interested to learn MacRuby. What would you recommend as your best resource (books, blogs, sites) to learn MacRuby? Found:http://www.macruby.org/ ...

In Rails 3, I'm getting a NoMethodError for the recycle! method during testing

Hello, I've got a functional test that's using fixtures. I also am using fixtures in my Unit tests, but they work without flaw. When running the functional tests, I get a: NoMethodError: undefined method 'recycle!' for #<Response:0x10346be10> /test/functional/responses_controller_test.rb:10:in 'test_testing' My functional tests, at ...

Ruby: OptionParser: String Arg & Hash Assignment

Using OptionParser for string argument input and hash assignment. What is the best way to read-in multiple variables for a single argument? How do I then assign those to a hash to reference? Here is what I have so far: large_skus = Hash.new small_skus = Hash.new OptionParser.new do |opts| opts.on("-b", "--brands bName1,bName2,bName...

Installing a gem from Github with Bundler

I am trying to use the instructions here to install a pre-released version of a gem with bundler. The "bundle install" output lists the gem as getting installed, but "gem list" fails to find it. My Gemfile: source :gemcutter gem 'sinatra', '1.1.0', :git => 'http://github.com/sinatra/sinatra.git' gem 'RedCloth', '4.2.3' Here is a g...

How to get rid of TypeError

I have my class class A def to_s 'string' end def inspect 'string' end end and trying to do something like this a = A.new 'somestring' + a Error is "in `+': can't convert A into String (TypeError)" Is there any way to fix it? P.S. using 'somestring' + a.to_s isn't an option. Answer found. to_str method needed. ...

heroku deployment testing

I have an app I've been upgrading to Rails 3, I've been hosting it on heroku for the past 6 months (rails 2.3.8 currently) but am unclear how to test my Rails 3 branch before I proceed. The most i could find about the subject in their docs was that I could do something like this: $ heroku create --stack bamboo-ree-1.8.7 --remote trybam...

Ruby on Rails: uninitialized constant MysqlCompat::MysqlRes

I tried all the options specified in the link: http://stackoverflow.com/questions/1332207/uninitialized-constant-mysqlcompatmysqlres-using-mms2r-gem but nothing is working. I have an iMac with Snow Leopard installed. I am currently using the mysql gem version 2.7 and I checked that ruby was 64 bit but I am unsure if the mysql gem is 64...

structuring complicated ruby helper routines

I'm working on a fairly complicated app and am trying to figure out how to implement some functionality in terms of rendering data to various formats. In simple terms, the app is taking key value data and rendering it to html, or potentially to other formats. I know key value data sucks but for the app in question it is required. This w...