categoria 0.1.0.pre.beta0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +34 -0
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG.md +5 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +33 -0
  7. data/Rakefile +12 -0
  8. data/categoria.gemspec +48 -0
  9. data/lib/categoria/version.rb +6 -0
  10. data/lib/categoria.rb +9 -0
  11. data/lib/generators/categoria/command_generator.rb +8 -0
  12. data/lib/generators/categoria/domain_generator.rb +35 -0
  13. data/lib/generators/categoria/model_generator.rb +8 -0
  14. data/lib/generators/categoria/templates/domain_module.rb.erb +6 -0
  15. data/sig/categoria.rbs +4 -0
  16. data/sorbet/config +4 -0
  17. data/sorbet/rbi/annotations/.gitattributes +1 -0
  18. data/sorbet/rbi/annotations/actionmailer.rbi +10 -0
  19. data/sorbet/rbi/annotations/actionpack.rbi +429 -0
  20. data/sorbet/rbi/annotations/actionview.rbi +75 -0
  21. data/sorbet/rbi/annotations/activejob.rbi +44 -0
  22. data/sorbet/rbi/annotations/activemodel.rbi +89 -0
  23. data/sorbet/rbi/annotations/activerecord.rbi +92 -0
  24. data/sorbet/rbi/annotations/activesupport.rbi +421 -0
  25. data/sorbet/rbi/annotations/globalid.rbi +30 -0
  26. data/sorbet/rbi/annotations/railties.rbi +61 -0
  27. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  28. data/sorbet/rbi/gems/.gitattributes +1 -0
  29. data/sorbet/rbi/gems/actioncable@7.1.3.3.rbi +9 -0
  30. data/sorbet/rbi/gems/actionmailbox@7.1.3.3.rbi +9 -0
  31. data/sorbet/rbi/gems/actionmailer@7.1.3.3.rbi +9 -0
  32. data/sorbet/rbi/gems/actionpack@7.1.3.3.rbi +9 -0
  33. data/sorbet/rbi/gems/actiontext@7.1.3.3.rbi +9 -0
  34. data/sorbet/rbi/gems/actionview@7.1.3.3.rbi +9 -0
  35. data/sorbet/rbi/gems/activejob@7.1.3.3.rbi +9 -0
  36. data/sorbet/rbi/gems/activemodel@7.1.3.3.rbi +9 -0
  37. data/sorbet/rbi/gems/activerecord@7.1.3.3.rbi +9 -0
  38. data/sorbet/rbi/gems/activestorage@7.1.3.3.rbi +9 -0
  39. data/sorbet/rbi/gems/activesupport@7.1.3.3.rbi +11 -0
  40. data/sorbet/rbi/gems/ast@2.4.2.rbi +585 -0
  41. data/sorbet/rbi/gems/base64@0.2.0.rbi +9 -0
  42. data/sorbet/rbi/gems/bigdecimal@3.1.8.rbi +9 -0
  43. data/sorbet/rbi/gems/builder@3.2.4.rbi +9 -0
  44. data/sorbet/rbi/gems/concurrent-ruby@1.3.1.rbi +9 -0
  45. data/sorbet/rbi/gems/connection_pool@2.4.1.rbi +9 -0
  46. data/sorbet/rbi/gems/crass@1.0.6.rbi +9 -0
  47. data/sorbet/rbi/gems/date@3.3.4.rbi +73 -0
  48. data/sorbet/rbi/gems/drb@2.2.1.rbi +9 -0
  49. data/sorbet/rbi/gems/erubi@1.12.0.rbi +146 -0
  50. data/sorbet/rbi/gems/globalid@1.2.1.rbi +9 -0
  51. data/sorbet/rbi/gems/i18n@1.14.5.rbi +9 -0
  52. data/sorbet/rbi/gems/io-console@0.7.2.rbi +9 -0
  53. data/sorbet/rbi/gems/json@2.7.2.rbi +1562 -0
  54. data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14238 -0
  55. data/sorbet/rbi/gems/loofah@2.22.0.rbi +9 -0
  56. data/sorbet/rbi/gems/mail@2.8.1.rbi +9 -0
  57. data/sorbet/rbi/gems/marcel@1.0.4.rbi +9 -0
  58. data/sorbet/rbi/gems/mini_mime@1.1.5.rbi +9 -0
  59. data/sorbet/rbi/gems/minitest@5.23.1.rbi +1555 -0
  60. data/sorbet/rbi/gems/mutex_m@0.2.0.rbi +9 -0
  61. data/sorbet/rbi/gems/net-imap@0.4.11.rbi +9 -0
  62. data/sorbet/rbi/gems/net-pop@0.1.2.rbi +9 -0
  63. data/sorbet/rbi/gems/net-protocol@0.2.2.rbi +282 -0
  64. data/sorbet/rbi/gems/net-smtp@0.5.0.rbi +9 -0
  65. data/sorbet/rbi/gems/netrc@0.11.0.rbi +159 -0
  66. data/sorbet/rbi/gems/nio4r@2.7.3.rbi +9 -0
  67. data/sorbet/rbi/gems/nokogiri@1.16.5.rbi +9 -0
  68. data/sorbet/rbi/gems/parallel@1.24.0.rbi +281 -0
  69. data/sorbet/rbi/gems/parser@3.3.2.0.rbi +5519 -0
  70. data/sorbet/rbi/gems/prism@0.29.0.rbi +37987 -0
  71. data/sorbet/rbi/gems/psych@5.1.2.rbi +1732 -0
  72. data/sorbet/rbi/gems/racc@1.8.0.rbi +162 -0
  73. data/sorbet/rbi/gems/rack-session@2.0.0.rbi +9 -0
  74. data/sorbet/rbi/gems/rack-test@2.1.0.rbi +9 -0
  75. data/sorbet/rbi/gems/rack@3.0.11.rbi +2910 -0
  76. data/sorbet/rbi/gems/rackup@2.1.0.rbi +390 -0
  77. data/sorbet/rbi/gems/rails-dom-testing@2.2.0.rbi +9 -0
  78. data/sorbet/rbi/gems/rails-html-sanitizer@1.6.0.rbi +9 -0
  79. data/sorbet/rbi/gems/rails@7.1.3.3.rbi +9 -0
  80. data/sorbet/rbi/gems/railties@7.1.3.3.rbi +9 -0
  81. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +403 -0
  82. data/sorbet/rbi/gems/rake@13.2.1.rbi +3028 -0
  83. data/sorbet/rbi/gems/rbi@0.1.13.rbi +3078 -0
  84. data/sorbet/rbi/gems/rdoc@6.7.0.rbi +12719 -0
  85. data/sorbet/rbi/gems/regexp_parser@2.9.2.rbi +3772 -0
  86. data/sorbet/rbi/gems/reline@0.5.8.rbi +9 -0
  87. data/sorbet/rbi/gems/rexml@3.2.8.rbi +4794 -0
  88. data/sorbet/rbi/gems/rubocop-ast@1.31.3.rbi +7045 -0
  89. data/sorbet/rbi/gems/rubocop-minitest@0.35.0.rbi +2611 -0
  90. data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +329 -0
  91. data/sorbet/rbi/gems/rubocop-sorbet@0.8.3.rbi +1607 -0
  92. data/sorbet/rbi/gems/rubocop@1.64.1.rbi +58104 -0
  93. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1318 -0
  94. data/sorbet/rbi/gems/spoom@1.3.2.rbi +4421 -0
  95. data/sorbet/rbi/gems/stringio@3.1.0.rbi +9 -0
  96. data/sorbet/rbi/gems/strscan@3.1.0.rbi +9 -0
  97. data/sorbet/rbi/gems/tapioca@0.14.3.rbi +3534 -0
  98. data/sorbet/rbi/gems/thor@1.3.1.rbi +4352 -0
  99. data/sorbet/rbi/gems/timeout@0.4.1.rbi +143 -0
  100. data/sorbet/rbi/gems/tzinfo@2.0.6.rbi +9 -0
  101. data/sorbet/rbi/gems/unicode-display_width@2.5.0.rbi +66 -0
  102. data/sorbet/rbi/gems/webrick@1.8.1.rbi +2607 -0
  103. data/sorbet/rbi/gems/websocket-driver@0.7.6.rbi +9 -0
  104. data/sorbet/rbi/gems/websocket-extensions@0.1.5.rbi +9 -0
  105. data/sorbet/rbi/gems/yard-sorbet@0.8.1.rbi +429 -0
  106. data/sorbet/rbi/gems/yard@0.9.36.rbi +18412 -0
  107. data/sorbet/rbi/gems/zeitwerk@2.6.15.rbi +9 -0
  108. data/sorbet/rbi/todo.rbi +46 -0
  109. data/sorbet/tapioca/config.yml +13 -0
  110. data/sorbet/tapioca/require.rb +4 -0
  111. metadata +339 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 708dc304bd6e976ef1570ee99cb1208b4814c37fdcff7e0f69ac4d2ce7970e50
