red_light 0.0.7 → 0.0.8
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/README.md +5 -3
- data/TODO +5 -0
- data/lib/red_light/fancy_login.rb +4 -3
- data/lib/red_light/railtie.rb +5 -7
- data/lib/red_light/version.rb +1 -1
- metadata +7 -6
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# RedLight
|
2
2
|
|
3
|
-
|
3
|
+
red_light is a gem used to help you incorporate fancy login in your Rails application effortlessly.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -15,10 +15,12 @@ And then execute:
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
17
|
$ gem install red_light
|
18
|
+
|
19
|
+
## Demo
|
20
|
+
[fancy-login](http://fancy-login.herokuapp.com)
|
18
21
|
|
19
22
|
## Usage
|
20
|
-
|
21
|
-
TODO: Write usage instructions here
|
23
|
+
[this](https://github.com/leomayleomay/red_light_example) is an example app built for illustrating how to incorporate red_light within your Rails application.
|
22
24
|
|
23
25
|
## Contributing
|
24
26
|
|
data/TODO
ADDED
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
module RedLight
|
4
4
|
class FancyLogin
|
5
|
-
def initialize(app)
|
5
|
+
def initialize(app, rules)
|
6
6
|
@app = app
|
7
|
+
@rules = rules
|
7
8
|
end
|
8
9
|
|
9
10
|
def call(env)
|
@@ -30,7 +31,7 @@ module RedLight
|
|
30
31
|
controller = path[:controller]
|
31
32
|
action = path[:action]
|
32
33
|
|
33
|
-
if
|
34
|
+
if @rules[controller] && @rules[controller].include?(action)
|
34
35
|
part.gsub!(/action="#{form_action}"/, "action='javascript:void(0);' rel='fancy_login'")
|
35
36
|
end
|
36
37
|
rescue ActionController::RoutingError => e
|
@@ -45,7 +46,7 @@ module RedLight
|
|
45
46
|
controller = path[:controller]
|
46
47
|
action = path[:action]
|
47
48
|
|
48
|
-
if
|
49
|
+
if @rules[controller] && @rules[controller].include?(action)
|
49
50
|
href_regex = Regexp.compile(Regexp.escape('href="/'+href+'"'))
|
50
51
|
part.gsub!(href_regex, "href='/#{href}' rel='fancy_login'")
|
51
52
|
end
|
data/lib/red_light/railtie.rb
CHANGED
@@ -3,7 +3,7 @@ require 'red_light/fancy_login'
|
|
3
3
|
module RedLight
|
4
4
|
class Railtie < Rails::Railtie
|
5
5
|
initializer "red_light.configure_rails_initialization" do |app|
|
6
|
-
|
6
|
+
rules = Hash.new([])
|
7
7
|
|
8
8
|
Dir.glob("app/controllers/**/*_controller.rb").map do |entry|
|
9
9
|
controller = File.basename(entry, ".rb").classify.constantize
|
@@ -15,21 +15,19 @@ module RedLight
|
|
15
15
|
next if filter.nil?
|
16
16
|
|
17
17
|
controller_name = controller.to_s.underscore.split("_controller").first
|
18
|
-
|
18
|
+
rules[controller_name] = Array(controller.action_methods)
|
19
19
|
|
20
20
|
options = filter.options
|
21
21
|
if options[:only].present? && Array(options[:only]).any?
|
22
|
-
|
22
|
+
rules[controller_name] = Array(options[:only]).map(&:to_s)
|
23
23
|
end
|
24
24
|
|
25
25
|
if options[:except].present? && Array(options[:except]).any?
|
26
|
-
|
26
|
+
rules[controller_name] -= Array(options[:except]).map(&:to_s)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
::
|
31
|
-
|
32
|
-
app.middleware.use RedLight::FancyLogin
|
30
|
+
app.middleware.use RedLight::FancyLogin, rules
|
33
31
|
end
|
34
32
|
end
|
35
33
|
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.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &70290583428500 !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: *70290583428500
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70290583425000 !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: *70290583425000
|
36
36
|
description: a gem used to add fancy login to your rails application
|
37
37
|
email:
|
38
38
|
- leomayleomay@gmail.com
|
@@ -46,6 +46,7 @@ files:
|
|
46
46
|
- LICENSE.txt
|
47
47
|
- README.md
|
48
48
|
- Rakefile
|
49
|
+
- TODO
|
49
50
|
- lib/red_light.rb
|
50
51
|
- lib/red_light/fancy_login.rb
|
51
52
|
- lib/red_light/railtie.rb
|