Project

wrake

0.0
No commit activity in last 3 years
No release in over 3 years
Runs rake without having to load the entire rais app
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

<= 5.0.0, >= 3.0.0
 Project Readme

Wrake

A web partner of Rake. Runs wrake via web api.

Build Status Coverage Status Code Climate Dependency Status Gem Version

But why?

When you run rake inside rails, you have to load the entire application. By running wrake, rake will be callled via web API, through your aready loaded rails app.

Instalation

Add this line to your application's Gemfile:

gem 'wrake'

And then execute:

$ bundle
$ rails g wrake:install

This will create the following files:

  • config/wrake.yml - the configuration file is self explicative.
  • config/initializers/wrake.rb - the configuration file is self explicative.

Also, you wil need to mount the engine:

# config/routes.rb

mount Wrake::Engine, at: 'wrake'

Usage

Using API

api  = Wrake::Api.new(url: base_url, username: username, password: password)

# or to get the api with default configuration

api = Wrake.api

response = api.invoke_task('some:task', { args: 'a b c' })
# or
response = api.invoke_task('some:task', args: ['a', 'b', 'c'])

puts response.code, response.headers, response.body, response.message

Using the CLI

wrake cache:clean -c path/to/wrake.yml -e development

wrake mail:welcome new@user.com -c path/to/wrake.yml

Password protecting the API

By default, the API is protected by Basic Auth. You could change the default behavior by overwriting the wrake_authorization method:

class ApplicationController < ActionController::Base
  def wrake_authorization
    authenticate_or_request_with_http_basic do |username, password|
      User.with_wrake_privileges.where(email: username, password: password).first!
    end
  end
end

TODO

Authors

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

** Do not forget to write tests**