dscf-core 0.1.6 → 0.1.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.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/dscf/core/json_response.rb +12 -1
  3. data/app/controllers/concerns/dscf/core/reviewable_controller.rb +345 -0
  4. data/app/controllers/dscf/core/addresses_controller.rb +52 -0
  5. data/app/controllers/dscf/core/auth_controller.rb +19 -14
  6. data/app/models/concerns/dscf/core/reviewable_model.rb +31 -0
  7. data/app/models/dscf/core/review.rb +22 -0
  8. data/app/models/dscf/core/role.rb +8 -0
  9. data/app/models/dscf/core/user.rb +8 -0
  10. data/app/serializers/dscf/core/address_serializer.rb +10 -0
  11. data/app/serializers/dscf/core/business_serializer.rb +10 -0
  12. data/app/serializers/dscf/core/business_type_serializer.rb +9 -0
  13. data/app/serializers/dscf/core/review_serializer.rb +16 -0
  14. data/app/serializers/dscf/core/role_serializer.rb +9 -0
  15. data/app/serializers/dscf/core/user_auth_serializer.rb +10 -0
  16. data/app/serializers/dscf/core/user_profile_serializer.rb +12 -0
  17. data/app/serializers/dscf/core/user_role_serializer.rb +10 -0
  18. data/app/serializers/dscf/core/user_serializer.rb +14 -0
  19. data/config/routes.rb +2 -0
  20. data/db/migrate/20250926102025_create_dscf_core_reviews.rb +14 -0
  21. data/lib/dscf/core/version.rb +1 -1
  22. data/lib/generators/common/USAGE +39 -0
  23. data/lib/generators/common/common_generator.rb +579 -0
  24. data/lib/generators/common/templates/controller.rb.erb +75 -0
  25. data/lib/generators/common/templates/request_spec.rb.erb +33 -0
  26. data/lib/generators/common/templates/serializer.rb.erb +43 -0
  27. data/spec/factories/dscf/core/reviews.rb +11 -0
  28. metadata +22 -2
@@ -0,0 +1,75 @@
1
+ <% if controller_namespace_modules.any? -%>
2
+ <% controller_namespace_modules.each do |mod| -%>
3
+ module <%= mod %>
4
+ <% end -%>
5
+ class <%= controller_class_name %> < ApplicationController
6
+ include Dscf::Core::Common
7
+
8
+ private
9
+
10
+ def model_params
11
+ params.require(:<%= model_class_name.underscore %>).permit(
12
+ # TODO: Add your permitted parameters here
13
+ # Example: :name, :email, :status
14
+ )
15
+ end
16
+
17
+ # Override to define associations to eager load
18
+ def eager_loaded_associations
19
+ []
20
+ end
21
+
22
+ # Override to define allowed columns for ordering/pagination
23
+ def allowed_order_columns
24
+ %w[id created_at updated_at]
25
+ end
26
+
27
+ # Override to define serializer includes for different actions
28
+ def default_serializer_includes
29
+ {
30
+ default: [],
31
+ index: [],
32
+ show: [],
33
+ create: [],
34
+ update: []
35
+ }
36
+ end
37
+ end
38
+ <% controller_namespace_modules.each do |mod| -%>
39
+ end
40
+ <% end -%>
41
+ <% else -%>
42
+ class <%= controller_class_name %> < ApplicationController
43
+ include Dscf::Core::Common
44
+
45
+ private
46
+
47
+ def model_params
48
+ params.require(:<%= model_class_name.underscore %>).permit(
49
+ # TODO: Add your permitted parameters here
50
+ # Example: :name, :email, :status
51
+ )
52
+ end
53
+
54
+ # Override to define associations to eager load
55
+ def eager_loaded_associations
56
+ []
57
+ end
58
+
59
+ # Override to define allowed columns for ordering/pagination
60
+ def allowed_order_columns
61
+ %w[id created_at updated_at]
62
+ end
63
+
64
+ # Override to define serializer includes for different actions
65
+ def default_serializer_includes
66
+ {
67
+ default: [],
68
+ index: [],
69
+ show: [],
70
+ create: [],
71
+ update: []
72
+ }
73
+ end
74
+ end
75
+ <% end -%>
@@ -0,0 +1,33 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe <%= spec_describe_name %>, type: :request do
4
+ include_context "authenticated_user"
5
+ it_behaves_like "request_shared_spec", "<%= controller_name %>", 14, []
6
+
7
+ let(:valid_attributes) do
8
+ {
9
+ # TODO: Add your valid attributes here
10
+ # Example:
11
+ # name: "Test Name",
12
+ # email: "test@example.com",
13
+ # status: "active"
14
+ }
15
+ end
16
+
17
+ let(:invalid_attributes) do
18
+ {
19
+ # TODO: Add your invalid attributes here
20
+ # Example:
21
+ # name: "",
22
+ # email: "invalid-email"
23
+ }
24
+ end
25
+
26
+ let(:new_attributes) do
27
+ {
28
+ # TODO: Add your update attributes here
29
+ # Example:
30
+ # name: "Updated Name"
31
+ }
32
+ end
33
+ end
@@ -0,0 +1,43 @@
1
+ <% if controller_namespace_modules.any? -%>
2
+ <% controller_namespace_modules.each do |mod| -%>
3
+ module <%= mod %>
4
+ <% end -%>
5
+ class <%= model_class_name %>Serializer < ActiveModel::Serializer
6
+ attributes <%= serializer_attributes %>
7
+ <% if model_exists? -%>
8
+ <% serializer_associations.each do |macro, associations| -%>
9
+
10
+ <% associations.each do |association| -%>
11
+ <%= macro %> :<%= association[:name] %><%= association[:serializer] ? ", serializer: #{association[:serializer]}" : "" %>
12
+ <% end -%>
13
+ <% end -%>
14
+ <% else -%>
15
+
16
+ # TODO: Model not found. Please ensure the model exists and add associations manually:
17
+ # belongs_to :association_name, serializer: AssociationSerializer
18
+ # has_many :association_names, serializer: AssociationSerializer
19
+ # has_one :association_name, serializer: AssociationSerializer
20
+ <% end -%>
21
+ end
22
+ <% controller_namespace_modules.reverse.each do |mod| -%>
23
+ end
24
+ <% end -%>
25
+ <% else -%>
26
+ class <%= model_class_name %>Serializer < ActiveModel::Serializer
27
+ attributes <%= serializer_attributes %>
28
+ <% if model_exists? -%>
29
+ <% serializer_associations.each do |macro, associations| -%>
30
+
31
+ <% associations.each do |association| -%>
32
+ <%= macro %> :<%= association[:name] %><%= association[:serializer] ? ", serializer: #{association[:serializer]}" : "" %>
33
+ <% end -%>
34
+ <% end -%>
35
+ <% else -%>
36
+
37
+ # TODO: Model not found. Please ensure the model exists and add associations manually:
38
+ # belongs_to :association_name, serializer: AssociationSerializer
39
+ # has_many :association_names, serializer: AssociationSerializer
40
+ # has_one :association_name, serializer: AssociationSerializer
41
+ <% end -%>
42
+ end
43
+ <% end -%>
@@ -0,0 +1,11 @@
1
+ FactoryBot.define do
2
+ factory :review, class: "Dscf::Core::Review" do
3
+ reviewable { create(:user) }
4
+ context { Faker::Lorem.word }
5
+
6
+ status { "pending" }
7
+ feedback { {} }
8
+ reviewed_by { create(:user) }
9
+ reviewed_at { nil }
10
+ end
11
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dscf-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asrat
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-08-31 00:00:00.000000000 Z
10
+ date: 2025-09-29 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -430,12 +430,15 @@ files:
430
430
  - app/controllers/concerns/dscf/core/filterable.rb
