Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
78 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,57 @@ | ||
require 'rake' | ||
require 'rake/testtask' | ||
require 'date' | ||
require 'lib/clearance/version' | ||
|
||
|
||
test_files_pattern = 'test/rails_root/test/{unit,functional,other}/**/*_test.rb' | ||
Rake::TestTask.new do |t| | ||
t.libs << 'lib' | ||
t.pattern = test_files_pattern | ||
t.verbose = false | ||
end | ||
|
||
desc "Run the test suite" | ||
task :default => :test | ||
|
||
spec = Gem::Specification.new do |s| | ||
s.name = "clearance" | ||
|
||
s.summary = "Simple, complete Rails authentication." | ||
s.email = "dcroak@thoughtbot.com" | ||
s.homepage = "http://github.com/thoughtbot/clearance" | ||
s.description = "Simple, complete Rails authentication scheme." | ||
s.authors = ["thoughtbot, inc.", "Dan Croak", "Josh Nichols", "Mike Breen", "Mike Burns", "Jason Morrison"] | ||
s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"] | ||
end | ||
|
||
desc "Generate a gemspec file for GitHub" | ||
task :gemspec => 'version:calculate' do | ||
date = DateTime.now | ||
spec.date = "#{date.year}-#{date.month}-#{date.day}" | ||
|
||
File.open("#{spec.name}.gemspec", 'w') do |f| | ||
f.write spec.to_ruby | ||
end | ||
end | ||
|
||
desc "Displays the current version" | ||
task :version => 'version:calculate' do | ||
puts spec.version | ||
end | ||
|
||
namespace :version do | ||
desc "Determine's the version based on Clearance::Version" | ||
task :calculate do | ||
spec.version ||= "#{Clearance::Version::MAJOR}.#{Clearance::Version::MINOR}.#{Clearance::Version::PATCH}" | ||
end | ||
|
||
namespace :bump do | ||
def bump_gemspec(spec, major, minor, patch) | ||
File.open("lib/clearance/version.rb", 'w') do |file| | ||
file.write <<-END | ||
module Clearance | ||
module Version | ||
MAJOR = #{major} | ||
MINOR = #{minor} | ||
PATCH = #{patch} | ||
end | ||
|
||
begin | ||
require 'jeweler' | ||
Jeweler.gemspec = spec | ||
rescue LoadError | ||
puts "Jeweler not available. Try installing technicalpickles-jeweler." | ||
end | ||
END | ||
end | ||
|
||
spec.version = "#{major}.#{minor}.#{patch}" | ||
Rake::Task["gemspec"].invoke | ||
puts "Gem bumped to #{spec.version}" | ||
end | ||
|
||
desc "Bump the gemspec a major version." | ||
task :major do | ||
major = Clearance::Version::MAJOR + 1 | ||
bump_gemspec(spec, major, 0, 0) | ||
end | ||
|
||
desc "Bump the gemspec a minor version." | ||
task :minor do | ||
minor = Clearance::Version::MINOR + 1 | ||
bump_gemspec(spec, Clearance::Version::MAJOR, minor, 0) | ||
|
||
namespace :generator do | ||
task :templates do | ||
app_files = FileList["test/rails_root/app/{controllers,models,views}/**/*"] | ||
app_files.reject! { |file| file.include?("test/rails_root/app/views/layouts") } | ||
test_files = FileList["test/rails_root/test/{functional,unit}/**/*"] | ||
test_files += ["test/rails_root/test/factories.rb"] | ||
files = test_files + app_files | ||
templates_path = "generators/clearance/templates" | ||
system `rm -rf #{templates_path}` | ||
system `mkdir #{templates_path}` | ||
["app", "app/controllers", "app/models", "app/views", | ||
"test", "test/functional", "test/unit"].each do |directory| | ||
system `mkdir #{templates_path}/#{directory}` | ||
end | ||
|
||
desc "Bump the gemspec a patch version." | ||
task :patch do | ||
patch = Clearance::Version::PATCH + 1 | ||
bump_gemspec(spec, Clearance::Version::MAJOR, Clearance::Version::MINOR, patch) | ||
files.each do |file| | ||
template = "generators/clearance/templates/#{file.gsub("test/rails_root/", "")}" | ||
if File.directory?(file) | ||
system `rm -rf #{template}` | ||
system `mkdir #{template}` | ||
else | ||
system `rm #{template}` if File.exists?(template) | ||
system `cp #{file} #{template}` | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
generators/clearance/templates/app/controllers/application.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ApplicationController < ActionController::Base | ||
helper :all | ||
protect_from_forgery | ||
include Clearance::ApplicationController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
user.email { Factory.next :email } | ||
user.password "password" | ||
user.password_confirmation "password" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class UserTest < Test::Unit::TestCase | ||
include Clearance::UserTest | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ def url_after_create | |
end | ||
|
||
def url_after_destroy | ||
login_url | ||
new_session_url | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ module Clearance | |
module Version | ||
MAJOR = 0 | ||
MINOR = 2 | ||
PATCH = 3 | ||
PATCH = 6 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,13 @@ | ||
ActionController::Routing::Routes.draw do |map| | ||
|
||
map.resources :users | ||
map.resource :session | ||
|
||
map.resources :users, :has_one => :password | ||
map.resources :users, :has_one => :confirmation | ||
|
||
map.resources :passwords | ||
|
||
map.root :controller => 'sessions', :action => 'new' | ||
|
||
map.with_options :controller => 'sessions' do |m| | ||
m.login '/login', :action => 'new' | ||
m.logout '/logout', :action => 'destroy' | ||
end | ||
|
||
end | ||
|
||
ActionController::Routing::Routes.draw do |map| | ||
|
||
map.resources :users | ||
map.resource :session | ||
|
||
map.resources :users, :has_one => :password | ||
map.resources :users, :has_one => :confirmation | ||
|
||
map.resources :passwords | ||
|
||
map.root :controller => 'sessions', :action => 'new' | ||
|
||
end |