ruby

Watir and Cucumber unable to run on win xp

I just download an example of cucumber from http://github.com/aslakhellesoy/cucumber/downloads, and install ruby, watir and cucumber. but I dont know how to run it, I cant found any example for windows. thanks, Dani. ...

Ruby GUI (non-complex layouts)

I've done quite a bit of research on Ruby GUI design, and it appears to be the one area where Ruby tends to be behind the curve. I've explored the options of MonkeyBars, wxRuby, fxRuby, Shoes, etc. and was just wanted to get some input from the Ruby community. While they're definitely usable, the development on each seems to have falle...

how do i check the value inside a text feild while using ruby selenium testing?

i am running a selenium test using ruby and was wondering how i can assert the value inside a text field? i have a page where once its loaded has text inside the editable text field and i was wondering how i can check if the text is present? thank you ...

Ruby Mysql Connection

I setup ruby and mysql on my mac and i am having issues connecting to my local mysql server. require 'rubygems' require 'mysql' ... db = Mysql.new("localhost", "root", "", "") ... This would give me the following error when i run this script fromt he command line: generate.rb:37:in `initialize': wrong number of arguments (4 for 0...

QuickTimeX in Applescript / Scripting Bridge

I'd like to be able to grab the metadata of the currently playing file in Quicktime X using ScriptingBridge and Ruby, so far I have the following code require 'osx/cocoa' OSX.require_framework 'ScriptingBridge' @app = OSX::SBApplication.applicationWithBundleIdentifier("com.apple.QuickTimePlayerX") @app.documents.each do |movie| # Wh...

Overriding an ActiveRecord attribute

I have a model with a completed:boolean column that I'd like override so I can add some conditional code. I've never override an ActiveRecord attribute before and wanted to know if the method below is good practice? class Article < ActiveRecord::Base def completed=(b) write_attribute(:completed, b) # IF b is true then do so...

Rails each loop insert tag every 6 items?

Hello Stack Anon, I have X number of image objects that I need to loop through in a view and want to create a new div every 6 objects or so (for a gallery). I have looked at cycle but it seems to change every other record. Does anyone know of a way to insert code into a view every 6 times? I could probably do it with nested loops but ...

API to translate group name to group id (gid)

File.chown takes an owner ID, a group ID (gid), and a filename. I want to use it to set a file's gid, but what I have is the group name. Is there anything in the standard library that I can use to translate a group name into a gid? ...

Subtract dates in Ruby and get the difference in minutes

Hi, how do i subtract two different UTC dates in Ruby and then get the difference in minutes? Thanks ...

Method For Making Methods: Easy Ruby Metaprogramming

I have a bunch of methods like this in view helper def background "#e9eaec" end def footer_link_color "#836448" end I'd like these methods exposed to the view, but I'd prefer the helper to be a bit more concise. What's the best way to turn a hash, say, into methods (or something else)? ...

Nested Select in Rails

I am working on a Rails application which uses categories for items. My category model is self-joined so that categories can be nested: class Category < ActiveRecord::Base has_many :items # Self Join (categories can have subcategories) has_many :subcategories, :class_name => "Category", :foreign_key => "parent_id" belongs_...

Within a ruby script how can i ignore HostKeyMismatch, and still login via Net::SSH.start()

I tried Net::SSH.start( value_hosts, USER, :password => PASS , :forward_agent => true , :paranoid => false) do|ssh, err| but :paranoid option does not seem to work ...

Validating class and superclass on RoR

In ruby, you have an attribute called "type" which is the class of the object. Rails stores this at the database in a column called type. So, if I have several blog "types", I can do something like this def create @blog = Blog.new(params[:blog]) @blog[:type] = params[:blog][:type] # ... end If I add someone like this, and then l...

Accessing variables from included files in Ruby

How do you access variables which are defined in an included file? # inc.rb foo = "bar"; # main.rb require 'inc.rb' puts foo # NameError: undefined local variable or method `foo' for main:Object ...

Rails Controller

Hi...In Rails, is it ok to define logic in a controller with a model. For example, take there is an User Model, which is good design. 1)Leaving the UserModel with the CRUD models and moving all the other User Specific actions to a separate controller or 2)Add the user specific actions to the same UserModels Thanks :) ...

What's the recommended way to write logs from a ruby script on Windows XP?

Too bad I don't have a server but a XP to serve some scheduled ruby scripts. So, what's the recommended way (gem/plug-in?) to write logs on Windows XP from ruby scripts? ...

Missing functions in ruby 1.8

I have a ruby gem that I developed with ruby 1.9, and it works. With ruby 1.8, though, it says this when I try to run it: dyld: lazy symbol binding failed: Symbol not found: _RBIGNUM_SIGN Referenced from: /Users/Adrian/Desktop/num_to_bytes/ext/num_to_bytes/num_to_bytes.bundle Expected in: flat namespace dyld: Symbol not found: _RBI...

More elegant way to write this?

Hi, I am trying to make a multi-dimensional array of characters in ruby, and this works, but is there a more elegant way? def initialize(text) @map = Array.new i = 0 text.split("\n").each do |x| @map[i] = x.scan(/./) i += 1 end #@map = text end#constructor ...

How can I get Hpricot to play nice with HTML5?

I am using Hpricot to parse a theme file. I have noticed, however, that if I feed a valid HTML5 document into Hpricot(), it auto-closes HTML5 tags (like <section>), and messes with the DOCTYPE. Are there any extensions to Hpricot, or perhaps a flag I need to set, that will allow HTML5 documents to be parsed correctly? ...

remainder application in ruby

i want to send develop a web app in ruby on rails . which wil send the remainder to the mail and mobile tooo . can some body help me out thanks in advance ...