Skip to content

Commit

Permalink
Rake 0.9 Compat
Browse files Browse the repository at this point in the history
  • Loading branch information
DAddYE committed May 21, 2011
1 parent fd66302 commit 117803f
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 46 deletions.
1 change: 1 addition & 0 deletions CHANGES.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* Added a new method to load custom app dependencies
* Added a new format helper 'truncate_words' [Thanks cearls!]
* Fixes support for local vars passing in render
* Rake 0.9 compat

== 0.9.28

Expand Down
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ base_path = File.expand_path(File.dirname(__FILE__), __FILE__)

source :rubygems

# gem "sinatra", :git => "git://github.com/sinatra/sinatra.git"

group :db do
gem "dm-core", ">= 1.0"
gem "dm-migrations", ">= 1.0"
Expand All @@ -15,6 +13,10 @@ group :db do
end

group :development do
if ENV['SINATRA_EDGE']
puts "=> Using sinatra edge"
gem "sinatra", :git => "git://github.com/sinatra/sinatra.git"
end
gem "rake", ">= 0.8.7"
gem "mocha", ">= 0.9.8"
gem "rack-test", ">= 0.5.0"
Expand Down
11 changes: 2 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
# rake bump[X.X.X] && rake publish

require 'rake/clean'
require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'rake/contrib/sshpublisher'
require 'fileutils'
require 'rdoc/task'

require File.expand_path("../padrino-core/lib/padrino-core/version.rb", __FILE__)
begin
require 'sdoc'
rescue LoadError
puts "You need to install sdoc: gem install sdoc to correctly generate our api docs."
end

begin
require 'memcached'
rescue LoadError
puts "The memcached gem only works on certain VM versions. It's safe to ignore this"
end

include FileUtils

ROOT = File.expand_path(File.dirname(__FILE__))
Expand Down
19 changes: 7 additions & 12 deletions gem_rake_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'rubygems/specification' unless defined?(Gem::Specification)
require 'rake' unless defined?(Rake)
require 'rubygems/specification'
require 'rake'
require 'rubygems/package_task'

# Runs the sh command with sudo if the rake command is run with sudo
def sudo_sh(command)
Expand Down Expand Up @@ -58,16 +59,10 @@ def gemspec
end

# rake package
begin
require 'rake/gempackagetask'
rescue LoadError
task(:gem) { $stderr.puts '`gem install rake` to package gems' }
else
Rake::GemPackageTask.new(gemspec) do |pkg|
pkg.gem_spec = gemspec
end
task :gem => :gemspec
Gem::PackageTask.new(gemspec) do |pkg|
pkg.gem_spec = gemspec
end

task :gem => :gemspec
task :package => :gemspec

task :default => :test
3 changes: 1 addition & 2 deletions load_paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
else
require 'rubygems'
end
require 'bundler'
Bundler.setup
require 'bundler/setup'
7 changes: 3 additions & 4 deletions padrino-core/lib/padrino-core/cli/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Cli

class Base < Thor
include Thor::Actions
include Thor::RakeCompat

class_option :chdir, :type => :string, :aliases => "-c", :desc => "Change to dir before starting"
class_option :environment, :type => :string, :aliases => "-e", :required => true, :default => :development, :desc => "Padrino Environment"
Expand Down Expand Up @@ -49,8 +48,8 @@ def rake(*args)
puts "=> Executing Rake #{ARGV.join(' ')} ..."
ENV['PADRINO_LOG_LEVEL'] ||= "test"
require File.expand_path(File.dirname(__FILE__) + '/rake')
silence(:stdout) { require File.expand_path('config/boot.rb') }
PadrinoTasks.init
require File.expand_path('config/boot.rb') # }
PadrinoTasks.init(true)
end

desc "console", "Boots up the Padrino application irb console"
Expand Down Expand Up @@ -139,4 +138,4 @@ def capture(stream)
alias :silence :capture
end # Base
end # Cli
end # Padrino
end # Padrino
27 changes: 16 additions & 11 deletions padrino-core/lib/padrino-core/cli/rake.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
require File.expand_path(File.dirname(__FILE__) + '/../tasks')
require 'rake'
require 'thor'
require 'securerandom' unless defined?(SecureRandom)
Rake.application.instance_variable_set(:@rakefile, __FILE__)

