avocado 0.5.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +59 -14
  3. data/README.md +8 -43
  4. data/Rakefile +0 -2
  5. data/app/controllers/avocado/affirmations_controller.rb +21 -18
  6. data/app/controllers/avocado/base_controller.rb +26 -5
  7. data/app/controllers/avocado/credentials_controller.rb +41 -0
  8. data/app/controllers/avocado/emails_controller.rb +9 -17
  9. data/app/controllers/avocado/events_controller.rb +3 -3
  10. data/app/controllers/avocado/passwords_controller.rb +8 -8
  11. data/app/controllers/avocado/recoveries_controller.rb +8 -41
  12. data/app/controllers/avocado/registrations_controller.rb +7 -14
  13. data/app/controllers/avocado/sessions_controller.rb +21 -13
  14. data/app/controllers/avocado/verifications_controller.rb +14 -15
  15. data/app/views/avocado/affirmations/_form.html.erb +4 -0
  16. data/app/views/avocado/affirmations/edit.html.erb +7 -0
  17. data/app/views/avocado/affirmations/new.html.erb +2 -4
  18. data/app/views/avocado/{recoveries/edit.html.erb → credentials/_form.html.erb} +4 -13
  19. data/app/views/avocado/credentials/edit.html.erb +12 -0
  20. data/app/views/avocado/emails/_form.html.erb +8 -0
  21. data/app/views/avocado/emails/edit.html.erb +1 -6
  22. data/app/views/avocado/mailer/email_affirmation.text.erb +1 -1
  23. data/app/views/avocado/mailer/email_verification.text.erb +1 -1
  24. data/app/views/avocado/mailer/password_reset.text.erb +1 -1
  25. data/app/views/avocado/passwords/_form.html.erb +12 -0
  26. data/app/views/avocado/passwords/edit.html.erb +1 -9
  27. data/app/views/avocado/recoveries/_form.html.erb +4 -0
  28. data/app/views/avocado/recoveries/new.html.erb +2 -4
  29. data/app/views/avocado/registrations/_form.html.erb +12 -0
  30. data/app/views/avocado/registrations/new.html.erb +1 -12
  31. data/app/views/avocado/sessions/_form.html.erb +8 -0
  32. data/app/views/avocado/sessions/new.html.erb +1 -4
  33. data/app/views/avocado/verifications/edit.html.erb +7 -0
  34. data/config/locales/en.yml +45 -0
  35. data/config/routes/avocado.rb +11 -0
  36. data/config.ru +0 -2
  37. data/docs/USAGE.md +164 -0
  38. data/lib/avocado/authentication.rb +2 -4
  39. data/lib/avocado/current.rb +0 -2
  40. data/lib/avocado/engine.rb +5 -2
  41. data/lib/avocado/event.rb +0 -2
  42. data/lib/avocado/mailer.rb +0 -2
  43. data/lib/avocado/session.rb +6 -2
  44. data/lib/avocado/session_callbacks.rb +0 -2
  45. data/lib/avocado/user.rb +0 -2
  46. data/lib/avocado/user_callbacks.rb +0 -2
  47. data/lib/avocado/user_tokens.rb +0 -2
  48. data/lib/avocado/user_validations.rb +0 -2
  49. data/lib/avocado/version.rb +1 -3
  50. data/lib/avocado.rb +1 -2
  51. data/lib/generators/avocado/migrations/migrations_generator.rb +34 -0
  52. data/lib/generators/avocado/migrations/templates/create_events.rb.tt +12 -0
  53. data/lib/generators/avocado/migrations/templates/create_sessions.rb.tt +12 -0
  54. data/lib/generators/avocado/migrations/templates/create_users.rb.tt +11 -0
  55. data/lib/generators/avocado/views/views_generator.rb +21 -0
  56. metadata +27 -38
  57. data/config/routes.rb +0 -12
@@ -0,0 +1,34 @@
1
+ require "rails/generators/base"
2
+ require "rails/generators/active_record"
3
+
4
+ module Avocado
5
+ class MigrationsGenerator < Rails::Generators::Base
6
+ include ActiveRecord::Generators::Migration
7
+
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ def create_migrations
11
+ migration_template "create_users.rb", "#{db_migrate_path}/create_users.rb"
12
+ migration_template "create_sessions.rb", "#{db_migrate_path}/create_sessions.rb"
13
+ migration_template "create_events.rb", "#{db_migrate_path}/create_events.rb"
14
+ end
15
+
16
+ private
17
+
18
+ def primary_and_foreign_key_types
19
+ config = Rails.configuration.generators
20
+ setting = config.options[config.orm][:primary_key_type]
21
+ primary_key_type = setting || :primary_key
22
+ foreign_key_type = setting || :bigint
23
+ [primary_key_type, foreign_key_type]
24
+ end
25
+
26
+ def primary_key_type
27
+ primary_and_foreign_key_types.first
28
+ end
29
+
30
+ def foreign_key_type
31
+ primary_and_foreign_key_types.last
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,12 @@
1
+ class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
+ def change
3
+ create_table :events, id: :<%= primary_key_type %> do |t|
4
+ t.references :user, null: false, foreign_key: true, type: :<%= foreign_key_type %>
5
+ t.string :action, null: false
6
+ t.string :user_agent
7
+ t.string :ip_address
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
+ def change
3
+ create_table :sessions, id: :<%= primary_key_type %> do |t|
4
+ t.references :user, null: false, foreign_key: true, type: :<%= foreign_key_type %>
5
+ t.string :token, null: false, index: {unique: true}
6
+ t.string :user_agent
7
+ t.string :ip_address
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
+ def change
3
+ create_table :users, id: :<%= primary_key_type %> do |t|
4
+ t.string :email, null: false, index: {unique: true}
5
+ t.string :password_digest, null: false
6
+ t.boolean :verified, null: false, default: false, index: true
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ require "rails/generators/base"
2
+
3
+ module Avocado
4
+ class ViewsGenerator < Rails::Generators::Base
5
+ source_root File.expand_path("../../../..", __dir__)
6
+
7
+ def create_views
8
+ directory source_directory, target_directory
9
+ end
10
+
11
+ private
12
+
13
+ def source_directory
14
+ "app/views/avocado"
15
+ end
16
+
17
+ def target_directory
18
+ Rails.root.join("app/views/avocado")
19
+ end
20
+ end
21
+ end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avocado
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Jankowski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-21 00:00:00.000000000 Z
11
+ date: 2023-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '3.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,37 +38,9 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 7.1.0.alpha
41
- - !ruby/object:Gem::Dependency
42
- name: combustion
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.3'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.3'
55
- - !ruby/object:Gem::Dependency
56
- name: sqlite3
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
41
  description:
