I want to delete a gem I uploaded to GemCutter. I couldn't find any commands for this. Some time ago there was a blog post stating gem deletion as an upcoming feature. I haven't seen any further official announcements about this feature.
Please let me know if there is a way to do this.
...
I am trying to parse a text file that contains a variable number of words and numbers per line, like this:
foo 4.500 bar 3.00
1.3 3 foo bar
How can I read the file delimited by spaces instead of newlines? Is there some way I can set the File("file.txt").foreach method to use a spaces instead of newlines as a delimiter?
...
I'm trying to add a navigation link from a plugin that I made without altering the main app files. For example, say that I have this:
app/views/shared/_navigation.html.erb
<ul id="navigation">
<li><a href="#">Nav link A</a></li>
<li><a href="#">Nav link B</a></li>
<li><a href="#">Nav link C</a></li>
</ul>
If I have a custom plugin...
class Promotion
def self.get_todays_promotions
# Promotion is a parent model, having child models e.g.
# DiscountPromotion, VoucherPromotion, etc.
# they all use a single table called promotions
# (and having 'type' field explaining which model they belong to)
promotions = self.find(:all, :conditions => [Promotion....
Is it possible to make yield keyword work inside a block given to define_method? Simple example:
class Test
define_method :test do |&b|
puts b # => #<Proc:...>
yield
end
end
Test.new.test {
puts "Hi!"
}
This code produces following error in both Ruby 1.8.7 and 1.9.0:
test.rb:4:in `test': no block given (LocalJump...
How can I copy files to a USB stick with Ruby (in Windows)?
So far I have tried to identify the path of the USB stick, with the idea of using FileUtils to copy the files. However, I haven't been able to identify the path.
Anyone know how to do this, or suggest an alternative approach.
Thanks
Edit:
I've found a solution. Windows in...
I have a Time instance curr_time with the value of Time.now and another String target_date with the value, say, "Apr 17, 2010". How do I get the date part in the variable curr_time change to the value of target_date ?
>> curr_time
=> Sun Feb 21 23:37:27 +0530 2010
>> target_date
=> "Apr 17, 2010"
I want curr_time to change like this:...
I have an odd situation where $" seems to be surviving between calls, but nothing else does. It's returning properly the first call, and fail each additional request. This should be global information, so It won't work just to put it in a session.
The comments show what logging returns, but my experience with "FileImport.installed_for...
I would like to determine the number of records that a query on a Tokyo Cabinet Table will return before I run the query. I am using the rufus-tokyo Ruby gem as my interface. What is the best way to do this?
...
Hi,
maybe someone knows the technical answer to the following behaviour:
s = "hello world!"
s == s.upcase
# =>false, because "hello world!" != "HELLO WORLD!"
s == s.upcase!
#=>true, because s is changed before comparison?
Thanks in advance,
Mathias
...
I have one rubyonrails app that turned really slow in development mode. Everything is fine in production, but even a simple "hello world" takes seconds in dev. I checked the session store and every possible reason i found on the net, but I didn't find the problem. Am I missing something that is common knowledge? "Completed in 1657ms (Vie...
I'm looking for a document-oriented db with a Ruby API that has SQLite-like properties:
self-contained,
serverless,
zero-configuration.
Are there light alternatives to MongoDB or CouchDB?
Is RDDB a possibility?
If not, what are the best paths to walk then?
...
RubyGems newbie here, trying to install the 'less' gem. I type 'sudo gem install less' as instructed at http://lesscss.org/, and I get the following error:
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find less (> 0) in any repository
Alright, so I figure maybe I just need to update RubyGems. Trying 'gem...
I was just wondering why Ruby exposes symbols for explicit use - isn't that the sort of optimisation that's usually handled by the interpreter / compiler? Thanks for any insight :)
...
Having this mix of polymorphism and inhertiance, I encounter some weird behaviour:
Migration
class CreateCommons < ActiveRecord::Migration
def self.up
create_table :commons do |t|
t.string :name
t.string :configurable_type
t.integer :configurable_id
end
create_table :specifics do |t|
t.integer :nu...
How can I make the code below work, so that both puts display 1?
video = []
name = "video"
name[0] = 1
puts name[0] #gives me 1
puts video[0] #gives me nil
...
I want to display some statistics of data stored in array of arrays. I have three categories (video,article,webinar) but it could expand later on. The structure of statistics per category will be almost the same. Like: total number of videos, last date when added new record in category, etc.
So far I can think of a hash of an array to s...
Hi all-
I am currently scraping an rss feed from last.fm and the title attribute looks like it has a unicode "-" that comes up as \u2013 on firebug. Here is the feed for those that are curious:
http://ws.audioscrobbler.com/2.0/user/rj/recenttracks.rss
When I write something like this
feedentry.title.split('-')
it won't find the un...
I try to modify "/foo/bar/dir" -> "\/foo\/bar\/dir" before execute it in command line.
I test by using gsub in irb the result is
x = "/foo/bar/dir"
x.gsub("/","\\\/")
=> "\\\/foo\\\/bar\\\/dir"
x.gsub("/","\/")
=> "/foo/bar/dir"
Is it possible to replace "/" with "\/" by gsub ?
Source of problems is
I try to execute "string i...
I want a function that keeps local state in Ruby. Each time I call the function I want to return a result that depends both on a calling argument and on the function's stored state. Here's a simple example:
def inc_mult(factor)
@state ||= 0 # initialize the state the first time.
@state += 1 # adjust the internal state.
factor...