Questions tagged [rakefile]

0

votes
0

answer
5

Views

Include / require common lib file in rake task

I tried these things suggested in this post and nothing worked I give up, I've tried everything and back again and for the life of me I can't include / require my common methods file in my rake task. First I thought that if you added a file in the lib folder and made sure it was in the load path tha...
ToddT
1

votes
2

answer
1.2k

Views

Specifying file prerequisites for Rake task

I've got a helper class that scans my entire project directory and collects a list of source files and the corresponding (target) object files. The dependencies on the compile task is defined after scanning the source directory as shown below. CLEAN.include(FileList[obj_dir + '**/*.o']) CLOBBER.incl...
thegreendroid
1

votes
2

answer
296

Views

Rake equivalent of make -j (--jobs)

The make commands allows a -j (--jobs) options documented as such: -j [jobs], --jobs[=jobs] Specifies the number of jobs (commands) to run simultaneously. If there is more than one -j option, the last one is effective. If the -j option is given without an argument, make will not limit the numb...
William Entriken
2

votes
2

answer
783

Views

Adding Growl notifications after Rake tasks are finished

Is there a way to add Growl notifications to the end of all Rake tasks? I initially thought of creating a task that Growls, and adding it as a dependency to tasks I want alerts from, but realized the dependencies get run before the task begins. Is there a way to add tasks to be run after certain Ra...
funkymunky
5

votes
2

answer
2k

Views

Check if rake task exists from within Rakefile

I'm looking for a way to be able to check if a certain rake task exists from within the Rakefile. I have a task dependency that I only want to include as a dependency if that task is available. In this particular case, the task is only available in a Rails project, but I want my rake tasks to work i...
conorliv
5

votes
1

answer
1.4k

Views

Load rake tasks from ruby gem

I'm writing a gem and I want to have an access to the gem rake tasks from my rails app. To do this I use Railties. I have lib/frontrockets-rails/railtie.rb with require 'frontrockets-rails' require 'rails' module FrontrocketsRails class Railtie < Rails::Railtie railtie_name :frontrockets rake_tasks...
Maxim Abramchuk
5

votes
3

answer
3.8k

Views

Generate Rake test tasks dynamically (based on existing test files) in a Rakefile

I'm generating test tasks dynamically based on existing test files in a Rakefile. Consider you have various unit test files named after the pattern test_.rb. So what I'm doing is creating a task named after the file name inside the 'test' namespace. With the code below I can then call all the tests...
jasoares
6

votes
2

answer
5k

Views

Using rake import (calling other rakefiles)

Here's my primary rake file subrake = 'subrake' task :init => [subrake] do #call subrake.build end import subrake I see documentation on how the above steps work, but I can't figure out how to call tasks in the other subrake file. BTW, those tasks may have the same name as mine, is this an issue?
Drew
5

votes
1

answer
339

Views

Rake task outside of namespace

I have a rake file set up like so: require 'rake' namespace :setup do puts 'I'm in setup' task :create do puts 'I'm in create' end end task :run do puts 'I'm in run' end If I run rake setup:create I get the expected: I'm in setup I'm in create However, if I run rake run I get: I'm in setup I'm in ru...
Anthony
22

votes
1

answer
931

Views

Building a C++ project using rake in Eclipse

I have a C++ project that I build using rake rather than a make. To set this up in Eclipse I disabled the CDT and Scanner builders and created a rake builder pointing to the rake executable. This causes the project to be built correctly with Ctrl-B. However the C++ error parser don't seem to be kick...
Sasha
2

votes
1

answer
1.2k

Views

<echo> ant task equivalent in rakefile?

What is the equivilent to the ant task in a ruby rake file?
leeand00
2

votes
1

answer
108

Views

Remove sensitive information from a Rakefile

What are the recommended procedures for removing sensitive information from a Rakefile? For example, my project's Rakefile looks like: # -*- coding: utf-8 -*- $:.unshift('/Library/RubyMotion/lib') require 'motion/project' require 'bubble-wrap' Motion::Project::App.setup do |app| # Use `rake config'...
Zach Latta
2

votes
1

answer
426

Views

Rails error Uninitialized constant importing csv

This is my first time importing a csv file to my rails app. I have the code below in /lib/tasks/import.rake require 'csv' CSV.foreach('lib/articles.csv', headers: true, encoding: 'ISO8859-1') do |row| Article.new(title: row['Title'], body: row['Body'], user: User.find(1)) end When I run rake impor...
jgrant
1

votes
1

answer
459

Views

Don't know how to build task 'recipe_test.rb'

I know same question is asked before but those were totally different scenarios than mine . I have a .rb file in my rails_app/test/integration recipe_test.rb require 'test_helper' class RecipeFlowsTest < ActionDispatch::IntegrationTest fixtures :recipes test 'create recipes' do https! # sign in emul...
ImranNaqvi
3

votes
2

answer
2.2k

Views

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?
Geo
2

votes
1

answer
166

Views

Rake's rule does not check timestamp

The following Rakefile is for a simple program which needs a.c and a.h. # Rakefile task :default => 'a.out' file 'a.o' => 'a.h' file 'a.out' => 'a.o' do |t| sh 'gcc -o #{t.name} #{t.prerequisite_tasks.collect(&:name).join(' ')}' end rule '.o' => '.c' do |t| sh 'gcc -c -o #{t.name} #{t.source}' end I...
kukyakya
2

votes
1

answer
1.2k

Views

bin stub - missing dependencies from gem (executing rake tasks within gem)

I've written a gem elastic-beanstalk which is to be used inside a rails project file structure, as well as in a standalone CI environment where the rails dir and files are not available (without unzipping etc). i.e. the Bamboo build process running eb:package will yield one primary artifact app.zip...
kross
2

votes
2

answer
293

Views

Command to display all descriptions of rakefile tasks?

I know in Ant / Nant you can pass an argument like -projecthelp to get a list of avaialbe targets with descriptions. Is there a similar command-line argument for doing this with a rakefile's tasks? Also is there a way to generate documentation from the rakefile itself?
leeand00
4

votes
1

answer
2.5k

Views

heroku run rake db:migrate … rake aborted! No Rakefile found

When I run heroku run rake db:migrate, I receive the following error: $ heroku run rake db:migrate Running `rake db:migrate` attached to terminal... up, run.8507 rake aborted! No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb) /usr/local/lib/ruby/1.9.1/rake.rb:2367:in `raw...
Joe Morano
12

votes
8

answer
3.8k

Views

How can I use a comma in a string argument to a rake task?

I have the following Rakefile: task :test_commas, :arg1 do |t, args| puts args[:arg1] end And want to call it with a single string argument containing commas. Here's what I get: %rake 'test_commas[foo, bar]' foo %rake 'test_commas['foo, bar']' 'foo %rake 'test_commas['foo, bar']' 'foo %rake 'test_co...
Ben Taitelbaum
30

votes
3

answer
16.1k

Views

Load rake files and run tasks from other files

Currently I'm trying split up my rake files to organize them better. For this, I've added a rake folder to my assets dir, that holds one rake file for each group of tasks. As I'm coming from PHP, I've only very basic knowledge of Ruby/Rake and can't get my namespaces default action running after loa...
kaiser
2

votes
4

answer
1.7k

Views

Logging to rails console with rake

I have a rake file that is being called by a job scheduler. The file outputs the desc but I am not able to log anything else to the console. What am I missing? inbox.rake namespace :inbox do desc 'Check inbox for new app builds' task process_inbox: :environment do puts 'my task is working' end end
Antarr Byrd
31

votes
3

answer
77.3k

Views

File.open, write and save?

I am trying to get a .rb file to make another .rb file within a specific directory with specified content, when that file is run. I dont know whether the best way to do this would be with a Ruby file or a Rake file. You input would be great.
CharlesJHardy
7

votes
1

answer
1.6k

Views

What exactly does $:.unshift(File.expand_path(“../../lib”, __FILE__)) do?

There are a lot of threads on here about this already I know but none of the titles have this worded exactly like I did. I hope that we can clear this up a bit. $:.unshift(File.expand_path('../../lib', __FILE__)) You see something like this in a lot of Ruby code. Opinions vary whether this is prope...
Douglas G. Allen
2

votes
1

answer
4.8k

Views

Ruby: return nonzero exit status

I would like my Ruby script to return any non-zero exit status upon a certain condition. The exit status itself does not matter as long as it is not zero. I tested out how it's done: test_exit.rb: exit 4 test_exit_wrap.rb: system('ruby test_exit.rb') puts $?.exitstatus cmd: > ruby test_exit_wrap.rb...
Kei
2

votes
1

answer
294

Views

Error in Rake Task in Redmine

When I'm trying to install the plugins by Rake command I'm getting the below error can any one help? rake redmine:plugins:migrate:RAILS_ENV=production rake aborted! Don't know how to build task 'redmine:plugins:migrate:RAILS_ENV' Note that im using 2.2.0 version
Chanthu
3

votes
0

answer
42

Views

better way to manage state between rake tasks (starting and stopping servers by process id)

I have a requirement to start and stop servers within rake tasks. Each server gets a specific process id. I have created a number of tasks that start and stop each server (note that the servers may not always be unique and will start on different ports, so its unreasonable that I grep/search for pro...
aDiT
2

votes
3

answer
251

Views

What can rakefiles be used for?

I understand the utility of the rake command, but what kinds of custom actions are typically defined in the Rakefile? I'm new and trying to figure out when it's appropriate to use this feature. I've found out plenty about how to use it, but not much about 'best practices'.
Matty
1

votes
3

answer
1.3k

Views

Access a class method from a model in the Rakefile / Ruby on Rails 3

I have a model, let's call it Foobar. I want to be able to run a cron job to update an attribute of all objects that are instances of Foobar. So, in pseudocode, it might be something like this: Foobar.all.each do |foobar| foobar.update_attributes({:my_attribute => 'updated'}); end Now, let's say I...
Morris Singer
3

votes
1

answer
855

Views

Add Ruby Source Code as HTML to RDoc

How do I include a ruby code file, as is, into RDoc? I have an example.rb file that documents how to use my gem and I would like to include that as one of the files like the README.rdoc and HISTORY.rdoc. I've already figured out how to convert the ruby source code into HTML using the Syntax gem but...
2

votes
2

answer
952

Views

Create a zip file using Rake::PackageTask

I am trying to package up a zip file in my rake file and I am pretty inexperienced with Rake and ruby, so I am having a hard time identifying why this is failing. This is what I have tried: def create_zip_file(targetDirectory, projectToZip) puts 'target:' + targetDirectory puts 'Zipping ' + projec...
David Watts
2

votes
1

answer
603

Views

How to use rake with rake tasks outside rails?

I think Rails is very heavy and I'm taking pieces out of my projects and making them standalone. My library of tasks, I would like it to work outside Rails. So there is no application and no config/application.rb, only the lib/ folder that defines tasks. How should I structure my rakefile to include...
Victor Piousbox
5

votes
2

answer
683

Views

Rake cp permission denied on windows

Here's the rake file. task :default => :release task :release do target = 'releases/' + Time.new.strftime('%Y%m%d') mkdir_p target cp Dir['web'], target end I get 'permission denied - web'. what do I have to do to give rake the same rights I have when it runs, in windows.
DevelopingChris
5

votes
2

answer
738

Views

How do I pass args from command line to rake then rspec

I'm trying to pass a couple of variables through the command line to rake to be used in rspec. From what i gather i can do this to pass args into my rake task: task :my_task, :arg1, :arg2 do |t, args| puts 'Args were: #{args}' end but I'm using rspec so my rake task looks like this: RSpec::Core::Ra...
Jayson Ng
2

votes
1

answer
807

Views

rake db tasks running twice

I was seeding a development postgres database with a few thousand records from Faker when I caught a problem with the seed file. I aborted the seed operation and rolled back the inserts and fixed the seeds.rb file. When I went to run it again, every rake db:* task runs twice. I can run rake routes...
bubunt205
5

votes
1

answer
398

Views

Accessing Rails environment config in Rake namespace

I have a path defined in my environment.rb file MyRailsApp::Application.configure do config.xml_import_path = '/path/to/xml' end I'd like to be able to set a variableaccess these within a Rake file like this namespace :myapp do xml_path = MyRailsApp::Application.config.xml_import_path task :first_ta...
LukeR
3

votes
1

answer
895

Views

can't uninstall rake 0.9 on rails 2.3.8

I'm working on a legacy Rails 2.3.8 project and setting up a dev server. I get errors when I try to run rake, and I realized I have the wrong version of Rake installed, in the Rakefile it says: s.add_dependency 'rake', '>= 0.7.1' and I have 0.9.2.2 installed. When I try to uninstall, I get ERROR:...
schatzkin
2

votes
1

answer
287

Views

Rakefile - stop every tasks in a multitask

I have an application running with Flask, and use Compass as css preprocessor. Which means I need to start the python server and compass for development. I made what I thought was a clever Rakefile to start everything from one command and have everything run in only one terminal window. Everything w...
romainberger
2

votes
0

answer
214

Views

Rake task to fetch current price and update object attribute

I have a Portfolio model and am currently running rake tasks to fetch updated price data from Yahoo Finance API, updating the amounts for the Portfolios and create a new Valuation object that takes a snapshot of each portfolio and their values. A Portfolio has_many Positions that store tickers and...
Coder_Nick
46

votes
2

answer
27.6k

Views

What is a Rakefile?

I have started learning Ruby and just tried out my first hello world program in NetBeans IDE. I have one doubt, I can see that the new project wizard created set of package structure. It had one 'Rakefile' in it. What does that mean and what is the use of it?
bragboy

View additional questions