431
431
  - app/controllers/concerns/dscf/core/json_response.rb
432
432
  - app/controllers/concerns/dscf/core/pagination.rb
433
+ - app/controllers/concerns/dscf/core/reviewable_controller.rb
433
434
  - app/controllers/concerns/dscf/core/token_authenticatable.rb
435
+ - app/controllers/dscf/core/addresses_controller.rb
434
436
  - app/controllers/dscf/core/application_controller.rb
435
437
  - app/controllers/dscf/core/auth_controller.rb
436
438
  - app/errors/dscf/core/authentication_error.rb
437
439
  - app/jobs/dscf/core/application_job.rb
438
440
  - app/mailers/dscf/core/application_mailer.rb
441
+ - app/models/concerns/dscf/core/reviewable_model.rb
439
442
  - app/models/concerns/dscf/core/user_authenticatable.rb
440
443
  - app/models/dscf/core/address.rb
441
444
  - app/models/dscf/core/application_record.rb
@@ -443,10 +446,20 @@ files:
443
446
  - app/models/dscf/core/business_type.rb
444
447
  - app/models/dscf/core/document.rb
445
448
  - app/models/dscf/core/refresh_token.rb
449
+ - app/models/dscf/core/review.rb
446
450
  - app/models/dscf/core/role.rb
447
451
  - app/models/dscf/core/user.rb
448
452
  - app/models/dscf/core/user_profile.rb
449
453
  - app/models/dscf/core/user_role.rb
454
+ - app/serializers/dscf/core/address_serializer.rb
455
+ - app/serializers/dscf/core/business_serializer.rb
456
+ - app/serializers/dscf/core/business_type_serializer.rb
457
+ - app/serializers/dscf/core/review_serializer.rb
458
+ - app/serializers/dscf/core/role_serializer.rb
459
+ - app/serializers/dscf/core/user_auth_serializer.rb
460
+ - app/serializers/dscf/core/user_profile_serializer.rb
461
+ - app/serializers/dscf/core/user_role_serializer.rb
462
+ - app/serializers/dscf/core/user_serializer.rb
450
463
  - app/services/dscf/core/auth_service.rb
451
464
  - app/services/dscf/core/token_service.rb
452
465
  - config/initializers/jwt.rb
@@ -465,15 +478,22 @@ files:
465
478
  - db/migrate/20250824114725_create_dscf_core_refresh_tokens.rb
466
479
  - db/migrate/20250824200927_make_email_and_phone_optional_for_users.rb
467
480
  - db/migrate/20250825192113_add_defaults_to_user_profiles.rb
481
+ - db/migrate/20250926102025_create_dscf_core_reviews.rb
468
482
  - lib/dscf/core.rb
469
483
  - lib/dscf/core/engine.rb
470
484
  - lib/dscf/core/version.rb
485
+ - lib/generators/common/USAGE
486
+ - lib/generators/common/common_generator.rb
487
+ - lib/generators/common/templates/controller.rb.erb
488
+ - lib/generators/common/templates/request_spec.rb.erb
489
+ - lib/generators/common/templates/serializer.rb.erb
471
490
  - lib/tasks/dscf/core_tasks.rake
472
491
  - spec/factories/dscf/core/addresses.rb
473
492
  - spec/factories/dscf/core/business_types.rb
474
493
  - spec/factories/dscf/core/businesses.rb
475
494
  - spec/factories/dscf/core/documents.rb
476
495
  - spec/factories/dscf/core/refresh_tokens.rb
496
+ - spec/factories/dscf/core/reviews.rb
477
497
  - spec/factories/dscf/core/roles.rb
478
498
  - spec/factories/dscf/core/user_profiles.rb
479
499
  - spec/factories/dscf/core/user_roles.rb