patternist 0.1.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 +7 -0
- data/.devcontainer/Dockerfile +4 -0
- data/.devcontainer/devcontainer.json +23 -0
- data/.rspec +3 -0
- data/.rspec_status +48 -0
- data/.rubocop.yml +17 -0
- data/.ruby-lsp/.gitignore +1 -0
- data/.ruby-lsp/Gemfile +6 -0
- data/.ruby-lsp/Gemfile.lock +198 -0
- data/.ruby-lsp/last_updated +1 -0
- data/.ruby-lsp/main_lockfile_hash +1 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +283 -0
- data/Rakefile +14 -0
- data/coverage/.last_run.json +5 -0
- data/coverage/.resultset.json +1041 -0
- data/coverage/.resultset.json.lock +0 -0
- data/coverage/assets/0.13.1/DataTables-1.10.20/images/sort_asc.png +0 -0
- data/coverage/assets/0.13.1/DataTables-1.10.20/images/sort_asc_disabled.png +0 -0
- data/coverage/assets/0.13.1/DataTables-1.10.20/images/sort_both.png +0 -0
- data/coverage/assets/0.13.1/DataTables-1.10.20/images/sort_desc.png +0 -0
- data/coverage/assets/0.13.1/DataTables-1.10.20/images/sort_desc_disabled.png +0 -0
- data/coverage/assets/0.13.1/application.css +1 -0
- data/coverage/assets/0.13.1/application.js +7 -0
- data/coverage/assets/0.13.1/colorbox/border.png +0 -0
- data/coverage/assets/0.13.1/colorbox/controls.png +0 -0
- data/coverage/assets/0.13.1/colorbox/loading.gif +0 -0
- data/coverage/assets/0.13.1/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.13.1/favicon_green.png +0 -0
- data/coverage/assets/0.13.1/favicon_red.png +0 -0
- data/coverage/assets/0.13.1/favicon_yellow.png +0 -0
- data/coverage/assets/0.13.1/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.13.1/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.13.1/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.13.1/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.13.1/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.13.1/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.13.1/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.13.1/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.13.1/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.13.1/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.13.1/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.13.1/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.13.1/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/assets/0.13.1/loading.gif +0 -0
- data/coverage/assets/0.13.1/magnify.png +0 -0
- data/coverage/index.html +11400 -0
- data/docs/PERFORMANCE_ASSESSMENT.md +199 -0
- data/docs/benchmark.rb +222 -0
- data/docs/performance_improvements.rb +81 -0
- data/docs/performance_recommendations.rb +186 -0
- data/lib/patternist/controller.rb +12 -0
- data/lib/patternist/controllers/actionpack/helpers.rb +89 -0
- data/lib/patternist/controllers/actionpack/response_handling.rb +61 -0
- data/lib/patternist/controllers/actionpack/restful.rb +93 -0
- data/lib/patternist/version.rb +5 -0
- data/lib/patternist.rb +10 -0
- data/sig/patternist.rbs +4 -0
- metadata +125 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 81b8e32837a2f163d36eff654d1a0a87f825239b4e281f37eac9f5d6c26d3619
|
|
4
|
+
data.tar.gz: 98b0d5ef6762f43d28276e2c3ffd48a00ba07fb05e88fe87c4afdf6dbb25b377
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9137ac174483c001c957e51527ca7e2b1642d2242230d68e92723e648ad5d8462adcae42316496dea1d1cb91f2c1e08cd34b3028fa565261a4c2bd2cdf4d2079
|
|
7
|
+
data.tar.gz: 32ae6a3c3c5138ba7fa9a1283aa07a90d75a416338dbd0e15a3c1a971bfeac1f3ff974b1e6c4bbf1ad127f72330c3444b6b492bb910cc4a3e0be3dc535b308ac
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
|
2
|
+
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby
|
|
3
|
+
{
|
|
4
|
+
"name": "patternist",
|
|
5
|
+
"build": {
|
|
6
|
+
// Path is relative to the devcontainer.json file.
|
|
7
|
+
"dockerfile": "Dockerfile",
|
|
8
|
+
}
|
|
9
|
+
// Features to add to the dev container. More info: https://containers.dev/features.
|
|
10
|
+
// "features": {},
|
|
11
|
+
|
|
12
|
+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
|
13
|
+
// "forwardPorts": [],
|
|
14
|
+
|
|
15
|
+
// Use 'postCreateCommand' to run commands after the container is created.
|
|
16
|
+
"postCreateCommand": "bin/setup",
|
|
17
|
+
|
|
18
|
+
// Configure tool-specific properties.
|
|
19
|
+
// "customizations": {},
|
|
20
|
+
|
|
21
|
+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
|
22
|
+
"remoteUser": "root"
|
|
23
|
+
}
|
data/.rspec
ADDED
data/.rspec_status
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
example_id | status | run_time |
|
|
2
|
+
---------------------------------------------------------------- | ------- | --------------- |
|
|
3
|
+
./spec/patternist/controller_spec.rb[1:1:1:1] | pending | 0 seconds |
|
|
4
|
+
./spec/patternist/controller_spec.rb[1:1:1:2] | pending | 0 seconds |
|
|
5
|
+
./spec/patternist/controller_spec.rb[1:1:2] | passed | 0.00616 seconds |
|
|
6
|
+
./spec/patternist/controller_spec.rb[1:2:1] | passed | 0.00128 seconds |
|
|
7
|
+
./spec/patternist/controller_spec.rb[1:2:2] | passed | 0.0006 seconds |
|
|
8
|
+
./spec/patternist/controller_spec.rb[1:2:3] | passed | 0.00025 seconds |
|
|
9
|
+
./spec/patternist/controller_spec.rb[1:2:4] | passed | 0.00018 seconds |
|
|
10
|
+
./spec/patternist/controller_spec.rb[1:2:5] | passed | 0.00091 seconds |
|
|
11
|
+
./spec/patternist/controller_spec.rb[1:3:1] | passed | 0.00027 seconds |
|
|
12
|
+
./spec/patternist/controller_spec.rb[1:4:1] | passed | 0.00021 seconds |
|
|
13
|
+
./spec/patternist/controller_spec.rb[1:5:1:1] | passed | 0.0015 seconds |
|
|
14
|
+
./spec/patternist/controller_spec.rb[1:5:1:2] | passed | 0.00066 seconds |
|
|
15
|
+
./spec/patternist/controller_spec.rb[1:5:2:1] | passed | 0.00018 seconds |
|
|
16
|
+
./spec/patternist/controller_spec.rb[1:5:3:1] | passed | 0.00045 seconds |
|
|
17
|
+
./spec/patternist/controller_spec.rb[1:6:1:1] | passed | 0.00055 seconds |
|
|
18
|
+
./spec/patternist/controller_spec.rb[1:6:1:2] | passed | 0.00066 seconds |
|
|
19
|
+
./spec/patternist/controller_spec.rb[1:6:2:1] | passed | 0.00015 seconds |
|
|
20
|
+
./spec/patternist/controller_spec.rb[1:7:1] | passed | 0.00034 seconds |
|
|
21
|
+
./spec/patternist/controller_spec.rb[1:7:2] | passed | 0.00181 seconds |
|
|
22
|
+
./spec/patternist/controller_spec.rb[1:7:3] | passed | 0.00035 seconds |
|
|
23
|
+
./spec/patternist/controller_spec.rb[1:7:4] | passed | 0.00035 seconds |
|
|
24
|
+
./spec/patternist/controller_spec.rb[1:7:5:1] | passed | 0.00034 seconds |
|
|
25
|
+
./spec/patternist/controller_spec.rb[1:8:1] | passed | 0.0001 seconds |
|
|
26
|
+
./spec/patternist/controller_spec.rb[1:9:1] | passed | 0.0001 seconds |
|
|
27
|
+
./spec/patternist/controllers/helpers_spec.rb[1:1:1:1] | passed | 0.00016 seconds |
|
|
28
|
+
./spec/patternist/controllers/helpers_spec.rb[1:1:1:2] | passed | 0.00016 seconds |
|
|
29
|
+
./spec/patternist/controllers/helpers_spec.rb[1:1:1:3] | passed | 0.00019 seconds |
|
|
30
|
+
./spec/patternist/controllers/helpers_spec.rb[1:1:1:4] | passed | 0.00018 seconds |
|
|
31
|
+
./spec/patternist/controllers/helpers_spec.rb[1:1:2:1] | passed | 0.00012 seconds |
|
|
32
|
+
./spec/patternist/controllers/helpers_spec.rb[1:1:2:2] | passed | 0.00021 seconds |
|
|
33
|
+
./spec/patternist/controllers/helpers_spec.rb[1:2:1:1] | passed | 0.0001 seconds |
|
|
34
|
+
./spec/patternist/controllers/helpers_spec.rb[1:2:1:2] | passed | 0.00013 seconds |
|
|
35
|
+
./spec/patternist/controllers/helpers_spec.rb[1:2:2:1] | passed | 0.00009 seconds |
|
|
36
|
+
./spec/patternist/controllers/helpers_spec.rb[1:2:3:1] | passed | 0.0001 seconds |
|
|
37
|
+
./spec/patternist/controllers/helpers_spec.rb[1:2:3:2] | passed | 0.00013 seconds |
|
|
38
|
+
./spec/patternist/controllers/helpers_spec.rb[1:2:4:1] | passed | 0.00013 seconds |
|
|
39
|
+
./spec/patternist/controllers/helpers_spec.rb[1:2:5:1] | passed | 0.00009 seconds |
|
|
40
|
+
./spec/patternist/controllers/helpers_spec.rb[1:2:6:1] | passed | 0.00009 seconds |
|
|
41
|
+
./spec/patternist/controllers/helpers_spec.rb[1:2:6:2] | passed | 0.0001 seconds |
|
|
42
|
+
./spec/patternist/controllers/response_handling_spec.rb[1:1:1:1] | passed | 0.00025 seconds |
|
|
43
|
+
./spec/patternist/controllers/response_handling_spec.rb[1:1:1:2] | passed | 0.0002 seconds |
|
|
44
|
+
./spec/patternist/controllers/response_handling_spec.rb[1:1:2:1] | passed | 0.00042 seconds |
|
|
45
|
+
./spec/patternist/controllers/response_handling_spec.rb[1:1:2:2] | passed | 0.00021 seconds |
|
|
46
|
+
./spec/patternist/controllers/response_handling_spec.rb[1:1:2:3] | passed | 0.00022 seconds |
|
|
47
|
+
./spec/patternist/controllers/response_handling_spec.rb[1:1:2:4] | passed | 0.00019 seconds |
|
|
48
|
+
./spec/patternist_spec.rb[1:1] | passed | 0.00003 seconds |
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
plugins:
|
|
2
|
+
- rubocop-rspec
|
|
3
|
+
|
|
4
|
+
AllCops:
|
|
5
|
+
TargetRubyVersion: 3.1
|
|
6
|
+
SuggestExtensions: false
|
|
7
|
+
Exclude:
|
|
8
|
+
- 'docs/**/*'
|
|
9
|
+
|
|
10
|
+
RSpec/ExampleLength:
|
|
11
|
+
Max: 15
|
|
12
|
+
|
|
13
|
+
RSpec/AnyInstance:
|
|
14
|
+
Enabled: false
|
|
15
|
+
|
|
16
|
+
RSpec/SpecFilePathFormat:
|
|
17
|
+
Enabled: false
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*
|
data/.ruby-lsp/Gemfile
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# This custom gemfile is automatically generated by the Ruby LSP.
|
|
2
|
+
# It should be automatically git ignored, but in any case: do not commit it to your repository.
|
|
3
|
+
|
|
4
|
+
eval_gemfile(File.expand_path("../Gemfile", __dir__))
|
|
5
|
+
gem "ruby-lsp", require: false, group: :development
|
|
6
|
+
gem "debug", require: false, group: :development, platforms: :mri
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: /workspaces/patternist
|
|
3
|
+
specs:
|
|
4
|
+
patternist (0.1.0.pre.rc)
|
|
5
|
+
actionpack (>= 4.0, < 9.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
actionpack (8.0.2)
|
|
11
|
+
actionview (= 8.0.2)
|
|
12
|
+
activesupport (= 8.0.2)
|
|
13
|
+
nokogiri (>= 1.8.5)
|
|
14
|
+
rack (>= 2.2.4)
|
|
15
|
+
rack-session (>= 1.0.1)
|
|
16
|
+
rack-test (>= 0.6.3)
|
|
17
|
+
rails-dom-testing (~> 2.2)
|
|
18
|
+
rails-html-sanitizer (~> 1.6)
|
|
19
|
+
useragent (~> 0.16)
|
|
20
|
+
actionview (8.0.2)
|
|
21
|
+
activesupport (= 8.0.2)
|
|
22
|
+
builder (~> 3.1)
|
|
23
|
+
erubi (~> 1.11)
|
|
24
|
+
rails-dom-testing (~> 2.2)
|
|
25
|
+
rails-html-sanitizer (~> 1.6)
|
|
26
|
+
activesupport (8.0.2)
|
|
27
|
+
base64
|
|
28
|
+
benchmark (>= 0.3)
|
|
29
|
+
bigdecimal
|
|
30
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
31
|
+
connection_pool (>= 2.2.5)
|
|
32
|
+
drb
|
|
33
|
+
i18n (>= 1.6, < 2)
|
|
34
|
+
logger (>= 1.4.2)
|
|
35
|
+
minitest (>= 5.1)
|
|
36
|
+
securerandom (>= 0.3)
|
|
37
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
38
|
+
uri (>= 0.13.1)
|
|
39
|
+
ast (2.4.3)
|
|
40
|
+
base64 (0.3.0)
|
|
41
|
+
benchmark (0.4.1)
|
|
42
|
+
bigdecimal (3.2.2)
|
|
43
|
+
builder (3.3.0)
|
|
44
|
+
concurrent-ruby (1.3.5)
|
|
45
|
+
connection_pool (2.5.3)
|
|
46
|
+
crass (1.0.6)
|
|
47
|
+
date (3.4.1)
|
|
48
|
+
debug (1.11.0)
|
|
49
|
+
irb (~> 1.10)
|
|
50
|
+
reline (>= 0.3.8)
|
|
51
|
+
diff-lcs (1.6.2)
|
|
52
|
+
docile (1.4.1)
|
|
53
|
+
drb (2.2.3)
|
|
54
|
+
erb (5.0.1)
|
|
55
|
+
erubi (1.13.1)
|
|
56
|
+
i18n (1.14.7)
|
|
57
|
+
concurrent-ruby (~> 1.0)
|
|
58
|
+
io-console (0.8.0)
|
|
59
|
+
irb (1.15.2)
|
|
60
|
+
pp (>= 0.6.0)
|
|
61
|
+
rdoc (>= 4.0.0)
|
|
62
|
+
reline (>= 0.4.2)
|
|
63
|
+
json (2.12.2)
|
|
64
|
+
language_server-protocol (3.17.0.5)
|
|
65
|
+
lint_roller (1.1.0)
|
|
66
|
+
logger (1.7.0)
|
|
67
|
+
loofah (2.24.1)
|
|
68
|
+
crass (~> 1.0.2)
|
|
69
|
+
nokogiri (>= 1.12.0)
|
|
70
|
+
minitest (5.25.5)
|
|
71
|
+
nokogiri (1.18.8-aarch64-linux-gnu)
|
|
72
|
+
racc (~> 1.4)
|
|
73
|
+
nokogiri (1.18.8-aarch64-linux-musl)
|
|
74
|
+
racc (~> 1.4)
|
|
75
|
+
nokogiri (1.18.8-arm-linux-gnu)
|
|
76
|
+
racc (~> 1.4)
|
|
77
|
+
nokogiri (1.18.8-arm-linux-musl)
|
|
78
|
+
racc (~> 1.4)
|
|
79
|
+
nokogiri (1.18.8-arm64-darwin)
|
|
80
|
+
racc (~> 1.4)
|
|
81
|
+
nokogiri (1.18.8-x86_64-darwin)
|
|
82
|
+
racc (~> 1.4)
|
|
83
|
+
nokogiri (1.18.8-x86_64-linux-gnu)
|
|
84
|
+
racc (~> 1.4)
|
|
85
|
+
nokogiri (1.18.8-x86_64-linux-musl)
|
|
86
|
+
racc (~> 1.4)
|
|
87
|
+
parallel (1.27.0)
|
|
88
|
+
parser (3.3.8.0)
|
|
89
|
+
ast (~> 2.4.1)
|
|
90
|
+
racc
|
|
91
|
+
pp (0.6.2)
|
|
92
|
+
prettyprint
|
|
93
|
+
prettyprint (0.2.0)
|
|
94
|
+
prism (1.4.0)
|
|
95
|
+
psych (5.2.6)
|
|
96
|
+
date
|
|
97
|
+
stringio
|
|
98
|
+
racc (1.8.1)
|
|
99
|
+
rack (3.1.16)
|
|
100
|
+
rack-session (2.1.1)
|
|
101
|
+
base64 (>= 0.1.0)
|
|
102
|
+
rack (>= 3.0.0)
|
|
103
|
+
rack-test (2.2.0)
|
|
104
|
+
rack (>= 1.3)
|
|
105
|
+
rails-dom-testing (2.3.0)
|
|
106
|
+
activesupport (>= 5.0.0)
|
|
107
|
+
minitest
|
|
108
|
+
nokogiri (>= 1.6)
|
|
109
|
+
rails-html-sanitizer (1.6.2)
|
|
110
|
+
loofah (~> 2.21)
|
|
111
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
|
112
|
+
rainbow (3.1.1)
|
|
113
|
+
rake (13.3.0)
|
|
114
|
+
rbs (3.9.4)
|
|
115
|
+
logger
|
|
116
|
+
rdoc (6.14.2)
|
|
117
|
+
erb
|
|
118
|
+
psych (>= 4.0.0)
|
|
119
|
+
regexp_parser (2.10.0)
|
|
120
|
+
reline (0.6.1)
|
|
121
|
+
io-console (~> 0.5)
|
|
122
|
+
rspec (3.13.1)
|
|
123
|
+
rspec-core (~> 3.13.0)
|
|
124
|
+
rspec-expectations (~> 3.13.0)
|
|
125
|
+
rspec-mocks (~> 3.13.0)
|
|
126
|
+
rspec-core (3.13.5)
|
|
127
|
+
rspec-support (~> 3.13.0)
|
|
128
|
+
rspec-expectations (3.13.5)
|
|
129
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
130
|
+
rspec-support (~> 3.13.0)
|
|
131
|
+
rspec-mocks (3.13.5)
|
|
132
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
133
|
+
rspec-support (~> 3.13.0)
|
|
134
|
+
rspec-support (3.13.4)
|
|
135
|
+
rubocop (1.77.0)
|
|
136
|
+
json (~> 2.3)
|
|
137
|
+
language_server-protocol (~> 3.17.0.2)
|
|
138
|
+
lint_roller (~> 1.1.0)
|
|
139
|
+
parallel (~> 1.10)
|
|
140
|
+
parser (>= 3.3.0.2)
|
|
141
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
142
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
143
|
+
rubocop-ast (>= 1.45.1, < 2.0)
|
|
144
|
+
ruby-progressbar (~> 1.7)
|
|
145
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
146
|
+
rubocop-ast (1.45.1)
|
|
147
|
+
parser (>= 3.3.7.2)
|
|
148
|
+
prism (~> 1.4)
|
|
149
|
+
rubocop-rake (0.7.1)
|
|
150
|
+
lint_roller (~> 1.1)
|
|
151
|
+
rubocop (>= 1.72.1)
|
|
152
|
+
rubocop-rspec (3.6.0)
|
|
153
|
+
lint_roller (~> 1.1)
|
|
154
|
+
rubocop (~> 1.72, >= 1.72.1)
|
|
155
|
+
ruby-lsp (0.25.0)
|
|
156
|
+
language_server-protocol (~> 3.17.0)
|
|
157
|
+
prism (>= 1.2, < 2.0)
|
|
158
|
+
rbs (>= 3, < 5)
|
|
159
|
+
ruby-progressbar (1.13.0)
|
|
160
|
+
securerandom (0.4.1)
|
|
161
|
+
simplecov (0.22.0)
|
|
162
|
+
docile (~> 1.1)
|
|
163
|
+
simplecov-html (~> 0.11)
|
|
164
|
+
simplecov_json_formatter (~> 0.1)
|
|
165
|
+
simplecov-html (0.13.1)
|
|
166
|
+
simplecov_json_formatter (0.1.4)
|
|
167
|
+
stringio (3.1.7)
|
|
168
|
+
tzinfo (2.0.6)
|
|
169
|
+
concurrent-ruby (~> 1.0)
|
|
170
|
+
unicode-display_width (3.1.4)
|
|
171
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
|
172
|
+
unicode-emoji (4.0.4)
|
|
173
|
+
uri (1.0.3)
|
|
174
|
+
useragent (0.16.11)
|
|
175
|
+
|
|
176
|
+
PLATFORMS
|
|
177
|
+
aarch64-linux-gnu
|
|
178
|
+
aarch64-linux-musl
|
|
179
|
+
arm-linux-gnu
|
|
180
|
+
arm-linux-musl
|
|
181
|
+
arm64-darwin
|
|
182
|
+
x86_64-darwin
|
|
183
|
+
x86_64-linux-gnu
|
|
184
|
+
x86_64-linux-musl
|
|
185
|
+
|
|
186
|
+
DEPENDENCIES
|
|
187
|
+
debug
|
|
188
|
+
patternist!
|
|
189
|
+
rake
|
|
190
|
+
rspec
|
|
191
|
+
rubocop
|
|
192
|
+
rubocop-rake
|
|
193
|
+
rubocop-rspec
|
|
194
|
+
ruby-lsp
|
|
195
|
+
simplecov
|
|
196
|
+
|
|
197
|
+
BUNDLED WITH
|
|
198
|
+
2.6.2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2025-07-11T04:32:34+00:00
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ebc3eed610a4f36d86479c081a74cbae48535879e673558892234b3e12faf2d1
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 TODO: Write your name
|
|
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,283 @@
|
|
|
1
|
+
# Patternist
|
|
2
|
+
|
|
3
|
+
[](https://github.com/xavius-rb/patternist/actions/workflows/main.yml)
|
|
4
|
+
[](https://badge.fury.io/rb/patternist)
|
|
5
|
+
|
|
6
|
+
Patternist is a Ruby gem that provides reusable utilities and patterns for Ruby and Rails applications. It offers a collection of modules designed to reduce boilerplate code and standardize and protect common patterns.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Controller Helpers**: Automatic resource inference and naming conventions
|
|
11
|
+
- **RESTful Actions**: Complete CRUD operations with minimal configuration
|
|
12
|
+
- **Response Handling**: Unified response formatting for HTML and JSON
|
|
13
|
+
- **Rails Integration**: Seamless integration with Rails applications
|
|
14
|
+
- **Error Handling**: Comprehensive error handling with custom exceptions
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Add this line to your application's Gemfile:
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
gem 'patternist'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
And then execute:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
bundle install
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or install it yourself as:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
gem install patternist
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
### RESTful Controller
|
|
39
|
+
|
|
40
|
+
The `Patternist::Controller` module provides complete CRUD operations:
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
class PostsController < ApplicationController
|
|
44
|
+
include Patternist::Controller
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def resource_params
|
|
49
|
+
params.require(:post).permit(:title, :body)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This automatically provides all standard RESTful actions:
|
|
55
|
+
- `index` - Lists all resources
|
|
56
|
+
- `show` - Shows a single resource
|
|
57
|
+
- `new` - Prepares a new resource
|
|
58
|
+
- `create` - Creates a new resource
|
|
59
|
+
- `edit` - Prepares a resource for editing
|
|
60
|
+
- `update` - Updates an existing resource
|
|
61
|
+
- `destroy` - Destroys a resource
|
|
62
|
+
|
|
63
|
+
### Controller Helpers
|
|
64
|
+
|
|
65
|
+
The `Patternist::Controllers::ActionPack::Helpers` module provides automatic resource inference and helper methods for controllers:
|
|
66
|
+
|
|
67
|
+
```ruby
|
|
68
|
+
class PostsController < ApplicationController
|
|
69
|
+
include Patternist::Controllers::ActionPack::Helpers
|
|
70
|
+
|
|
71
|
+
def index
|
|
72
|
+
# Automatically infers @posts from controller name
|
|
73
|
+
set_collection_instance(Post.all)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def show
|
|
77
|
+
# Automatically infers @post from controller name
|
|
78
|
+
set_resource_instance(Post.find(params[:id]))
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Helper Methods
|
|
84
|
+
|
|
85
|
+
The helpers module provides several useful methods:
|
|
86
|
+
|
|
87
|
+
- `resource_class` - Inferred model class (e.g., `Post` for `PostsController`)
|
|
88
|
+
- `resource_name` - Underscored resource name (e.g., `"post"`)
|
|
89
|
+
- `resource_class_name` - Human-readable resource name (e.g., `"Post"`)
|
|
90
|
+
- `collection_name` - Pluralized resource name (e.g., `"posts"`)
|
|
91
|
+
- `instance_variable_name` - Instance variable name for a resource
|
|
92
|
+
- `resource` - Get the resource instance variable
|
|
93
|
+
- `id_param` - Get the ID parameter from params
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
### Response Handling
|
|
97
|
+
|
|
98
|
+
The `Patternist::Controllers::ActionPack::ResponseHandling` module provides unified response formatting:
|
|
99
|
+
|
|
100
|
+
```ruby
|
|
101
|
+
class PostsController < ApplicationController
|
|
102
|
+
include Patternist::Controllers::ActionPack::ResponseHandling
|
|
103
|
+
|
|
104
|
+
def create
|
|
105
|
+
@post = Post.new(post_params)
|
|
106
|
+
|
|
107
|
+
format_response(@post,
|
|
108
|
+
notice: "Post created successfully",
|
|
109
|
+
status: :created,
|
|
110
|
+
on_error_render: :new) do
|
|
111
|
+
@post.save
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### Custom Response Formats
|
|
118
|
+
|
|
119
|
+
You can customize response handling with custom format handlers:
|
|
120
|
+
|
|
121
|
+
```ruby
|
|
122
|
+
format_response(@post,
|
|
123
|
+
notice: "Success",
|
|
124
|
+
status: :ok,
|
|
125
|
+
on_error_render: :edit,
|
|
126
|
+
formats: {
|
|
127
|
+
html: -> { redirect_to custom_path },
|
|
128
|
+
json: -> { render json: custom_serializer(@post) },
|
|
129
|
+
on_error_html: -> { render :custom_error },
|
|
130
|
+
on_error_json: -> { render json: { error: "Custom error" } }
|
|
131
|
+
}) do
|
|
132
|
+
@post.update(post_params)
|
|
133
|
+
end
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
## API Reference
|
|
138
|
+
|
|
139
|
+
### Patternist::Controllers::ActionPack::Helpers
|
|
140
|
+
|
|
141
|
+
Provides helper methods for resource handling and naming conventions.
|
|
142
|
+
|
|
143
|
+
**Class Methods:**
|
|
144
|
+
- `resource_class` - Returns the inferred resource class
|
|
145
|
+
- `resource_name` - Returns the underscored resource name
|
|
146
|
+
|
|
147
|
+
**Instance Methods:**
|
|
148
|
+
- `resource_class` - Returns the resource class
|
|
149
|
+
- `resource_name` - Returns the resource name
|
|
150
|
+
- `resource_class_name` - Returns the human-readable resource name
|
|
151
|
+
- `collection_name` - Returns the pluralized resource name
|
|
152
|
+
- `instance_variable_name(name)` - Returns instance variable name
|
|
153
|
+
- `resource` - Returns the resource instance
|
|
154
|
+
- `id_param` - Returns the ID parameter
|
|
155
|
+
- `set_collection_instance(value)` - Sets the collection instance variable
|
|
156
|
+
- `set_resource_instance(value)` - Sets the resource instance variable
|
|
157
|
+
|
|
158
|
+
### Patternist::Controllers::ActionPack::Restful
|
|
159
|
+
|
|
160
|
+
Provides standard RESTful actions for controllers.
|
|
161
|
+
|
|
162
|
+
**Actions:**
|
|
163
|
+
- `index` - Lists all resources
|
|
164
|
+
- `show` - Shows a single resource
|
|
165
|
+
- `new` - Prepares a new resource
|
|
166
|
+
- `create` - Creates a new resource
|
|
167
|
+
- `edit` - Prepares a resource for editing
|
|
168
|
+
- `update` - Updates an existing resource
|
|
169
|
+
- `destroy` - Destroys a resource
|
|
170
|
+
|
|
171
|
+
**Required Methods:**
|
|
172
|
+
- `resource_params` - Must be implemented to define permitted parameters
|
|
173
|
+
|
|
174
|
+
### Patternist::Controllers::ActionPack::ResponseHandling
|
|
175
|
+
|
|
176
|
+
Provides unified response formatting for different formats.
|
|
177
|
+
|
|
178
|
+
**Methods:**
|
|
179
|
+
- `format_response(resource, notice:, status:, on_error_render:, formats: {}, &block)` - Handles response formatting
|
|
180
|
+
|
|
181
|
+
## Requirements
|
|
182
|
+
|
|
183
|
+
- Ruby >= 3.1.0
|
|
184
|
+
- ActionPack >= 4.0 (for Rails integration)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
## Examples
|
|
188
|
+
|
|
189
|
+
### Basic Usage with All Features
|
|
190
|
+
|
|
191
|
+
```ruby
|
|
192
|
+
class PostsController < ApplicationController
|
|
193
|
+
include Patternist::Controller
|
|
194
|
+
|
|
195
|
+
# All RESTful actions are automatically provided
|
|
196
|
+
|
|
197
|
+
private
|
|
198
|
+
|
|
199
|
+
def resource_params
|
|
200
|
+
params.require(:post).permit(:title, :body, :published)
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Optional: Override collection for custom scoping
|
|
204
|
+
def collection
|
|
205
|
+
current_user.posts.published.includes(:author)
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Custom Namespace Handling
|
|
211
|
+
|
|
212
|
+
```ruby
|
|
213
|
+
class Admin::PostsController < ApplicationController
|
|
214
|
+
include Patternist::Controller
|
|
215
|
+
|
|
216
|
+
# Automatically infers Post class from Admin::PostsController
|
|
217
|
+
|
|
218
|
+
private
|
|
219
|
+
|
|
220
|
+
def resource_params
|
|
221
|
+
params.require(:post).permit(:title, :body, :featured)
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### API Controller with Custom Responses
|
|
227
|
+
|
|
228
|
+
```ruby
|
|
229
|
+
class Api::V1::PostsController < ApplicationController
|
|
230
|
+
include Patternist::Controller
|
|
231
|
+
|
|
232
|
+
def create
|
|
233
|
+
set_resource_instance(resource_class.new(resource_params))
|
|
234
|
+
|
|
235
|
+
format_response(resource,
|
|
236
|
+
notice: "Post created successfully",
|
|
237
|
+
status: :created,
|
|
238
|
+
on_error_render: :new,
|
|
239
|
+
formats: {
|
|
240
|
+
json: -> { render json: resource, serializer: PostSerializer },
|
|
241
|
+
error_json: -> { render json: { errors: resource.errors.full_messages } }
|
|
242
|
+
}) do
|
|
243
|
+
resource.save
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
private
|
|
248
|
+
|
|
249
|
+
def resource_params
|
|
250
|
+
params.require(:post).permit(:title, :body)
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Development
|
|
256
|
+
|
|
257
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
258
|
+
|
|
259
|
+
To release a new version, update the version number in `version.rb`, update the CHANGELOG.md, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
260
|
+
|
|
261
|
+
### Testing
|
|
262
|
+
|
|
263
|
+
Run the test suite with:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
bundle exec rspec
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Code Quality
|
|
270
|
+
|
|
271
|
+
The project follows standard Ruby conventions and uses RSpec for testing.
|
|
272
|
+
|
|
273
|
+
## Contributing
|
|
274
|
+
|
|
275
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/xavius-rb/patternist. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/xavius-rb/patternist/blob/main/CODE_OF_CONDUCT.md).
|
|
276
|
+
|
|
277
|
+
## License
|
|
278
|
+
|
|
279
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
280
|
+
|
|
281
|
+
## Code of Conduct
|
|
282
|
+
|
|
283
|
+
Everyone interacting in the Patternist project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/xavius-rb/patternist/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
require 'rspec/core/rake_task'
|
|
5
|
+
|
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
7
|
+
|
|
8
|
+
require 'rubocop/rake_task'
|
|
9
|
+
|
|
10
|
+
RuboCop::RakeTask.new do |task|
|
|
11
|
+
task.plugins << %w[rubocop-rspec]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
task default: %i[spec rubocop]
|