I have a Ruby script that I built in TextMate and can successfully run in TextMate.
I can also successfully run this script straight from the terminal.
The script has this chunk of code in it:
# Get the XML file
puts 'Opening the file'
open("messages.xml", "r") do |f|
puts 'File is opened'
theXML = Hpricot::XML(f)
puts 'Tryin...
Hello!
I'm rather new to Ruby, and today I wrote an application which you can pass arguments to via ARGV. But inside my application, I want to be able to use "gets". Problem is, every time I try to do so, I get an error.
Here's a simple script which shows my problem:
print "Say something! "
input = gets
If I'd call that like this:
...
I'm trying to call a web service from a PHP page via a Ruby script. The PHP script returns a string and itself calls another web service; I've tested the PHP script alone and it returns a single string. I'm trying to call this method via RPC using the following code:
require 'soap/rpc/driver'
driver = SOAP::RPC:Driver.new('http://mysi...
I have an array with 2 different types of objects. They all have similar properties, like ratings / title etc...
An example is:
array = array.sort_by { |o| [o.type1.rating] }
Sometimes the array has 2 object types type1 and type2 is there any way to sort both of them using the sort_by method?
...
I've got the following relationships in my model:
class Show < ActiveRecord::Base
has_many :service_shows
has_many :services, :through => :service_shows
end
class Service < ActiveRecord::Base
has_many :service_shows
has_many :shows, :through => :service_shows
end
class ServiceShow < ActiveRecord::Base
belongs_to :show
belo...
What would be the fastest way to do this.
I have may html documents that might (or might not) contain the word "Instructions" followed by several lines of instructions. I want to parse these pages that contain the word "Instructions" and the lines that follow.
...
I'm setting up emacs as my ruby development environment. I run tests by doing M-x compile and then rake test. I've set up compile-error-regexp-alist appropriately so that the resulting compile buffer can recognize test failures and make them clickable, but I'm facing trouble getting compile-find-file to use the correct directory to find ...
Hi all,
hope you all doing well.
my question is on ruby technology, we are developing an web based application using rails framework and ruby. I need to know how the routing works (routes.rb), can some one send me a link of sample CRUD application which I can use in my project.
I need also User authentication and authorization framewor...
I'm using a simple browser.goto(url) call to our Microsoft SQL Reporting pages. It does a "goto" on the first url but then just sits there. I'm currently running it via command line.
If I Ctrl+C to cancel it, the output says:
C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/ie-class.rb:506:in `wait': Interrupt
from C:/Ruby/lib/...
Hi,
I've never seen the point of installing the ri and rdoc for gems and my .gemrc file has --no-ri and --no-rdoc set. Since every gem includes ri and rdoc info, I just wondered if I'm missing something? Is there any advantage to installing the ri and rdoc for a gem?
Thanks
Chris
Summary
If you don't install the ri and rdoc, you don...
hi
On my server searching is fast but on my local machine gem searches are slow.
Can I do something for speed up my gem searches?
...
obj = SomeObject.new
def obj.new_method
"do some things"
end
puts obj.new_method
> "do some things"
This works ok. However, I need to do same thing inside an existing method:
def some_random_method
def obj.new_method
"do some things"
end
end
Works ok as well, but having a method inside a method looks pretty horrible. The...
I'm trying to return an array of counted values for consecutive date ranges (that will vary in distance), so that I have something like the following:
counted_values = [2,0,4,5,6,0,0,4,2]
So far I've written something that works but makes me shudder slightly, as I'm sure there's a more Rubyist/Rails way of doing it.
Current code:
...
I have following code in my deploy.rb
namespace :app do
desc "copies the configuration frile from ~/shared/config/*.yml to ~/config"
task :copy_config_files,:roles => :app do
run "cp -fv #{deploy_to}/shared/config/hoptoad.rb #{release_path}/config/initializers"
run "cp -fv #{deploy_to}/shared/config/app_config.yml #{release_...
Hello,
I have two tables on mysql: users, and management. The users table has a numeric id, and the management table has a varchar foreign key which is the primary key of the other table. The types are not the same, and this seems to be the main problem when I build an index from the User model, and try to include one column from the ma...
How do i use a link_to inorder to go to a specific (html) ID on a page normally
if i wanted to go to the "whatever_id" on a page i could use
<a href="http://www.example.com/index/mypage#whatever_id>Click Here</a>
but i would like to use my link_to
<%= link_to "click here" , {:action => "mypage", :controller => "index" }, :id => "...
Hi all,
So I'm trying to figure out a way of stubbing a controller method in rspec for a Sinatra app. The main reason for this is to test the logical flow of the application and to make sure it calls the necessary functions when certain conditions are met. So, in essence, I want to be able to do something like
controller.should_receive...
Can anyone provide some clues as to why these two pieces of code are not equivalent? My only thought is that the .open in the latter code portion is not in a block and the file handle is left open.
File.open(file) do |io|
io.each_line do |line|
body_string << line
end
end
and this one
File.open(file).each_line {|line| body_s...
I want to make a simple JSP parser by using Treetop. Now, I have the following problem:
My basic grammar for starting is:
grammar Jspgrammar
rule jspToken
'<%'
end
rule jspPageToken
jspToken '@page'
end
jspToken should match '<%' while jspPageToken should match '<%@page'
When I try this in irb:
...
My gem semantictext has a bunch of test data that it reads for regression testing.
Here's the project: http://github.com/dafydd/semantictext
Here's an example test that I want to be able to run directly from the gem: http://github.com/dafydd/semantictext/blob/master/test/test%5Fdocument.rb (look for text "SANDBOX")
I normally develop...