Permalink
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...
1 parent 8487769 commit ddaa6bb1ef9f3b9649a37aa3af48b6eedf007c17 @hassox hassox committed Jan 7, 2008
View
@@ -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
@@ -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|
@@ -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
@@ -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,
@@ -1,5 +0,0 @@
-Description:
-
-
-Usage:
-
@@ -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

0 comments on commit ddaa6bb

Please sign in to comment.