ruby

Something like sharepoint but built in ruby on rails?

Are there any gems, plugins, frameworks etc that give sharepoint like functionality (list and file management & versioning) but are based on ruby on rails? ...

Accessing class methods like instance methods

class Foo def self.bar puts "foobar" end def bar self.class.bar end end I want to refrain from needing to define the instance method bar. Is there a way to automatically make class methods accessible as instance methods? Maybe with some method_missing? magic? ...

SQLite3/Ruby statement question

Hello, I am trying to import a file as a table in SQLite 3 using a Ruby script. I need to assign a tab separator, and I used the following code: db = SQLite3::Database.new("meshdb2.db") db.execute("CREATE TABLE IF NOT EXISTS pubmed(id integer primary key,prideID INT NOT NULL,pubmedID VARCHAR(10) NOT NULL) db.prepare(".separator '\t'") ...

Remove all but some special characters

Hey, I am trying to come up with a regex to remove all special characters except some. For example, I have a string: str = "subscripción gustaría♥" I want the output to be "subscripción gustaría". The way I tried to do is, match anything which is not an ascii character (00 - 7F) and not special character I want and replace it with b...

How do I profile my Ruby test suite in aggregate?

The usual sob story: my tests are running slowly. My first thought was to profile the whole test suite to look for obvious wins (stubbing out network access or caches), so I added a ruby-prof task: RubyProf::ProfileTask.new(:units) do |t| t.test_files = FileList[RAILS_ROOT + '/test/unit/**/*_test.rb'] t.output_dir = Dir.tmpdir t....

Finding the product of a variable number of Ruby arrays

I'm looking to find all combinations of single items from a variable number of arrays. How do I do this in Ruby? Given two arrays, I can use Array.product like this: groups = [] groups[0] = ["hello", "goodbye"] groups[1] = ["world", "everyone"] combinations = groups[0].product(groups[1]) puts combinations.inspect # [["hello", "world...

Getting a list of all packages from shipping carriers.

I've been looking at the APIs for UPS, FedEx, USPS, etc, and I can't seem to find any method of pulling all tracking info for a given user. I only see methods that pull info via a tracking number. Has anyone been able to find a way to get at this data? Seems silly to me that these huge carriers wouldn't supply this info in an easy method...

Making an equals method without needing to make private fields public

I'm writing a Ruby class, and want to override the == method. I want to say something like: class ReminderTimingInfo attr_reader :times, :frequencies #don't want these to exist def initialize(times, frequencies) @times, @frequencies = times, frequencies end ... def ==(other) @times == other.times and @freq...

Prevent Rails 2 from caching of Lib/ Classes

Does anyone know how to instruct rails to NOT cache classes that are included within the lib folder? ...

Ruby/Mechanize Multipart Form With File Upload to a Mediawiki

I've been trying to write a ruby script using mechanize to batch upload a large number of images to a MediaWiki. The script runs without any errors but I suspect there is something wrong with the way I'm handling multipart forms with mechanize. The result variable at the end of the code gives no indication of success or failure, it just ...

Where is the new_post_path, edit_post_path, posts_path ... lies in the source? I need to override them

Where is the new_post_path, edit_post_path, posts_path ... lies in the source? I need to override them. my env: ruby-1.9.2-preview rails-3.0.0.beta3 ...

How can I request a Rails page from within a Rails page?

A certain action must load an html page according a uri parameter. It works fine for all valid uris, except those of the current server. Is there an easy way to request a page from within a controller? require 'uri' class MainController < ApplicationController def foo uri = URI(params[:uri]) if uri.host =~ /localhost|mydomain\...

How do I parse this key-value pair?

This is the output from doing puts get_account_entry.inspect [[{:value=>"8b08e26a-6d35-7140-9e41-4c5b4612c146", :name=>"id"}, {:value=>"Typhoon Corporation", :name=>"name"}]] How do I extract out the value of :name => "id" for example? Originally I thought it was like a hash, so get_account_entry[id] would produce the result, but it ...

DRY the SUT up - RSpec and Mocking question

n the .net world, my specs would follow the Arrange, Act, Assert pattern. I'm having trouble replicating that in rspec, because there doesn't appear to be an ability to selectively verify your mocks after the SUT has taken it's action. That, coupled with the fact that EVERY expectation is evaluated at the end of each 'It' block, is cau...

ruby: irb gives NameError attempting to use mechanize gem (ubuntu)

On my ubuntu box, irb (ruby) gives a NameError when I try to use the mechanize gem: $ irb irb(main):001:0> require 'mechanize' => true irb(main):002:0> Mechanize.new NameError: uninitialized constant Mechanize from (irb):2 from :0 gem env shows this: RubyGems Environment: - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.8.7 (2...

how to assign a value to another class's initialize parameter from child class in Ruby

How do I assign a value to another class's initialize parameter in Ruby class Ubac def initialize(p_str) @p_str=p_str (.....) end def method1 (.....) end end class ReqQuote < Ubac def initialize(p_code) @code=p_code # here how do i initialize the @p_str to the value which is returned from the get_data m...

Setting up a Ruby development environment

Hi, I am currently trying to set up a development environment for learning Ruby. The environment will primarily be for getting to grips with the language, but I will most probably move on to development with Rails after long. With web development a target, I would like to hear about preferred web servers and databases. I plan on settin...

Conversion of Data Type in column of migration table

Suppose that I have a table Attendances (id(integer), login_date(date), login_time(time),logout_time (time)). Now I have to change the data type of logout_time from time to datetime. So how it can be possible in Migration ? Because i Tried this statement in new migration. change_column(attendances, logout_time, time, datetime) Please s...

=== vs. == in Ruby

In Ruby, what is the difference between == and ===? The RDoc says Case Equality—For class Object, effectively the same as calling #==, but typically overridden by descendents to provide meaningful semantics in case statements. Is #== the same as ==? And could you provide an example of when/how this is used in case statemen...

require 'ruby-debug' LoadError: symbol not found

I've somehow broken my ruby configuration, and I'm not sure how to fix it. Here's an irb session: >> require 'ruby-debug' LoadError: dlsym(0x101a272d0, Init_ruby_debug): symbol not found - /opt/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.3/lib/ruby_debug.bundle from /opt/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.3...