registration_generator 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd28b26f3f15209f5ae09b58445af142d718a72448469b87b92fc5821c6c4fcd
4
- data.tar.gz: 15d8d57286ac36cee35843e5ae68911a2027463f37781a6528f52ce6e1f68bb1
3
+ metadata.gz: a95a984757d27298f9e5badb0dc3e8d4951865ddc0fe3b839335c85000d5efaf
4
+ data.tar.gz: fee07f733da31a604c0ff23935a468fba8b0830ab4c8b32e39a5be53dbee6c08
5
5
  SHA512:
6
- metadata.gz: daad25001fe12feed81e20fe62cd83b677b8792466f42a4377a62acaf2c50d807e3c384555fb3249b7bf9a5378822958f3bdde7a855415827a75e84405e588fe
7
- data.tar.gz: 9c139a62bd8c2cb4821e4330cb7cc05c7591a7cc052021ab97ef732300b1736cbdf311e3906480eca7298590cef45dbde38fa3ccd508e064c193f4f80583e48e
6
+ metadata.gz: ae0c5fb1061edcd25a28c6fe8fb9ff23654f894b85b9da5ec26f5569f105c95e2842ccb6913917aacb7b7cdc2e6bbf2857f31898f49848baac85b68530475e65
7
+ data.tar.gz: b521a0507ec7f13ee484f0538268a6c002ec5bcdd5f9f53cc687fe9a2552204e774317cfbf83b8960e5001fe7f589b08127c19c7d75b6b8cb1d74e5d7704b309
data/README.md CHANGED
@@ -1,24 +1,36 @@
1
1
  # RegistrationGenerator
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ A Rails Generator that adds registration pages to the Authentication Generator as well as some useful routes and helper methods.
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/registration_generator`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ * Adds a registration page which will create a new user with an email address and password.
6
+ * Adds `new_registration_path` and `registration_path` routes
7
+ * Adds a registration link on the sign_in page
8
+ * Adds '/sign_in' and '/sign_out' routes as alias to '/session/new' and 'session', these can be accessed using the `sign_in_path` and `sign_out_path, method: :delete` helpers
9
+ * Adds a `link_to_sign_in_or_out` helper that will display a sign out or sign in link depending on if a user is authenticated or not
10
+ * Adds a `show_username_if_signed_in` method that displays a "signed in as username" message if the user is signed in
11
+ * Adds a `name` method to the user model that is an alias for the email_address, but can be changed
6
12
 
7
13
  ## Installation
8
14
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
15
  Install the gem and add to the application's Gemfile by executing:
12
16
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
17
+ $ bundle add registration_generator
14
18
 
15
19
  If bundler is not being used to manage dependencies, install the gem by executing:
16
20
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
+ $ gem install registration_generator
18
22
 
19
23
  ## Usage
20
24
 
21
- TODO: Write usage instructions here
25
+ ```bash
26
+ rails generate authentication
27
+ ```
28
+
29
+ Then run the registration generator:
30
+
31
+ ```bash
32
+ rails generate registration
33
+ ```
22
34
 
23
35
  ## Development
24
36
 
@@ -28,7 +40,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
28
40
 
29
41
  ## Contributing
30
42
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/registration_generator.
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/daz4126/registration_generator.
32
44
 
33
45
  ## License
34
46
 
@@ -20,6 +20,44 @@ module RegistrationGenerator
20
20
 
21
21
  def add_routes
22
22
  route "resource :registration, only: [:new, :create]"
23
+ route "get 'sign_in', to: 'session#new', as :sign_in"
24
+ route "delete 'sign_out', to: 'session#destroy', as :sign_out"
23
25
  end
24
26
  end
27
+
28
+ def create_helper
29
+ create_file "app/helpers/authentication_helper.rb", <<-RUBY
30
+ module AuthenticationHelper
31
+ def link_to_sign_in_or_out(show_user: false)
32
+ if authenticated?
33
+ button_to "Sign Out", sign_out_path, method: :delete
34
+ else
35
+ link_to "Sign In", sign_in_path
36
+ end
37
+ end
38
+
39
+ def show_username_if_signed_in(text="Signed in as")
40
+ if authenticated?
41
+ content = "#{text} #{Current.user.name}"
42
+ content.html_safe
43
+ end
44
+ end
45
+ end
46
+ RUBY
47
+
48
+ inject_into_class "app/controllers/application_controller.rb", ApplicationController, <<-RUBY
49
+
50
+ include AuthenticationHelper
51
+ RUBY
52
+ end
53
+
54
+ def add_name_method_to_user
55
+ inject_into_class "app/models/user.rb", User, <<-RUBY
56
+
57
+ def name
58
+ email_address
59
+ end
60
+
61
+ RUBY
62
+ end
25
63
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RegistrationGenerator
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: registration_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Your Name
8
- autorequire:
7
+ - DAZ
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-02-21 00:00:00.000000000 Z
10
+ date: 2025-02-22 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
@@ -24,10 +23,24 @@ dependencies:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
25
  version: '8.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: ruby
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.0'
27
40
  description: This gem provides a Rails generator to create a registration form and
28
41
  related files.
29
42
  email:
30
- - your_email@example.com
43
+ - darren.jones@hey.com
31
44
  executables: []
32
45
  extensions: []
33
46
  extra_rdoc_files: []
@@ -45,7 +58,6 @@ homepage: https://github.com/your_username/registration_generator
45
58
  licenses:
46
59
  - MIT
47
60
  metadata: {}
48
- post_install_message:
49
61
  rdoc_options: []
50
62
  require_paths:
51
63
  - lib
@@ -60,8 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
72
  - !ruby/object:Gem::Version
61
73
  version: '0'
62
74
  requirements: []
63
- rubygems_version: 3.5.11
64
- signing_key:
75
+ rubygems_version: 3.6.3
65
76
  specification_version: 4
66
77
  summary: A Rails generator for user registration
67
78
  test_files: []