I need an easy way to take a tar file and convert it into a string (and vice versa). Is there a way to do this in Ruby? My best attempt was this:
file = File.open("path-to-file.tar.gz")
contents = ""
file.each {|line|
contents << line
}
I thought that would be enough to convert it to a string, but then when I try to write it back ou...
I have a backroundrb scheduled task that takes quite a long time to run. However it seems that the process is ending after only 2.5 minutes.
My background.yml file:
:schedules:
:named_worker:
:task_name:
:trigger_args: 0 0 12 * * * *
:data: input_data
I have zero activity on the server when the process is running. (...
Hello,
Trying to install the RMagick gem is failing with an error about being unable to find ImageMagick libraries, even though I'm sure they are installed.
The pertinent output from gem install rmagick is:
checking for InitializeMagick() in -lMagick... no
checking for InitializeMagick() in -lMagickCore... no
checking for InitializeMa...
Can someone explain why how the result for the following unpack is computed?
"aaa".unpack('h2H2') #=> ["16", "61"]
In binary, 'a' = 0110 0001. I'm not sure how the 'h2' can become 16 (0001 0000) or 'H2' can become 61 (0011 1101).
...
Hi guys,
I'm running a strange problem sending emails. Basicly I'm getting this exception:
ArgumentError (wrong number of arguments (1 for 0)):
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:642:in `initialize'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:642:in `new'
/usr/lib/ruby/...
The question I'm really asking is why require does not take the name of the gem. Also, In the case that it doesn't, what's the easiest way to find the secret incantation to require the damn thing!?
As an example if I have memcache-client installed then I have to require it using
require 'rubygems'
require 'memcache'
...
How do I find the name of the namespace or module 'Foo' in the filter below?
class ApplicationController < ActionController::Base
def get_module_name
@module_name = ???
end
end
class Foo::BarController < ApplicationController
before_filter :get_module_name
end
...
Hi I was looking into Ruby to actionscript 3 bytecode compilers and found a mention of a project called Red Sun but can find very little information on it.
So my Question is ... what tools are available to convert Ruby source into AS3 bytecode
...
I want to log user's actions in my Ruby on Rails application.
So far, I have a model observer that inserts logs to the database after updates and creates. In order to store which user performed the action that was logged, I require access to the session but that is problematic.
Firstly, it breaks the MVC model. Secondly, techniques ran...
Hi,
I am running ruby and MySQL on a Windows box.
I have some Ruby code that needs to connect to a MySQL database a perform a select. To connect to the database I need to provide the password (amongst other things). My question is this: How can I get ruby to display the types password as a line of asterisks in the 'dos box'.
In other ...
I have heard that it's best not to actually have any html in your helpers; my question is, Why not? And furthermore, if you were trying to generate an html list or something like that, how can I avoid actual tags?
Thanks!
-fREW
...
I've been kicking around Ruby and the rails framework and have been considering recommending to a client-of-a-client that they use it to rebuild their site, which is currently built in very bad ASP classic that will have to be rewritten from the ground up regardless of what technology is used.
One thing I'm missing from my pitch is a li...
This is a follow-up to this question.
When I issue the gem update command on Windows, whenever it gets to a
gem whose latest version DOESN'T have Windows binaries, it'll attempt to
build the native extension which will, of course, fail. For example:
Updating sqlite3-ruby
Building native extensions. This could take a while...
ERROR: W...
What are the advantages/disadvantages of the major Ruby VMs (things like features, compatibility, performance, and quirks?) I know there are also some bonus features like being able to use Java interfaces through JRuby, too. Those would also be helpful to note. Does any VM have a clear advantage at this point, and in what contexts?
...
In Ruby, is there the equivalent of the __str__() method that you can define on Python classes?
...
Hi
Any thoughts on using Flex to build an RIA for administering a complex rails app.
We are starting to find it difficult using ajax to keep our admin section intuitive and easy for users to work with.
Would welcome any advise or suggestions you all may have
Thanks
Dom
...
So, I want to define a singleton method for an object, but I want to do it using a closure.
For example,
def define_say(obj, msg)
def obj.say
puts msg
end
end
o = Object.new
define_say o, "hello world!"
o.say
This doesn't work because defining a singleton method via "def" is not a closure, so I get an exception that "msg" is...
short:
Is there a way in Ruby to DRY-ify this:
def entry_point_one
begin
do_something
rescue MySyntaxErrorOne, MySyntaxErrorTwo, MySyntaxErrorEtc => syn_err
raise syn_err.exception(syn_err.message)
end
end
def entry_point_two
begin
do_something_else
rescue MySyntaxErrorOne, MySyntaxErrorTwo, MySyntaxErrorEtc => s...
I'm using this code to let the user enter in names while the program stores them in an array until they enter an empty string (they must press enter after each name):
people = []
info = 'a' # must fill variable with something, otherwise loop won't execute
while not info.empty?
info = gets.chomp
people += [Person.new(info)] if n...
I've used ZenTest and autotest to work on Ruby projects before, and I used to using them for test-driven development a la this configuration. I have a project that I'm currently working on in Java, and I was wondering if there is something similar in the Java world to achieve the same effect.
...