module PadrinoTasks
def self.init
Padrino::Tasks.files.flatten.uniq.each { |ext| load(ext) rescue puts "<= Failed load #{ext}" } unless @_init
Rake.application.init
Rake.application.top_level
@_init = true
def self.init(init=false)
Padrino::Tasks.files.flatten.uniq.each { |rakefile| Rake.application.add_import(rakefile) rescue puts "<= Failed load #{ext}" }
if init
Rake.application.init
Rake.application.instance_variable_set(:@rakefile, __FILE__)
Rake.load_rakefile(__FILE__)
Rake.application.load_imports
Rake.application.top_level
else
Rake.application.load_imports
end
end
end

Expand Down Expand Up @@ -51,15 +57,16 @@ def list_app_routes(app, args)
end

desc "Displays a listing of the named routes within a project, optionally only those matched by [query]"
task :routes, :query, :needs => :environment do |t, args|
task :routes, [:query] => :environment do |t, args|
Padrino.mounted_apps.each do |app|
list_app_routes(app, args)
end
end

desc "Displays a listing of the named routes a given app [app]"
namespace :routes do
task :app, :app, :needs => :environment do |t, args|
task :app, [:app] => :environment do |t, args|
puts args.inspect
app = Padrino.mounted_apps.find { |app| app.app_class == args.app }
list_app_routes(app, args) if app
end
Expand All @@ -69,10 +76,8 @@ def list_app_routes(app, args)
task :gen do
File.open(Padrino.root("Rakefile"), "w") do |file|
file.puts <<-RUBY.gsub(/^ {6}/, '')
require File.dirname(__FILE__) + '/config/boot.rb'
require 'thor'
require File.expand_path('../config/boot.rb', __FILE__)
require 'padrino-core/cli/rake'
PadrinoTasks.init
RUBY
end
Expand Down
2 changes: 1 addition & 1 deletion padrino-core/test/test_reloader_simple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class TestSimpleReloader < Test::Unit::TestCase
assert_match %r{fixtures/apps/simple.rb}, SimpleDemo.app_file
end

should_eventually 'correctly reload SimpleDemo fixture' do
should 'correctly reload SimpleDemo fixture' do
@app = SimpleDemo
get "/"
assert ok?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source :rubygems
# Project requirements
gem 'rake'
gem 'rack-flash'
gem 'thin' # or mongrel

# Component requirements

Expand Down
4 changes: 2 additions & 2 deletions padrino-gen/lib/padrino-gen/padrino-tasks/datamapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
end

desc "Migrate up using migrations"
task :up, :version, :needs => :load do |t, args|
task :up, [:version] => :load do |t, args|
version = args[:version] || ENV['VERSION']
migrate_up!(version)
puts "<= dm:migrate:up #{version} executed"
end

desc "Migrate down using migrations"
task :down, :version, :needs => :load do |t, args|
task :down, [:version] => :load do |t, args|
version = args[:version] || ENV['VERSION']
migrate_down!(version)
puts "<= dm:migrate:down #{version} executed"
Expand Down
2 changes: 1 addition & 1 deletion padrino-gen/lib/padrino-gen/padrino-tasks/sequel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
end

desc "Perform migration up/down to VERSION"
task :to, :version, :needs => :environment do |t, args|
task :to, [:version] => :environment do |t, args|
version = (args[:version] || ENV['VERSION']).to_s.strip
::Sequel.extension :migration
raise "No VERSION was provided" if version.empty?
Expand Down
1 change: 0 additions & 1 deletion padrino-gen/test/test_project_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ def teardown
silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none') }
assert_match_in_file(/gem 'padrino'/, "#{@apptmp}/sample_project/Gemfile")
assert_match_in_file(/gem 'rack-flash'/, "#{@apptmp}/sample_project/Gemfile")
assert_match_in_file(/gem 'thin'/, "#{@apptmp}/sample_project/Gemfile")
end
end

Expand Down

0 comments on commit 117803f

Please sign in to comment.