Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

First spike of functionality

  • Loading branch information...
commit e3f00756e99e49cdc8ea417c03b3b7c7e0cb2e52 1 parent 3446c6a
@alindeman authored
View
6 lib/rake-rails.rb
@@ -1,6 +1,2 @@
require "rake-rails/version"
-
-module Rake
- module Rails
- end
-end
+require "rake-rails/railtie" if defined?(Rails)
View
10 lib/rake-rails/railtie.rb
@@ -0,0 +1,10 @@
+module Rake
+ module Rails
+ class Railtie < ::Rails::Railtie
+ rake_tasks do
+ load File.join(File.dirname(__FILE__), "tasks.rb")
+ ::Rake::Rails::Tasks.new
+ end
+ end
+ end
+end
View
50 lib/rake-rails/tasks.rb
@@ -0,0 +1,50 @@
+require 'rake'
+
+module Rake
+ module Rails
+ TASKS = {
+ "generate" => "Generate new code (short-cut alias: \"g\")",
+ "console" => "Start the Rails console (short-cut alias: \"c\")",
+ "server" => "Start the Rails server (short-cut alias: \"s\")",
+ "dbconsole" => "Start a console for the database specified in config/database.yml (short-cut alias: \"db\")",
+
+ "application" => "Generate the Rails application code",
+ "destroy" => "Undo code generated with \"generate\"",
+ "benchmarker" => "See how fast a piece of code runs",
+ "profiler" => "Get profile information from a piece of code",
+ "plugin" => "Install a plugin",
+ "runner" => "Run a piece of code in the application environment"
+ }
+
+ ALIASES = {
+ "g" => "generate",
+ "c" => "console",
+ "s" => "server",
+ "db" => "dbcsonsole"
+ }
+
+ class Tasks
+ include Rake::DSL
+
+ def initialize
+ TASKS.each do |command, description|
+ desc description
+ task command do
+ prevent_additional_arguments_from_running_as_tasks
+ require 'rails/cli'
+ end
+ end
+
+ ALIASES.each do |alias_command, command|
+ task alias_command => command
+ end
+ end
+
+ private
+
+ def prevent_additional_arguments_from_running_as_tasks
+ Rake.application.top_level_tasks.clear
+ end
+ end
+ end
+end
View
2  rake-rails.gemspec
@@ -14,4 +14,6 @@ Gem::Specification.new do |gem|
gem.name = "rake-rails"
gem.require_paths = ["lib"]
gem.version = Rake::Rails::VERSION
+
+ gem.add_dependency "rake"
end
Please sign in to comment.
Something went wrong with that request. Please try again.