4
+ data.tar.gz: d2db1ff75ae27757941554ee650ea86e5db8fb6a34d715a439e74b2bbc67f4b3
5
+ SHA512:
6
+ metadata.gz: 84ff6674a0d1c147b13a449c2f816314d1e748263e67bfad5ada878055897398ee60a501d372649718d74e34d3973447553cd45747a098aa9433d6851e137a37
7
+ data.tar.gz: 3581214bb48972f200f24b59567b2e529fdcf6c3164aa49f3b001d38c6173af89aa182cb240995d2eb058312d28ebeaa61225b195bc7a6150117a7b34ef4246d
data/.rubocop.yml ADDED
@@ -0,0 +1,34 @@
1
+ require:
2
+ - rubocop-rake
3
+ - rubocop-minitest
4
+ - rubocop-sorbet
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 3.3
8
+ Exclude:
9
+ - "**/sorbet/**/*"
10
+ - "**/bin/**/*"
11
+
12
+ Style/StringLiterals:
13
+ Enabled: true
14
+ EnforcedStyle: double_quotes
15
+
16
+ Style/StringLiteralsInInterpolation:
17
+ Enabled: true
18
+ EnforcedStyle: double_quotes
19
+
20
+ Style/AccessModifierDeclarations:
21
+ Enabled: true
22
+ EnforcedStyle: inline
23
+
24
+ Style/Documentation:
25
+ Enabled: false
26
+
27
+ Layout/LineLength:
28
+ Max: 120
29
+
30
+ Metrics/AbcSize:
31
+ Enabled: false
32
+
33
+ Metrics/MethodLength:
34
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-06-02
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Yaw Boakye
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # κατηγορία
2
+
3
+ i argue that the default way to structure a rails application is bad, and
4
+ subsequently encourages bad design because components of a logical unit are
5
+ spread all over the place: in the `models` directory, the `services` (the
6
+ mechanism the rails community seems to have settled on for bundling executive
7
+ code together), sometimes `concerns`, etc.
8
+
9
+ look at [discourse][], my favorite rails project of all time, and it's almost
10
+ impossible to figure out the essence of the application. the entries in the
11
+ [`app/models`][dc_models] directory continues to grow with no end in sight. the
12
+ relationships between these models—who works with who and in what
13
+ capacity?—isn't immediately obvious.
14
+
15
+ categoria fixes this. it regroups data and executive code and separates them
16
+ along domain lines. it's similar in spirit to [phoenix's context][phxc]. the
17
+ point of departure is the following:
18
+
19
+ **a category/domain doesn't concern itself with the web part of the application.**
20
+
21
+ ### directory structure of a domain
22
+
23
+ domains live under `app/lib` of the rails application. internally, it is
24
+ organized into three main categories, represented by directories and ruby module
25
+ namespaces:
26
+
27
+ - `internal`: to be described
28
+ - `command`: to be described
29
+ - `data`: to be described
30
+
31
+ [discourse]: https:/github.com/discourse/discourse
32
+ [dc_models]: https://github.com/discourse/discourse/tree/main/app/models
33
+ [phxc]: https://hexdocs.pm/phoenix/contexts.html
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[test rubocop]
data/categoria.gemspec ADDED
@@ -0,0 +1,48 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "lib/categoria/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "categoria"
8
+ spec.version = Categoria::VERSION
9
+ spec.authors = ["Yaw Boakye"]
10
+ spec.email = ["wheresyaw@gmail.com"]
11
+
12
+ spec.summary = "categoria presents a set of generators for domain-driven development in rails"
13
+ spec.description = spec.summary
14
+ spec.homepage = "https://github.com/yawboakye/categoria"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = ">= 3.3"
17
+
18
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = spec.homepage
22
+ spec.metadata["changelog_uri"] = %(#{spec.homepage}/CHANGELOG.md)
23
+
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (File.expand_path(f) == __FILE__) ||
27
+ f.start_with?(*%w[bin/ test/ features/ .git .github appveyor Gemfile])
28
+ end
29
+ end
30
+
31
+ spec.require_paths = %(lib)
32
+
33
+ spec.add_runtime_dependency "sorbet-runtime", "~> 0.5"
34
+
35
+ spec.add_development_dependency "debug", "~> 1.9"
36
+ spec.add_development_dependency "minitest", "~> 5.16"
37
+ spec.add_development_dependency "rake", "~> 13.0"
38
+ spec.add_development_dependency "rubocop", "~> 1.21"
39
+ spec.add_development_dependency "rubocop-minitest", "~> 0.34"
40
+ spec.add_development_dependency "rubocop-rake", "~> 0.6"
41
+ spec.add_development_dependency "rubocop-sorbet", "~> 0.7"
42
+ spec.add_development_dependency "sorbet", "~> 0.5"
43
+ spec.add_development_dependency "spoom", "~> 1.2"
44
+ spec.add_development_dependency "tapioca", "~> 0.12"
45
+
46
+ spec.add_dependency "rails", "~> 7.0"
47
+ spec.add_dependency "zeitwerk", "~> 2.6"
48
+ end
@@ -0,0 +1,6 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ module Categoria
5
+ VERSION = "0.1.0-beta0"
6
+ end
data/lib/categoria.rb ADDED
@@ -0,0 +1,9 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "sorbet-runtime"
5
+
6
+ require_relative "categoria/version"
7
+
8
+ module Categoria
9
+ end
@@ -0,0 +1,8 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Categoria
5
+ module Generators
6
+ class CommandGenerator < ::Rails::Generators::NamedBase; end
7
+ end
8
+ end
@@ -0,0 +1,35 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Categoria
5
+ module Generators
6
+ class DomainGenerator < ::Rails::Generators::NamedBase
7
+ extend T::Sig
8
+
9
+ source_root File.expand_path("templates", __dir__)
10
+
11
+ def module_name = file_name.capitalize
12
+
13
+ sig { void }
14
+ def setup_new_domain
15
+ domain_directory_path = "#{Rails.root}/app/lib/#{file_name}"
16
+ %w[
17
+ internal/commands
18
+ internal/models
19
+ command
20
+ data
21
+ ].each do |component_path|
22
+ full_component_path = "#{domain_directory_path}/#{component_path}"
23
+
24
+ empty_directory full_component_path
25
+ create_file "#{full_component_path}/.keep"
26
+ end
27
+
28
+ create_file "#{domain_directory_path}/description.yml"
29
+ template \
30
+ "domain_module.rb.erb",
31
+ "#{domain_directory_path}.rb"
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,8 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Categoria
5
+ module Generators
6
+ class ModelGenerator < ::Rails::Generators::NamedBase; end
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module <%= Rails.application.class.module_parent %>
4
+ module <%= module_name %>
5
+ end
6
+ end
data/sig/categoria.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Categoria
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
data/sorbet/config ADDED
@@ -0,0 +1,4 @@
1
+ --dir
2
+ .
3
+ --ignore=tmp/
4
+ --ignore=vendor/
@@ -0,0 +1 @@
1
+ **/*.rbi linguist-vendored=true
@@ -0,0 +1,10 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This file was pulled from a central RBI files repository.
5
+ # Please run `bin/tapioca annotations` to update it.
6
+
7
+ class ActionMailer::Base
8
+ sig { params(headers: T.untyped, block: T.nilable(T.proc.params(arg0: ActionMailer::Collector).void)).returns(Mail::Message) }
9
+ def mail(headers = nil, &block); end
10
+ end