Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changes the generators name to authenticated from authentication to c…

…onform to restful_authentication.

Adds generators to provide errors when no ORM is selected and when Sequel is selected since it's not supported.
  • Loading branch information...
commit ddaa6bb1ef9f3b9649a37aa3af48b6eedf007c17 1 parent 8487769
@hassox hassox authored
Showing with 134 additions and 22 deletions.
  1. +7 −0 CHANGELOG
  2. +4 −3 Rakefile
  3. +55 −0 merb_default_generators/merbful_authentication_model/merbful_authentication_model_generator.rb
  4. 0  {test_unit_generators/merbful_authentication_tests → merb_generators/authenticated}/USAGE
  5. +15 −14 merb_generators/{authentication/authentication_generator.rb → authenticated/authenticated_generator.rb}
  6. 0  merb_generators/{authentication → authenticated}/templates/activation.html.erb
  7. 0  merb_generators/{authentication → authenticated}/templates/activation.text.erb
  8. 0  merb_generators/{authentication → authenticated}/templates/authenticated_system_controller.rb
  9. 0  merb_generators/{authentication → authenticated}/templates/authenticated_system_model.rb
  10. 0  merb_generators/{authentication → authenticated}/templates/login.html.erb
  11. 0  merb_generators/{authentication → authenticated}/templates/mail_controller.rb
  12. 0  merb_generators/{authentication → authenticated}/templates/model_controller.rb
  13. 0  merb_generators/{authentication → authenticated}/templates/new_model.html.erb
  14. 0  merb_generators/{authentication → authenticated}/templates/session_controller.rb
  15. 0  merb_generators/{authentication → authenticated}/templates/signup.html.erb
  16. 0  merb_generators/{authentication → authenticated}/templates/signup.text.erb
  17. +0 −5 merb_generators/authentication/USAGE
  18. +53 −0 sequel_generators/merbful_authentication_model/merbful_authentication_model_generator.rb
