devise-links 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --format nested --color
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Kristian Mandrup
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,42 @@
1
+ # Devise links
2
+
3
+ View link helpers for Devise actions
4
+
5
+ ## Install
6
+
7
+ <code>gem install devise-links</code>
8
+
9
+ ## Usage
10
+
11
+ <pre>
12
+ <%= new_registration_link(:role => :admin) %>
13
+
14
+ <%= sign_out_link(:role => :admin, :label => 'Log me out!') %>
15
+ </pre>
16
+
17
+ ## TODO
18
+
19
+ Make API more generic...
20
+
21
+ <pre>
22
+ <%= new_registration_link(:admin) %>
23
+
24
+ <%= sign_out_link(:admin, 'Log out') %>
25
+
26
+ <%= new_registration_link('Register!') %>
27
+ </pre>
28
+
29
+
30
+ ## Note on Patches/Pull Requests
31
+
32
+ * Fork the project.
33
+ * Make your feature addition or bug fix.
34
+ * Add tests for it. This is important so I don't break it in a
35
+ future version unintentionally.
36
+ * Commit, do not mess with rakefile, version, or history.
37
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
38
+ * Send me a pull request. Bonus points for topic branches.
39
+
40
+ == Copyright
41
+
42
+ Copyright (c) 2010 Kristian Mandrup. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gem|
4
+ gem.name = "devise-links"
5
+ gem.summary = %Q{Link helpers for Devise actions}
6
+ gem.description = %Q{Link helpers for Devise actions, including user session and registration links.}
7
+ gem.email = "kmandrup@gmail.com"
8
+ gem.homepage = "http://github.com/kristianmandrup/devise-links"
9
+ gem.authors = ["Kristian Mandrup"]
10
+ gem.add_development_dependency "rspec", "~> 2.0.0"
11
+ gem.add_development_dependency "devise", "~> 1.1"
12
+ gem.add_dependency 'require_all', "~> 1.1"
13
+ gem.add_dependency 'sugar-high', "~> 0.1"
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
18
+ end
19
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,5 @@
1
+ require 'require_all'
2
+ require 'sugar-high/module'
3
+ require 'devise-links/namespaces'
4
+ require_all File.dirname(__FILE__) + '/devise-links/link'
5
+
@@ -0,0 +1,41 @@
1
+ module Devise::Link
2
+ module Registration
3
+ REGISTRATION_LINKS = {
4
+ :new_registration => :sign_up,
5
+ :edit_registration => :edit_profile
6
+ }
7
+
8
+ ACTIONS = [:new, :edit]
9
+
10
+ # new_registration_link, edit_registration_link
11
+ REGISTRATION_LINKS.keys.each do |name|
12
+ class_eval %{
13
+ def #{name}_link(options = {})
14
+ label = options[:label] || auth_labels[:#{name}]
15
+ path = #{name}_path options[:role]
16
+ link_to(label, path)
17
+ end
18
+ }
19
+ end
20
+ multi_alias REGISTRATION_LINKS.merge(:_after_ => :link)
21
+
22
+ protected
23
+
24
+ # new_registration_path, edit_registration_path
25
+ REGISTRATION_LINKS.keys.each_with_index do |name, index|
26
+ class_eval %{
27
+ def #{name}_path(role = :user)
28
+ get_registration_path :#{ACTIONS[index]}, role
29
+ end
30
+ }
31
+ end
32
+
33
+ def get_registration_path action, role = :user
34
+ user_reg_path action, role
35
+ end
36
+
37
+ def user_reg_path action, role = :user
38
+ send :"#{action}_#{role}_registration_path"
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,33 @@
1
+ module AuthAssistant::Link
2
+ module Session
3
+ SESSION_LINKS = {
4
+ :sign_out => :log_out,
5
+ :sign_in => :log_in
6
+ }
7
+
8
+ ACTIONS = [:destroy, :create]
9
+
10
+ # new_registration_link, edit_registration_link
11
+ SESSION_LINKS.keys.each_with_index do |name, index|
12
+ class_eval %{
13
+ def #{name}_link(options = {})
14
+ label = options[:label] || auth_labels[:#{name}]
15
+ path = #{ACTIONS[index]}_session_path options[:role]
16
+ link_to(label, path)
17
+ end
18
+ }
19
+ end
20
+
21
+ multi_alias SESSION_LINKS.merge(:_after_ => :link)
22
+
23
+ protected
24
+
25
+ ACTIONS.each do |action|
26
+ class_eval %{
27
+ def #{action}_session_path(role = :user)
28
+ send :"#{action}_\#{role}_session_path"
29
+ end
30
+ }
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module Devise
2
+ modules :link
3
+ end
File without changes
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require 'devise-links/link/registration'
3
+
4
+ describe Devise::Link::Registration do
5
+
6
+ extend_view_with Devise::Link::Registration
7
+
8
+ describe '#new_registration_link' do
9
+ it "should create a registration link" do
10
+ with_engine do |e, view|
11
+ label = 'new registration'
12
+ path = 'new/reg/path'
13
+ view.stubs(:auth_labels).returns(:new_registration => label)
14
+ view.stubs(:user_reg_path).with(:new, :admin).returns path
15
+ view.stubs(:link_to).with(label, path).returns 'it works'
16
+
17
+ res = e.run_template do
18
+ %{<%= new_registration_link(:role => :admin) %> }
19
+ end
20
+ res.should match /it works/
21
+ end
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+ require 'devise-links/link/session'
3
+
4
+ describe Devise::Link::Session do
5
+
6
+ extend_view_with Devise::Link::Session
7
+
8
+ describe '#sign_out_link' do
9
+ it "should create a sign out link" do
10
+ with_engine do |e, view|
11
+ label = 'log out'
12
+ path = 'admin/log/out'
13
+ view.stubs(:auth_labels).returns(:sign_out => label)
14
+ view.stubs(:destroy_session_path).with(:admin).returns path
15
+ view.stubs(:link_to).with(label, path).returns 'it works'
16
+
17
+ res = e.run_template do
18
+ %{<%= sign_out_link(:role => :admin) %> }
19
+ end
20
+ res.should match /it works/
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+ require 'devise-links/rails/configure'
3
+
4
+ describe 'Devise links Rails 3 view extensions' do
5
+ it "should extend Action View with Devise link helpers" do
6
+ after_init :view do
7
+ :view.should be_extended_with Devise::Links, :session, :registration
8
+ end
9
+
10
+ init_app_railties :minimal, :view
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ require 'rspec'
2
+ require 'rspec/autorun'
3
+ require 'devise-links'
4
+
5
+ RSpec.configure do |config|
6
+ config.mock_with :mocha
7
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: devise-links
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Kristian Mandrup
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-09-17 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 0
31
+ - 0
32
+ version: 2.0.0
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: devise
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 1
45
+ - 1
46
+ version: "1.1"
47
+ type: :development
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: require_all
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 1
59
+ - 1
60
+ version: "1.1"
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: sugar-high
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ segments:
72
+ - 0
73
+ - 1
74
+ version: "0.1"
75
+ type: :runtime
76
+ version_requirements: *id004
77
+ description: Link helpers for Devise actions, including user session and registration links.
78
+ email: kmandrup@gmail.com
79
+ executables: []
80
+
81
+ extensions: []
82
+
83
+ extra_rdoc_files:
84
+ - LICENSE
85
+ - README.markdown
86
+ files:
87
+ - .document
88
+ - .gitignore
89
+ - .rspec
90
+ - LICENSE
91
+ - README.markdown
92
+ - Rakefile
93
+ - VERSION
94
+ - lib/devise-links.rb
95
+ - lib/devise-links/link/registration.rb
96
+ - lib/devise-links/link/session.rb
97
+ - lib/devise-links/namespaces.rb
98
+ - lib/devise-links/rails/configure.rb
99
+ - spec/devise-links/helpers/registration-links_spec.rb
100
+ - spec/devise-links/helpers/session_links_spec.rb
101
+ - spec/devise-links/rails/configure_spec.rb
102
+ - spec/spec_helper.rb
103
+ has_rdoc: true
104
+ homepage: http://github.com/kristianmandrup/devise-links
105
+ licenses: []
106
+
107
+ post_install_message:
108
+ rdoc_options:
109
+ - --charset=UTF-8
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ segments:
118
+ - 0
119
+ version: "0"
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ segments:
126
+ - 0
127
+ version: "0"
128
+ requirements: []
129
+
130
+ rubyforge_project:
131
+ rubygems_version: 1.3.7
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: Link helpers for Devise actions
135
+ test_files:
136
+ - spec/devise-links/helpers/registration-links_spec.rb
137
+ - spec/devise-links/helpers/session_links_spec.rb
138
+ - spec/devise-links/rails/configure_spec.rb
139
+ - spec/spec_helper.rb