ruby

How to send keystrokes to windows from a ruby app?

Hello, I´ve been trying to interact with another app on windows, which doesn´t have any data exchange protocol implemented. So i figured the best way to do this is by fetching data from an app and send it to the other one by sending keystrokes, simulating human interaction. But i am having such a hard time trying to implement this kind...

Thor equivalent or similar scripting framework for Javascript?

Is there a Thor equivalent (ruby tool) or similar scripting framework for Javascript that could be used to build scripts? ...

What is the !! and a few other things in Ruby?

I have been digging through some ruby gem code and i came across these and not sure what they means def success? !!@success end def failure? !@success end cattr_accessor :test_response and lastly this chunk of code class_inheritable_accessor :attributes self.attributes = [] def self.attribute(name, options={}) top_level_name...

Is there a python equivalent of ruby's "Pathname" module?

Ruby has this really handy module called Pathname. Is there a python equivalent to it? ...

Any suggestion on handling unwanted text in a textfield in ruby on rails?

Ok so i have this problem i am trying to address. I have this textfield with the id of request_money <input id="request_money" name="request[money]" size="30" type="text"> In this textfield i have a watermark plugin that i am using with the text "Not now" which is happening via jQuery $("#request_money").Watermark("Not Now"); This ...

can mechanize read ajax? (ruby)

can I get the correct data/text that is displayed via AJAX using mechanize in ruby? Or is there any other scripting gem that would allow me to do so? ...

Installed gems lost after gem update

Hi, I performed a gem update using sudo gem install rubygems-update and sudo update_rubygems But now all my previously installed gems have disappeared. I ran gem list and no locally installed gems showed up. Any ideas what went wrong and how to fix it? Thanks. ...

Ruby array subtraction without removing items more than once

The canonical Array difference example in Ruby is: [ 1, 1, 2, 2, 3, 3, 4, 5 ] - [ 1, 2, 4 ] #=> [ 3, 3, 5 ] What's the best way to get the following behavior instead? [ 1, 1, 2, 2, 3, 3, 4, 5 ].subtract_once([ 1, 2, 4 ]) #=> [ 1, 2, 3, 3, 5 ] That is, only the first instance of each matching item in the second array is removed ...

fork with Ruby 1.8 and Windows

I'm using ruby 1.8.7 patchlevel 302 and I'm working on a Windows xp system. I have to start an external process that needs to react on user input. The process doesn't react if I use threads, so I tried using fork. With fork the external process reacts on the user input but it executes more than just the fork block. For example fork do ...

installing gems using rvm

When trying to install gems using rvm i get this error $ rvm gem install sproutcore ERROR: While executing gem ... (Errno::EACCES) Permission denied - /home/tee/.gem/specs but it says on the rvm site that you should not use sudo so I'm not sure whats wrong with my setup when i type $GEM_HOME it shows that the directory is pointing t...

How do I delete mongrel temp files after completion of upload?

Hi all, In my rails application am uploading some large file(1 Gb),and when I go windows temp folder, mongrel temporary files are gathering there, but I would like these files to be deleted after upload completes. Could anyone tell me how do that?? This is my ruby version: ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32] ...

let user modify css propertise from front end of rails app

hi all i am creating a cms / portal that i want each user to change certain css properise ie colors, widths, backgrounds etc to customise there own version of my site. What is the best way to do this ? i have looked into sass but not sure if this is possible from front end as the css would need to be recompiled each time etc ? Any on...

basic ruby testing question

I've found myself doing this a lot lately... how can I improve the declaration of the paperclip fixture? (sorry, noob question I know) class ProjectTest < ActiveSupport::TestCase def xxx project = Project.new({ :name => 'xxx', :attachment => File.new(Rails.root + 'test/fixtures/files/attachments/xxx.psd') }) p...

integrated email in and out system in rails app

hi all i have a cms / portal rails app and i want to allow users to send and receive emails from within the application. I want to do this so that i can record and show all activity / communications from and to users contacts. I have done this in another site but had problems displaying and creating html emails within the site. Style...

Regular expressions: How do I grab a block of text using regex? (in ruby)

I'm using ruby and I'm trying to find a way to grab text in between the {start_grab_entries} and {end_grab_entries} like so: {start_grab_entries} i want to grab the text that you see here in the middle {end_grab_entries} Something like so: $1 => "i want to grab the text that you see here in the middle" So far, ...

How to detect file changes?

Hi, I am watching a log file using FSSM. So far, this works fine. FSSM informs me whenever the file gets updated. But how can I detect the new log entries without manipulating the given log file? My current code is: FSSM::Monitor.new.path(Dir.pwd, file) do update { |base, relative| puts "Change detected (#{file}): Bas...

Regex: How do you capture one group among multiple groups using regex? (in ruby)

I have two groups of text: firstgroup (some content) endgroup secondgroup (some content) endgroup I'm trying to just capture the first group (not the second group). I'm using this regular expression: firstgroup(.|\n)*endgroup For some reason, that regular expressions selects both first group and second group (probably because it ...

Ruby string to raw binary

Hey everyone, in PHP there is the hash() function that can return raw binary data. http://de2.php.net/manual/en/function.hash.php I want to do the same in Ruby. How do I do that? I generate the hash with: h = Digest::SHA2.new(512) << "hashme" PHP generates 32 byte of "raw binary output". ...

Months ago in ruby

I can't figure out a way (using class definitions) to get months ago. Seconds, days, and minutes are all fine because they're always constants. However since months isn't always constant, i need to know a way for ruby to know how many days are in the current month. ...

Can't get tweetstream library to work for ruby.

here is my code require 'rubygems' require 'tweetstream' TweetStream::Client.new('usr','pswd').sample do |status| puts "#{status.text}" end when i run this code i get: ./tweetstream.rb:6: uninitialized constant TweetStream (NameError) from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib/ruby...