rake

What makes Rake so useful in Ruby?

Perhaps this is a dumb question, and I'm not under estimating the value of Rake here by any means, I'm just not getting it. What value does Rake have if all it is, is arbitrarily executed Ruby code? It's apparently good at handling tasks, but what's to stop me from writing a class and embedding it into a shared Ruby directory and executi...

How do I return early from a rake task?

I have a rake task where I do some checks at the beginning, if one of the checks fails I would like to return early from the rake task, I don't want to execute any of the remaining code. I thought the solution would be to place a return where I wanted to return from the code but I get the following error unexpected return ...

Rake task which consumes many data freezes

Hi all, I have a simple rake task which consumes pretty much data via ActiveRecord. (contacts has ~47k rows) Contact.all.each do |contact| contact.update_attribute ... end When I run that task ~400 rows get updated and then the task stucks. No errors and no database activity at all... How do I make this work properly? ...

Help with rake dependency mapping.

I'm writing a Rakefile for a C++ project. I want it to identify #includes automatically, forcing the rebuilding of object files that depend on changed source files. I have a working solution, but I think it can be better. I'm looking for suggestions for: Suggestions for improving my function Libraries, gems, or tools that do the work f...

How do you communicate between Rake tasks?

Let's say I have a target who needs to compile some files. That target has another target as a prerequisite, one that obtains the files. Let's say this: task :obtain do # obtain files from somewhere end task :compile => :obtain do # do compilation end Let's say that the :obtain target doesn't always places the files in the same f...

Is it possible to use in a Rakefile tasks from another one?

I have some Rake tasks I'd like to use in my Rakefiles. Is it possible to include tasks defined in one rakefile from another rakefile? ...

Continue after exception in RSpec

Is there any way to have RSpec continue processing specifications after an exception is raised? This is what my spec task looks like: SPEC_PATTERN = "spec/**/*_spec.rb" Spec::Rake::SpecTask.new() do |t| t.spec_files = FileList[SPEC_PATTERN] t.verbose = true t.spec_opts = ["--format", "html:spec/spec_report.html"] t.fail_on_erro...

Is there any way to keep all the tasks inside Rake in reenable mode?

I'd like to run tasks in a Rakefile multiple times. Is there a way to specify that, or do I need to .reenable them each time I want to invoke them? ...

RSpec spec fails when invoked via "rake spec", passes when invoked via "spec spec"

One of my specs fails when I run it via "rake spec" but passes when I use the RSpec executable "spec". The spec fails when I use a url helper in a ActionMailer view. The error message is: auction_url failed to generate from {:action=>"show", :state=>"asd", :slug=>"asd", :controller=>"auctions"}, expected: {:action=>"show", :controller=...

Can one automatically write a Rails migration for a table change via command line?

Is there a way to write this in the command line that will auto-generate the migration script below? Example: ruby script/generate migration renamePostsTableToActicles Generates: class RenamePostsTableToActicles < ActiveRecord:Migration def self.up rename_table :posts, :articles end def self.down rename_table :articles,...

How to monkey patch a rake task shipped with Rails?

I just found a bug in one of the rake tasks shipped with Rails. Is there a way to monkey patch a rake task? ...

Rake uses jruby instead of ruby after jruby install

Hi, I recently installed jruby on a machine that also has ruby installed on it. When I do rake something it now appears to be using the jruby interpreter. I'd like rake to use the ruby interpreter. I'd appreciate any help. ...

Rails - rake:gems:install - not installing gems

If i define a few gems in my config/environments/test.rb file like this: config.gem "rspec" config.gem "rspec-rails" config.gem "mocha" and then run 'rake gems:install RAILS_ENV=test' I get the following error: Missing these required gems: mocha Run rake gems:install to install the missing gems. however if I run rake gems:inst...

Rails, Rake, moving a folder to a new location

I need to move a folder from a plugin to the main app/views. I guess using rake to do this with the following command is the easiest way: require 'fileutils' FileUtils.mv('/vendor/plugins/easy_addresses/lib/app/views', '/app/views/') I'm just not sure where to tell script where to look and where to place the folder. The file I want...

Recursive wildcards in Rake?

Follow up to this question about GNU make: I've got a directory, flac, containing .FLAC files. I've got a corresponding directory, mp3 containing MP3 files. If a FLAC file is newer than the corresponding MP3 file (or the corresponding MP3 file doesn't exist), then I want to run a bunch of commands to convert the FLAC file to an MP3 file...

How can I call a controller action from a rake task?

I have a controller action that generates a number of excel reports, this takes about 10 minutes to do. Sometimes I call it from my webapp, which is why it is an action. But I also want to create a rake task to run this, so I can schedule it to automatically run once a night. Any way to do this? ...

Why is Rake not able to invoke multiple tasks consecutively?

I have a Rake task which I have simplified below. I'm using Ruby 1.9 on Windows. Perhaps you would like to guess the outcome of calling the Rake task "list_all_levels" below? It should be: "Hello level 1" "Hello level 2" "Hello level 3" But for reasons unknown to me, it prints only "Hello level 1" and then stops. That is, it always ...

Rack URL Mapping

Hi, I am trying to write two kind of Rack routes. Rack allow us to write such routes like so: app = Rack::URLMap.new('/test' => SimpleAdapter.new, '/files' => Rack::File.new('.')) In my case, I would like to handle those routes: "/" or "index" "/*" in order to match any other routes So I had trying this: ...

Shell Script Sequencing with Rake

Hi All, I am working on a rake utility and want to implement something mentioned below: There are some shell commands in a sequence in my Rake file. What I want is that the sequence should wait for the previous command to finish processing before it moves to the next one. sh "git commit -m \"#{args.commit_message}\"" do |ok, res| # ...

Excluding .svn directories in Rake cp_r

I'm writing a rakefile using Albacore for my .NET stuff, and I'm trying to figure out the easiest way to copy a project to another directory (artifacts) while excluding the .svn directories in its subdirectories. Suggestions? I'm running into a wall here. ...