ruby

Using inotify-tools and ruby to push uploads to Cloud Files - SOLVED

Hi Guys, I wrote a few scripts to monitor an uploads directory for changes, then capture the file uploaded/changed and push it to cloud files using a ruby script. This all works well 95% of the time, the only exception is that occasionally, ruby fails with a 'file does not exist' exception. I am assuming that the ruby 'push' script is ...

Why don't RSpec's methods, "get", "post", "put", "delete" work in a controller spec in a gem (or outside Rails)?

I'm not new to Rails or Rspec, but I'm new to making gems. When I test my controllers, the REST methods "get", "post", "put", "delete" give me an undefined method error. Below you'll find code, but if you prefer to see it in a pastie, click here. Thanks! Here's my spec_helper: $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.un...

Override default route if no parameter specified

Consider the following snippet: get '/hello/:name' do |n| "Hello #{n}!" end How can I set a default parameters if name isn't specified? If I can set the default paramater to Tom will this also route the URL so /hello/ will automatically redirect to /hello/tom? ...

Upgrade ruby projects from 1.8.6 to 1.8.7

Hello. Is there list of tips about upgradeing project's sources to be working on ruby 1.8.7? ...

Git + GitHub + Heroku

Hi All, I am new to the world of Git, GitHub and Heroku. So far, I am enjoying this paradigm but coming from a background with SVN, things seems a bit complicated to me in the world of Git. I am facing a problem for which I am looking for a solution. Scenario: 1. I have setup a new private project on GitHub. I forked the private proje...

aws-s3 and European Buckets

Is there a work around for European Buckets and aws-s3 with RoR? Thanks! ...

rspec & rails 3 cannot find model object

I'm trying to put some specs around a new rails 3 project I am working on, and my first test doesn't seem to be able to find a model. I've installed rspec from the command line using: sudo gem install rspec --pre and then I put the following in my Gemfile gem "rspec-rails", ">= 2.0.0.beta.1" But when I run my test I get ./spec/mo...

Are any large enterprises using Heroku?

I'm interested as sometimes I get friends who are developers telling me about their Ruby deployments, and most of them are in large enterprises which are using Java mainly, but have some small projects in Ruby on Rails. ...

What would cause native gem extensions on OS X to build but fail to load?

I am having trouble with some of my rubygems, in particular those that use native extensions. I am on a MacBookPro, with Snow Leopard. I have XCode 3.2.1 installed, with gcc 4.2.1. Ruby 1.8.6, because I'm lazy and a scaredy cat and don't want to upgrade yet. Ruby is running in 32-bit mode. I built this ruby from scratch when my MBP ran ...

Rails - asynchronous tasks, forked processes, best practices

I'm using a Observer on my classes. When one of the records is created/updated I need to notfify another service (via a URL call). What is the best way to do this to avoid slowing down my class? Would using a gem liked delayed_job be overkill? In my Observer's after_update() / after_create() I just want to launch a thread that calls the...

Getting Header Data with Sinatra

I'm writing a web app for EVE online in sinatra,and want to retrive header data. In php I can get data from a header variable with: $_SERVER['HTTP_EVE_TRUSTED'] how can I do the same in a sinatra page? ...

How do I handle a missing mandatory argument in Ruby OptionParser?

In OptionParser I can make an option mandatory, but if I leave out that value it will take the name of any following option as the value, screwing up the rest of the command line parsing. Here is a test case that echoes the values of the options: $ ./test_case.rb --input foo --output bar output bar input foo Now leave out the value...

Markdown to plain text in Ruby?

I'm currently using BlueCloth to process Markdown in Ruby and show it as HTML, but in one location I need it as plain text (without some of the Markdown). Is there a way to achieve that? Is there a markdown-to-plain-text method? Is there an html-to-plain-text method that I could feel the result of BlueCloth? ...

Why does a JRuby application on App Engine take so long to start (versus a Python app)?

I'm considering using JRuby on App Engine but have heard that Juby app on App Engine have a long startup lag versus a Python app. Why is this? Is it because the JRuby jar files are so large that a cold startup requires them to be loaded into memory before the app can start serving? That would be my guess but I'm not sure if that's a p...

gem install sinatra keeps fetching wrong version

when i type "gem install sinatra" it keeps pulling 0.9.4 instead of the new 1.0 why does this happen? ...

Jruby embedded modules and classes.

Hey, I have a ruby file as follows: module Example class Myclass def t_st "Hello World!" end end end now if this was just a class I would be able to use the following java code: ScriptEngine jruby = new ScriptEngineManager().getEngineByName("jruby"); jruby.eval(new BufferedReader(new FileReader("e...

Fork a process and send data to it inside Rails

I'm making a Rails application. In the one action I need to spawn a long running process. This is not a problem. I can fork new process using spawn gem or some other. But some time after process has been spawned, user must be able to pass additional data to that process. Sure, I can fork process which will listen a UNIX socket, store so...

Method synonyms in Ruby

I'm familiarizing myself with Ruby and it's the first time I see synonyms for methods in the standard library. For now I've found the ones in the Enumerable module: collect <-> map detect <-> find include <-> member etc. Probably other modules contains synonymic methods too. Why are they there? Is it some kind of backward compatibilit...

how to manually add a cookie to Mechanize state?

[I'm working in Ruby, but my question is valid for other languages as well.] I have a Mechanize-driven application. The server I'm talking to sets a cookie using javascript (rather than standard set-cookie), so Mechanize doesn't catch the cookie. I need to pass that cookie back on the next GET request. The good news is that I alr...

DataMapper Dates

Forgive me if this is a simple answer. But how do you get a Date from a DataMapper property. For example: require 'rubygems' require 'sinatra' require 'datamapper' class Test include DataMapper::Resource property :id, Serial property :created_at, Date end get '/:id' do test = Test.get(1) test.created_at = ? end ...