yaag 0.1.0 → 0.3.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: 4ae888409d5afb7a721b266a6952749b1abc3255a6f3d4671a9204c5b24dd8f4
4
- data.tar.gz: 2eb44833be4f5d0d20f6b3318982697ca754fb3b9ce41f4698532557f0635ef1
3
+ metadata.gz: 9574bdab53be3c4f08a3b5d53a94c13c4112250d508a285ca15a0d2d92eadecb
4
+ data.tar.gz: '0396903f2a8a2f9995e9cfeedb97714fc712bf91db65f0485bfa9bb81f4f6a75'
5
5
  SHA512:
6
- metadata.gz: c59715e2e986d0a012abd80f2d7376dbd106c28d2d9ec12c64bf8db2b1a0207e07760953e652cfdc6e259ec3100e025e9fdb516c6caa199bb424ab6127c06245
7
- data.tar.gz: f20893f3c65274ab3ea55b41efb76d70132a3765f97155b837b4e6c0e21e5068a0d3a3055cf101b7ef10e46550fc2f5dcf1a64b05edaec011fde9ab168a4d958
6
+ metadata.gz: 4250c7ab8385ebd4ae19737ad206f5cc7ec4fb24708f88cb50fd44d7b176ed55983028b862580710bb933995bc35366b7470b5fa3669b9a0c132befcb2ef4567
7
+ data.tar.gz: 4e28c123f2295fe0933b2324ce6add25cd64548570bd0e4434f9ee84fcfb1c148b198e2768b1a1092b268c77c7f211ccaf926e38864b3e2e686473b26204f440
data/README.md CHANGED
@@ -60,12 +60,48 @@ class MyController < ApplicationController
60
60
  end
61
61
  ```
62
62
 
63
- To create a copy of the views for customization, run:
63
+ ### Generators
64
+
65
+ Here is a list of generator available in case any of the components of the gem need to be customized to specific application needs.
66
+
67
+ For views:
64
68
 
65
69
  ```bash
66
70
  rails g authentication:copy:views
67
71
  ```
68
72
 
73
+ For controllers (including concerns):
74
+
75
+ ```bash
76
+ rails g authentication:copy:controllers
77
+ ```
78
+
79
+ For mailers:
80
+
81
+ ```bash
82
+ rails g authentication:copy:mailers
83
+ ```
84
+
85
+ For models:
86
+
87
+ ```bash
88
+ rails g authentication:copy:models
89
+ ```
90
+
91
+ ### Test helper
92
+
93
+ To be able to perform tasks as an authenticated user, a helper is available to be used in tests. Add `include Yaag::Test::SessionsHelper` to your test class to access the methods `sign_in_as` and `sign_out`:
94
+
95
+ ```
96
+ class MyControllerTest < ActionDispatch::IntegrationTest
97
+ include Yaag::Test::SessionsHelper
98
+ setup { sign_in_as(User.take) }
99
+ ...
100
+ end
101
+ ```
102
+
103
+ Note: the example above requires users fixtures to exist, which are not provided by this gem.
104
+
69
105
  ## Release
70
106
 
71
107
  ```bash
@@ -0,0 +1,13 @@
1
+ module Authentication
2
+ module Copy
3
+ class ControllersGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../../../", __dir__)
5
+
6
+ def copy_controllers
7
+ copy_file "app/controllers/concerns/authentication.rb"
8
+ copy_file "app/controllers/sessions_controller.rb"
9
+ copy_file "app/controllers/signins_controller.rb"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module Authentication
2
+ module Copy
3
+ class MailersGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../../../", __dir__)
5
+
6
+ def copy_mailers
7
+ copy_file "app/mailers/signins_mailer.rb"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module Authentication
2
+ module Copy
3
+ class ModelsGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../../../", __dir__)
5
+
6
+ def copy_models
7
+ copy_file "app/models/current.rb"
8
+ copy_file "app/models/session.rb"
9
+ copy_file "app/models/user.rb"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module Yaag
2
+ module Test
3
+ module SessionsHelper
4
+ def sign_in_as(user)
5
+ Current.session = user.sessions.create!
6
+
7
+ ActionDispatch::TestRequest.create.cookie_jar.tap do |cookie_jar|
8
+ cookie_jar.signed[:session_id] = Current.session.id
9
+ cookies["session_id"] = cookie_jar[:session_id]
10
+ end
11
+ end
12
+
13
+ def sign_out
14
+ Current.session&.destroy!
15
+ cookies.delete("session_id")
16
+ end
17
+
18
+ alias :sign_in :sign_in_as
19
+ end
20
+ end
21
+ end
data/lib/yaag/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yaag
2
- VERSION = "0.1.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/yaag.rb CHANGED
@@ -2,6 +2,10 @@ require "yaag/version"
2
2
  require "yaag/engine"
3
3
 
4
4
  module Yaag
5
+ module Test
6
+ autoload :SessionsHelper, "yaag/test/sessions_helper"
7
+ end
8
+
5
9
  module PasswordlessLogin
6
10
  extend ActiveSupport::Concern
7
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nu12
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-01-09 00:00:00.000000000 Z
11
+ date: 2026-01-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Yet Another Authentication Gem (YAAG) provides passwordless authentication
14
14
  for your Ruby on Rails app, all it takes is the user's e-mail address.
@@ -37,12 +37,16 @@ files:
37
37
  - db/migrate/20260108164812_create_users.rb
38
38
  - db/migrate/20260108165215_create_sessions.rb
39
39
  - lib/generators/authentication/USAGE
40
+ - lib/generators/authentication/copy/controllers_generator.rb
41
+ - lib/generators/authentication/copy/mailers_generator.rb
42
+ - lib/generators/authentication/copy/models_generator.rb
40
43
  - lib/generators/authentication/copy/views_generator.rb
41
44
  - lib/generators/authentication/install_generator.rb
42
45
  - lib/generators/authentication/templates/README
43
46
  - lib/tasks/yaag_tasks.rake
44
47
  - lib/yaag.rb
45
48
  - lib/yaag/engine.rb
49
+ - lib/yaag/test/sessions_helper.rb
46
50
  - lib/yaag/version.rb
47
51
  homepage: https://github.com/nu12/yaag
48
52
  licenses: