red_light 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/red_light/railtie.rb
CHANGED
@@ -5,5 +5,35 @@ module RedLight
|
|
5
5
|
initializer "red_light.configure_rails_initialization" do |app|
|
6
6
|
app.middleware.use RedLight::FancyLogin
|
7
7
|
end
|
8
|
+
|
9
|
+
ActiveSupport.on_load(:action_controller) do
|
10
|
+
::RED_LIGHT_RULES = Hash.new([])
|
11
|
+
|
12
|
+
controllers = Dir.glob("app/controllers/**/*_controller.rb").map do |entry|
|
13
|
+
File.basename(entry, ".rb").classify.constantize
|
14
|
+
end
|
15
|
+
|
16
|
+
controllers.each do |c|
|
17
|
+
filter = c._process_action_callbacks.select{ |callback|
|
18
|
+
callback.filter == :authenticate_user!
|
19
|
+
}.first
|
20
|
+
|
21
|
+
next if filter.nil?
|
22
|
+
|
23
|
+
controller_name = c.to_s.underscore.split("_controller").first
|
24
|
+
::RED_LIGHT_RULES[controller_name] = Array(c.action_methods)
|
25
|
+
|
26
|
+
options = filter.options
|
27
|
+
if options[:only].present? && Array(options[:only]).any?
|
28
|
+
::RED_LIGHT_RULES[controller_name] = Array(options[:only]).map(&:to_s)
|
29
|
+
end
|
30
|
+
|
31
|
+
if options[:except].present? && Array(options[:except]).any?
|
32
|
+
::RED_LIGHT_RULES[controller_name] -= Array(options[:except]).map(&:to_s)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
::RED_LIGHT_RULES.freeze
|
37
|
+
end
|
8
38
|
end
|
9
39
|
end
|
data/lib/red_light/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: red_light
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2013-05-19 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &70303589965440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.3'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70303589965440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70303589962020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70303589962020
|
36
36
|
description: a gem used to add fancy login to your rails application
|
37
37
|
email:
|
38
38
|
- leomayleomay@gmail.com
|
@@ -46,9 +46,6 @@ files:
|
|
46
46
|
- LICENSE.txt
|
47
47
|
- README.md
|
48
48
|
- Rakefile
|
49
|
-
- lib/generators/red_light/install_generator.rb
|
50
|
-
- lib/generators/templates/README
|
51
|
-
- lib/generators/templates/red_light_rules.rb
|
52
49
|
- lib/red_light.rb
|
53
50
|
- lib/red_light/fancy_login.rb
|
54
51
|
- lib/red_light/railtie.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module RedLight
|
2
|
-
module Generators
|
3
|
-
class InstallGenerator < Rails::Generators::Base
|
4
|
-
source_root File.expand_path("../../templates", __FILE__)
|
5
|
-
|
6
|
-
desc "Copy red light rules to your application."
|
7
|
-
|
8
|
-
def copy_rules
|
9
|
-
template "red_light_rules.rb", "config/initializers/red_light_rules.rb"
|
10
|
-
end
|
11
|
-
|
12
|
-
def show_readme
|
13
|
-
readme "README" if behavior == :invoke
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
RED_LIGHT_RULES = Hash.new([])
|
3
|
-
|
4
|
-
controllers = Dir.glob("app/controllers/**/*_controller.rb").map do |entry|
|
5
|
-
File.basename(entry, ".rb").classify.constantize
|
6
|
-
end
|
7
|
-
|
8
|
-
controllers.each do |c|
|
9
|
-
filter = c._process_action_callbacks.select{ |callback|
|
10
|
-
callback.filter == :authenticate_user!
|
11
|
-
}.first
|
12
|
-
|
13
|
-
next if filter.nil?
|
14
|
-
|
15
|
-
controller_name = c.to_s.underscore.split("_controller").first
|
16
|
-
RED_LIGHT_RULES[controller_name] = Array(c.action_methods)
|
17
|
-
|
18
|
-
options = filter.options
|
19
|
-
if options[:only].present? && Array(options[:only]).any?
|
20
|
-
RED_LIGHT_RULES[controller_name] = Array(options[:only]).map(&:to_s)
|
21
|
-
end
|
22
|
-
|
23
|
-
if options[:except].present? && Array(options[:except]).any?
|
24
|
-
RED_LIGHT_RULES[controller_name] -= Array(options[:except]).map(&:to_s)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
RED_LIGHT_RULES.freeze
|