brute_squad 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ coverage
2
+ doc
@@ -0,0 +1,26 @@
1
+ == Brute Squad
2
+
3
+ MIRACLE MAX:: "Get away, I'm telling you, or I call the Brute Squad."
4
+ FEZZIK:: "I'm on the Brute Squad."
5
+ MIRACLE MAX:: "You _are_ the brute squad."
6
+
7
+ I'm kind of sick of Rails authentication stacks that try to be all things to all people,
8
+ except in one little area where their authors are stubborn and opinionated.
9
+
10
+ So I thought I'd build another one.
11
+
12
+ === Goals
13
+
14
+ * Works out of the box
15
+ * ...with Rails 2 *and* 3
16
+ * ...and any ORM (within reason)
17
+ * ...as modularly and unobtrusively as possible
18
+
19
+ === Ungoals
20
+
21
+ * Flexibility for flexibility's sake
22
+ * Endless configuration options
23
+ * Stuff that isn't specifically authentication (e.g. user management)
24
+
25
+ Copyright (c) 2010 Matt Powell, released under the MIT license.
26
+ Don't be a dick.
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'spec/rake/spectask'
4
+
5
+ desc 'Default: run specs.'
6
+ task :default => :spec
7
+
8
+ desc 'Run the specs'
9
+ Spec::Rake::SpecTask.new(:spec) do |t|
10
+ t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
11
+ t.spec_files = FileList['spec/**/*_spec.rb']
12
+ t.rcov = true
13
+ t.rcov_opts = ['--text-report --rails --exclude "spec/*"']
14
+ end
15
+
16
+ begin
17
+ require 'jeweler'
18
+ Jeweler::Tasks.new do |gemspec|
19
+ gemspec.name = "brute_squad"
20
+ gemspec.summary = "No-bullshit authentication for Rails"
21
+ gemspec.description = "Sick of authentication frameworks with all the sauces? Me too."
22
+ gemspec.email = "fauxparse@gmail.com"
23
+ gemspec.homepage = "http://github.com/fauxparse/brute_squad"
24
+ gemspec.authors = ["Matt Powell"]
25
+ end
26
+ Jeweler::GemcutterTasks.new
27
+ rescue LoadError
28
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
29
+ end
30
+
31
+ begin
32
+ require 'hanna/rdoctask'
33
+ rescue
34
+ require 'rake/rdoctask'
35
+ end
36
+
37
+ desc 'Generate RDoc documentation.'
38
+ Rake::RDocTask.new(:rdoc) do |rdoc|
39
+ rdoc.rdoc_files.include('README.rdoc').
40
+ include('lib/**/*.rb')
41
+
42
+ rdoc.main = "README.rdoc" # page to start on
43
+ rdoc.title = "Brute Squad"
44
+
45
+ rdoc.rdoc_dir = 'doc' # rdoc output folder
46
+ rdoc.options << '--webcvs=http://github.com/fauxparse/credentials/'
47
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generates Brute Squad configuration files.
3
+
4
+ Example:
5
+ ./script/generate brute_squad User
6
+
7
+ creates:
8
+ config/initializers/brute_squad
@@ -0,0 +1,17 @@
1
+ class BruteSquadGenerator < Rails::Generator::NamedBase
2
+ attr_reader :model_name
3
+
4
+ def initialize(runtime_args, runtime_options = {})
5
+ runtime_args << "user" if runtime_args.empty?
6
+
7
+ super
8
+
9
+ @model_name = File.basename(plural_name)
10
+ end
11
+
12
+ def manifest
13
+ record do |m|
14
+ m.template "brute_squad.rb", "config/initializers/brute_squad.rb"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ BruteSquad.configure :<%= model_name %> do
2
+ <%= '# ' if model_name.singularize == singular_name %>singular "<%= singular_name %>"
3
+ <%= '# ' if model_name.singularize.classify == class_name %>class_name "<%= class_name %>"
4
+ end
@@ -0,0 +1,16 @@
1
+ module BruteSquad
2
+ def self.models
3
+ @models ||= {}
4
+ end
5
+
6
+ def self.configure(model, options = {}, &block)
7
+ returning configuration_for(model, options) do |config|
8
+ config.instance_eval &block if block_given?
9
+ end
10
+ end
11
+
12
+ protected
13
+ def self.configuration_for(model, options = {})
14
+ models[model.to_sym] ||= Model.new(model, options)
15
+ end
16
+ end
@@ -0,0 +1,32 @@
1
+ module BruteSquad
2
+ class Model
3
+ attr_reader :name
4
+ attr_accessor :singular, :class_name
5
+
6
+ # Configure a new model for use with BruteSquad
7
+ #
8
+ # Accepts the following options:
9
+ # :singular:: Singular name for the model
10
+ # :class_name:: Class name of the model to use
11
+ def initialize(model_name, options = {})
12
+ @name = model_name
13
+ @singular = options[:singular] if options[:singular].present?
14
+ @class_name = options[:class_name] if options[:class_name].present?
15
+ end
16
+
17
+ def singular(value = nil)
18
+ @singular = value unless value.nil?
19
+ @singular || name.to_s.singularize.to_sym
20
+ end
21
+
22
+ def class_name(value = nil)
23
+ @class_name = value unless value.nil?
24
+ @class_name || singular.to_s.classify
25
+ end
26
+
27
+ protected
28
+ def klass #:nodoc:
29
+ @class_name.constantize
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :brute_squad do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1 @@
1
+ # Include hook code here
@@ -0,0 +1,61 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe BruteSquad::Model do
4
+ before :each do
5
+ BruteSquad.models.clear
6
+ end
7
+
8
+ describe "created with defaults" do
9
+ before :each do
10
+ @model = BruteSquad.configure(:users)
11
+ end
12
+
13
+ it "should have sensible values" do
14
+ @model.name.should == :users
15
+ @model.singular.should == :user
16
+ @model.class_name.should == "User"
17
+ end
18
+
19
+ it "should be listed in BruteSquad.models" do
20
+ BruteSquad.models.should == { :users => @model }
21
+ end
22
+ end
23
+
24
+ describe "created with options" do
25
+ it "should accept the :singular option" do
26
+ @model = BruteSquad.configure(:users, :singular => :person)
27
+ @model.name.should == :users
28
+ @model.singular.should == :person
29
+ @model.class_name.should == "Person"
30
+ end
31
+
32
+ it "should accept the :class_name option" do
33
+ @model = BruteSquad.configure(:users, :class_name => "Person")
34
+ @model.name.should == :users
35
+ @model.singular.should == :user
36
+ @model.class_name.should == "Person"
37
+ end
38
+ end
39
+
40
+ describe "created with a configuration block" do
41
+ it "should accept the :singular option" do
42
+ BruteSquad.configure :users do
43
+ singular :person
44
+ end
45
+ @model = BruteSquad.models[:users]
46
+ @model.name.should == :users
47
+ @model.singular.should == :person
48
+ @model.class_name.should == "Person"
49
+ end
50
+
51
+ it "should accept the :class_name option" do
52
+ BruteSquad.configure :users do
53
+ class_name "Person"
54
+ end
55
+ @model = BruteSquad.models[:users]
56
+ @model.name.should == :users
57
+ @model.singular.should == :user
58
+ @model.class_name.should == "Person"
59
+ end
60
+ end
61
+ end
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
@@ -0,0 +1 @@
1
+ # Logfile created on Thu Apr 08 11:12:57 +1200 2010 by logger.rb/22285
@@ -0,0 +1,10 @@
1
+ begin
2
+ require File.dirname(__FILE__) + '/../../../../spec/spec_helper'
3
+ rescue LoadError
4
+ puts "You need to install rspec in your base app"
5
+ exit
6
+ end
7
+
8
+ plugin_spec_dir = File.dirname(__FILE__)
9
+ ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + "/debug.log")
10
+
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: brute_squad
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 0
9
+ version: 0.0.0
10
+ platform: ruby
11
+ authors:
12
+ - Matt Powell
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-08 00:00:00 +12:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Sick of authentication frameworks with all the sauces? Me too.
22
+ email: fauxparse@gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README.rdoc
29
+ files:
30
+ - .gitignore
31
+ - README.rdoc
32
+ - Rakefile
33
+ - VERSION
34
+ - generators/brute_squad/USAGE
35
+ - generators/brute_squad/brute_squad_generator.rb
36
+ - generators/brute_squad/templates/brute_squad.rb
37
+ - lib/brute_squad.rb
38
+ - lib/brute_squad/model.rb
39
+ - lib/tasks/brute_squad_tasks.rake
40
+ - rails/init.rb
41
+ - spec/brute_squad/model_spec.rb
42
+ - spec/brute_squad_spec.rb
43
+ - spec/debug.log
44
+ - spec/spec_helper.rb
45
+ - uninstall.rb
46
+ has_rdoc: true
47
+ homepage: http://github.com/fauxparse/brute_squad
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options:
52
+ - --charset=UTF-8
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ requirements: []
70
+
71
+ rubyforge_project:
72
+ rubygems_version: 1.3.6
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: No-bullshit authentication for Rails
76
+ test_files:
77
+ - spec/brute_squad/model_spec.rb
78
+ - spec/brute_squad_spec.rb
79
+ - spec/spec_helper.rb