View
7 CHANGELOG
@@ -0,0 +1,7 @@
+7th January 2008---------------------------------------------------
+Added generator blanks for merb_default and sequel scopes to gracefully error and stop the generators
+
+Changes the generator name from "authentication" to "authenticated" to match restful_authentication
+
+Made dependency on merb 0.5.0 or greater
+
View
7 Rakefile
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
PLUGIN = "merbful_authentication"
NAME = "merbful_authentication"
-VERSION = "0.1.0"
+VERSION = "0.1.1"
AUTHOR = "Daniel Neighman"
EMAIL = "has.sox@gmail.com"
HOMEPAGE = "http://rubyforge.org/projects/merbful-auth/"
@@ -20,10 +20,11 @@ spec = Gem::Specification.new do |s|
s.author = AUTHOR
s.email = EMAIL
s.homepage = HOMEPAGE
- s.add_dependency('merb', '>= 0.4.0')
+ s.add_dependency('merb', '>= 0.5.0')
s.require_path = 'lib'
s.autorequire = PLUGIN
- s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs,merb_generators,datamapper_generators,activerecord_generators,rspec_generators,test_unit_generators}/**/*")
+ s.files = %w(LICENSE README Rakefile TODO) +
+ Dir.glob("{lib,specs,merb_generators,datamapper_generators,activerecord_generators,merb_default_generators,sequel_generators,rspec_generators,test_unit_generators}/**/*")
end
Rake::GemPackageTask.new(spec) do |pkg|
View
55 merb_default_generators/merbful_authentication_model/merbful_authentication_model_generator.rb
@@ -0,0 +1,55 @@
+class MerbfulAuthenticationModelGenerator < RubiGen::Base
+
+ default_options :author => nil
+
+ attr_reader :name
+
+ def initialize(runtime_args, runtime_options = {})
+ super
+ usage if args.empty?
+ @name = args.shift
+ extract_options
+ end
+
+ def manifest
+ record do |m|
+ # Exit out because there should be an orm present
+ puts "\n"
+ puts "-" * 70
+ puts "\nThere is no ORM selected. merbful_authentication requires there to be an ORM present."
+ puts "\nSelect and ORM in config/dependencies.rb"
+ puts "\ne.g."
+ puts "use_orm :datamapper"
+ puts "\n"
+ puts "-" * 70
+ exit
+ end
+ end
+
+ protected
+ def banner
+ <<-EOS
+Creates a ...
+
+USAGE: #{$0} #{spec.name} name"
+EOS
+ end
+
+ def add_options!(opts)
+ # opts.separator ''
+ # opts.separator 'Options:'
+ # For each option below, place the default
+ # at the top of the file next to "default_options"
+ # opts.on("-a", "--author=\"Your Name\"", String,
+ # "Some comment about this option",
+ # "Default: none") { |options[:author]| }
+ # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
+ end
+
+ def extract_options
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
+ # Templates can access these value via the attr_reader-generated methods, but not the
+ # raw instance variable value.
+ # @author = options[:author]
+ end
+end
View
0  ...nit_generators/merbful_authentication_tests/USAGE → merb_generators/authenticated/USAGE
File renamed without changes
View
29 ...rators/authentication/authentication_generator.rb → ...nerators/authenticated/authenticated_generator.rb
@@ -1,5 +1,5 @@
require 'merb'
-class AuthenticationGenerator < RubiGen::Base
+class AuthenticatedGenerator < RubiGen::Base
default_options :author => nil
@@ -75,6 +75,20 @@ def manifest
m.class_collisions class_path, "#{class_name}", "#{class_name}Mailer"# , "#{class_name}MailerTest", "#{class_name}Observer"
m.class_collisions [], 'AuthenticatedSystem::Controller', 'AuthenticatedSystem::Model'
+ # Generate the model first. These can then throw an error when generating if there is no ORM present
+ model_attributes = {
+ :class_name => class_name,
+ :class_path => class_path,
+ :file_name => file_name,
+ :class_nesting => class_nesting,
+ :class_nesting_depth => class_nesting_depth,
+ :plural_name => plural_name,
+ :singular_name => singular_name,
+ :include_activation => options[:include_activation]
+ }
+ m.dependency "merbful_authentication_model", [name], model_attributes
+
+
# Controller, helper, views, and test directories.
m.directory File.join('app/controllers', controller_class_path)
@@ -106,19 +120,6 @@ def manifest
end
end
- # Generate the model
- model_attributes = {
- :class_name => class_name,
- :class_path => class_path,
- :file_name => file_name,
- :class_nesting => class_nesting,
- :class_nesting_depth => class_nesting_depth,
- :plural_name => plural_name,
- :singular_name => singular_name,
- :include_activation => options[:include_activation]
- }
- m.dependency "merbful_authentication_model", [name], model_attributes
-
# Generate the sessions controller
m.template "session_controller.rb", File.join('app/controllers',
controller_class_path,
View
0  ...tors/authentication/templates/activation.html.erb → ...ators/authenticated/templates/activation.html.erb
File renamed without changes
View
0  ...tors/authentication/templates/activation.text.erb → ...ators/authenticated/templates/activation.text.erb
File renamed without changes
View
0  ...tion/templates/authenticated_system_controller.rb → ...ated/templates/authenticated_system_controller.rb
File renamed without changes
View
0  ...ntication/templates/authenticated_system_model.rb → ...enticated/templates/authenticated_system_model.rb
File renamed without changes
View
0  ...enerators/authentication/templates/login.html.erb → ...generators/authenticated/templates/login.html.erb
File renamed without changes
View
0  ...ators/authentication/templates/mail_controller.rb → ...rators/authenticated/templates/mail_controller.rb
File renamed without changes
View
0  ...tors/authentication/templates/model_controller.rb → ...ators/authenticated/templates/model_controller.rb
File renamed without changes
View
0  ...ators/authentication/templates/new_model.html.erb → ...rators/authenticated/templates/new_model.html.erb
File renamed without changes
View
0  ...rs/authentication/templates/session_controller.rb → ...ors/authenticated/templates/session_controller.rb
File renamed without changes
View
0  ...nerators/authentication/templates/signup.html.erb → ...enerators/authenticated/templates/signup.html.erb
File renamed without changes
View
0  ...nerators/authentication/templates/signup.text.erb → ...enerators/authenticated/templates/signup.text.erb
File renamed without changes
View
5 merb_generators/authentication/USAGE
@@ -1,5 +0,0 @@
-Description:
-
-
-Usage:
-
View
53 sequel_generators/merbful_authentication_model/merbful_authentication_model_generator.rb
@@ -0,0 +1,53 @@
+class MerbfulAuthenticationModelGenerator < RubiGen::Base
+
+ default_options :author => nil
+
+ attr_reader :name
+
+ def initialize(runtime_args, runtime_options = {})
+ super
+ usage if args.empty?
+ @name = args.shift
+ extract_options
+ end
+
+ def manifest
+ record do |m|
+ # Exit out because sequel is not yet supported.
+ # For anyone who want to implement sequel, the model, and ORM map lib are the only files that should
+ # need to be updated. Some of the specs may need to change sytnax to pass though.
+ puts "\n"
+ puts "-" * 70
+ puts "\nThe sequel ORM is not yet supported in merbful_authentication. Please select another ORM.\n"
+ puts "-" * 70
+ exit
+ end
+ end
+
+ protected
+ def banner
+ <<-EOS
+Creates a ...
+
+USAGE: #{$0} #{spec.name} name"
+EOS
+ end
+
+ def add_options!(opts)
+ # opts.separator ''
+ # opts.separator 'Options:'
+ # For each option below, place the default
+ # at the top of the file next to "default_options"
+ # opts.on("-a", "--author=\"Your Name\"", String,
+ # "Some comment about this option",
+ # "Default: none") { |options[:author]| }
+ # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
+ end
+
+ def extract_options
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
+ # Templates can access these value via the attr_reader-generated methods, but not the
+ # raw instance variable value.
+ # @author = options[:author]
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.