70
42
  email:
71
- - matt@jankowski.online
43
+ - info@tcuwp.co
72
44
  executables: []
73
45
  extensions: []
74
46
  extra_rdoc_files: []
@@ -82,6 +54,7 @@ files:
82
54
  - Rakefile
83
55
  - app/controllers/avocado/affirmations_controller.rb
84
56
  - app/controllers/avocado/base_controller.rb
57
+ - app/controllers/avocado/credentials_controller.rb
85
58
  - app/controllers/avocado/emails_controller.rb
86
59
  - app/controllers/avocado/events_controller.rb
87
60
  - app/controllers/avocado/passwords_controller.rb
@@ -89,22 +62,33 @@ files:
89
62
  - app/controllers/avocado/registrations_controller.rb
90
63
  - app/controllers/avocado/sessions_controller.rb
91
64
  - app/controllers/avocado/verifications_controller.rb
65
+ - app/views/avocado/affirmations/_form.html.erb
66
+ - app/views/avocado/affirmations/edit.html.erb
92
67
  - app/views/avocado/affirmations/new.html.erb
68
+ - app/views/avocado/credentials/_form.html.erb
69
+ - app/views/avocado/credentials/edit.html.erb
70
+ - app/views/avocado/emails/_form.html.erb
93
71
  - app/views/avocado/emails/edit.html.erb
94
72
  - app/views/avocado/events/_event.html.erb
95
73
  - app/views/avocado/events/index.html.erb
96
74
  - app/views/avocado/mailer/email_affirmation.text.erb
97
75
  - app/views/avocado/mailer/email_verification.text.erb
98
76
  - app/views/avocado/mailer/password_reset.text.erb
77
+ - app/views/avocado/passwords/_form.html.erb
99
78
  - app/views/avocado/passwords/edit.html.erb
100
- - app/views/avocado/recoveries/edit.html.erb
79
+ - app/views/avocado/recoveries/_form.html.erb
101
80
  - app/views/avocado/recoveries/new.html.erb
81
+ - app/views/avocado/registrations/_form.html.erb
102
82
  - app/views/avocado/registrations/new.html.erb
83
+ - app/views/avocado/sessions/_form.html.erb
103
84
  - app/views/avocado/sessions/_session.html.erb
104
85
  - app/views/avocado/sessions/index.html.erb
105
86
  - app/views/avocado/sessions/new.html.erb
87
+ - app/views/avocado/verifications/edit.html.erb
106
88
  - config.ru
107
- - config/routes.rb
89
+ - config/locales/en.yml
90
+ - config/routes/avocado.rb
91
+ - docs/USAGE.md
108
92
  - lib/avocado.rb
109
93
  - lib/avocado/authentication.rb
110
94
  - lib/avocado/current.rb
@@ -118,6 +102,11 @@ files:
118
102
  - lib/avocado/user_tokens.rb
119
103
  - lib/avocado/user_validations.rb
120
104
  - lib/avocado/version.rb
105
+ - lib/generators/avocado/migrations/migrations_generator.rb
106
+ - lib/generators/avocado/migrations/templates/create_events.rb.tt
107
+ - lib/generators/avocado/migrations/templates/create_sessions.rb.tt
108
+ - lib/generators/avocado/migrations/templates/create_users.rb.tt
109
+ - lib/generators/avocado/views/views_generator.rb
121
110
  - sig/avocado.rbs
122
111
  homepage: https://github.com/tcuwp/avocado
123
112
  licenses:
@@ -141,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
130
  - !ruby/object:Gem::Version
142
131
  version: '0'
143
132
  requirements: []
144
- rubygems_version: 3.4.15
133
+ rubygems_version: 3.4.18
145
134
  signing_key:
146
135
  specification_version: 4
147
136
  summary: Simple authentication for Rails (7.1+) applications
data/config/routes.rb DELETED
@@ -1,12 +0,0 @@
1
- Rails.application.routes.draw do
2
- scope module: :avocado do
3
- resource :email, only: %i[edit update]
4
- resource :password, only: %i[edit update]
5
- resources :affirmations, only: %i[new show create]
6
- resources :events, only: %i[index]
7
- resources :recoveries, only: %i[new create edit update]
8
- resources :registrations, only: %i[new create]
9
- resources :sessions, only: %i[index new create destroy]
10
- resources :verifications, only: %i[show create]
11
- end
12
- end