hanamismith 2.3.0 → 3.0.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/hanamismith.gemspec +2 -2
- data/lib/hanamismith/builders/bundler.rb +20 -18
- data/lib/hanamismith/builders/caliber.rb +20 -9
- data/lib/hanamismith/builders/core.rb +4 -0
- data/lib/hanamismith/builders/providers/logger.rb +2 -6
- data/lib/hanamismith/builders/rake/configuration.rb +11 -2
- data/lib/hanamismith/builders/reek.rb +15 -6
- data/lib/hanamismith/templates/%project_name%/app/mailer.rb.erb +9 -0
- data/lib/hanamismith/templates/%project_name%/app/providers/logger.rb.erb +18 -1
- data/lib/hanamismith/templates/%project_name%/config/app.rb.erb +0 -16
- data/lib/hanamismith/templates/%project_name%/config/initializers/universal_logger_patch.rb.erb +24 -0
- data/lib/hanamismith/templates/%project_name%/config/puma.rb.erb +3 -4
- data/lib/hanamismith/templates/%project_name%/package.json.erb +5 -2
- data/lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb +9 -1
- data.tar.gz.sig +0 -0
- metadata +6 -8
- metadata.gz.sig +0 -0
- data/lib/hanamismith/templates/%project_name%/app/aspects/logging/rack_adapter.rb.erb +0 -21
- data/lib/hanamismith/templates/%project_name%/config/initializers/rack_logger_patch.rb.erb +0 -21
- data/lib/hanamismith/templates/%project_name%/config/initializers/sql_logger_patch.rb.erb +0 -13
- data/lib/hanamismith/templates/%project_name%/spec/app/aspects/logging/rack_adapter_spec.rb.erb +0 -34
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f0c8864aa328874754512be314522a523aa831bdbae209bafeec22a5e31bd0bb
|
|
4
|
+
data.tar.gz: 899e32fcfdced1478fc8b08f5e0a00758d300992417bcc723f91439f21a497e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bdad438b6b4e9e46200ee87866f94e5f631cc35c41a2e018b517871a5e7cab61320063ac30936ea7e298345ac38eeaf1e1d4bc34a8ee8fa09e91b8d403e319fa
|
|
7
|
+
data.tar.gz: 5a646edeefdaae29dcb4cf5cb260e3f43fc0c9b95fc35dc74b32859836848b9844953709644c36c6de3bae374a646b07e63daba033e7a6f7fd4625e4cf00987d
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/hanamismith.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
4
|
spec.name = "hanamismith"
|
|
5
|
-
spec.version = "
|
|
5
|
+
spec.version = "3.0.0"
|
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
|
8
8
|
spec.homepage = "https://alchemists.io/projects/hanamismith"
|
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
|
32
32
|
spec.add_dependency "htmx", "~> 3.0"
|
|
33
33
|
spec.add_dependency "infusible", "~> 5.0"
|
|
34
34
|
spec.add_dependency "refinements", "~> 14.0"
|
|
35
|
-
spec.add_dependency "rubysmith", "~>
|
|
35
|
+
spec.add_dependency "rubysmith", "~> 10.0"
|
|
36
36
|
spec.add_dependency "runcom", "~> 13.0"
|
|
37
37
|
spec.add_dependency "sod", "~> 2.0"
|
|
38
38
|
spec.add_dependency "spek", "~> 5.0"
|
|
@@ -35,35 +35,37 @@ module Hanamismith
|
|
|
35
35
|
|
|
36
36
|
def insert_hanami
|
|
37
37
|
with_template.insert_after "source", <<~CONTENT.strip
|
|
38
|
-
gem "hanami", "~>
|
|
39
|
-
gem "hanami-
|
|
40
|
-
gem "hanami-
|
|
41
|
-
gem "hanami-db", "~>
|
|
42
|
-
gem "hanami-
|
|
43
|
-
gem "hanami-
|
|
44
|
-
gem "hanami-view", "~>
|
|
38
|
+
gem "hanami", "~> 3.0"
|
|
39
|
+
gem "hanami-action", "~> 3.0"
|
|
40
|
+
gem "hanami-assets", "~> 3.0"
|
|
41
|
+
gem "hanami-db", "~> 3.0"
|
|
42
|
+
gem "hanami-mailer", "~> 3.0"
|
|
43
|
+
gem "hanami-router", "~> 3.0"
|
|
44
|
+
gem "hanami-view", "~> 3.0"
|
|
45
45
|
CONTENT
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def insert_main
|
|
49
49
|
with_template.insert_after "source", <<~CONTENT
|
|
50
|
-
gem "
|
|
50
|
+
gem "cogger", "~> 2.4"
|
|
51
|
+
gem "core", "~> 3.2"
|
|
52
|
+
gem "dry-schema", "~> 1.16"
|
|
51
53
|
gem "dry-types", "~> 1.9"
|
|
52
54
|
gem "dry-validation", "~> 1.11"
|
|
53
|
-
gem "htmx", "~> 3.
|
|
54
|
-
gem "
|
|
55
|
-
gem "puma", "~>
|
|
56
|
-
gem "rack-attack", "~> 6.
|
|
55
|
+
gem "htmx", "~> 3.2"
|
|
56
|
+
gem "i18n", "~> 1.15"
|
|
57
|
+
gem "puma", "~> 8.0"
|
|
58
|
+
gem "rack-attack", "~> 6.8"
|
|
57
59
|
CONTENT
|
|
58
60
|
end
|
|
59
61
|
|
|
60
62
|
def insert_persistence
|
|
61
63
|
with_template.insert_after "source", <<~CONTENT
|
|
62
64
|
|
|
63
|
-
gem "pg", "~> 1.
|
|
65
|
+
gem "pg", "~> 1.6", force_ruby_platform: true
|
|
64
66
|
gem "rom", "~> 5.4"
|
|
65
67
|
gem "rom-sql", "~> 3.7"
|
|
66
|
-
gem "sequel", "~> 5.
|
|
68
|
+
gem "sequel", "~> 5.106"
|
|
67
69
|
CONTENT
|
|
68
70
|
end
|
|
69
71
|
|
|
@@ -75,7 +77,7 @@ module Hanamismith
|
|
|
75
77
|
with_template.insert_before(/group :development/, <<~CONTENT)
|
|
76
78
|
|
|
77
79
|
group :development, :test do
|
|
78
|
-
gem "dotenv", "~> 3.
|
|
80
|
+
gem "dotenv", "~> 3.2"
|
|
79
81
|
end
|
|
80
82
|
|
|
81
83
|
CONTENT
|
|
@@ -83,8 +85,8 @@ module Hanamismith
|
|
|
83
85
|
|
|
84
86
|
def insert_development
|
|
85
87
|
with_template.insert_after(/group :development do/, <<~CONTENT.gsub("gem", " gem"))
|
|
86
|
-
gem "hanami-webconsole", "~>
|
|
87
|
-
gem "localhost", "~> 1.
|
|
88
|
+
gem "hanami-webconsole", "~> 3.0"
|
|
89
|
+
gem "localhost", "~> 1.8"
|
|
88
90
|
CONTENT
|
|
89
91
|
end
|
|
90
92
|
|
|
@@ -92,7 +94,7 @@ module Hanamismith
|
|
|
92
94
|
with_template.insert_after(/group :test/, <<~CONTENT.gsub("gem", " gem"))
|
|
93
95
|
gem "capybara", "~> 3.40"
|
|
94
96
|
gem "capybara-validate_html5", "~> 2.1"
|
|
95
|
-
gem "cuprite", "~> 0.
|
|
97
|
+
gem "cuprite", "~> 0.17"
|
|
96
98
|
gem "database_cleaner-sequel", "~> 2.0"
|
|
97
99
|
gem "launchy", "~> 3.1"
|
|
98
100
|
gem "rack-test", "~> 2.2"
|
|
@@ -12,17 +12,28 @@ module Hanamismith
|
|
|
12
12
|
return false unless settings.build_caliber
|
|
13
13
|
|
|
14
14
|
super
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.append("\nplugins: rubocop-sequel\n\n")
|
|
18
|
-
.append(<<~CONTENT)
|
|
19
|
-
RSpec/SpecFilePathFormat:
|
|
20
|
-
CustomTransform:
|
|
21
|
-
#{settings.project_namespaced_class}: ""
|
|
22
|
-
CONTENT
|
|
23
|
-
|
|
15
|
+
with_template.append "\nplugins: rubocop-sequel\n\n"
|
|
16
|
+
add_configuration
|
|
24
17
|
true
|
|
25
18
|
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def add_configuration
|
|
23
|
+
with_template.append <<~CONTENT
|
|
24
|
+
Metrics/MethodLength:
|
|
25
|
+
Exclude:
|
|
26
|
+
- config/initializers/universal_logger_patch.rb
|
|
27
|
+
RSpec/SpecFilePathFormat:
|
|
28
|
+
CustomTransform:
|
|
29
|
+
#{settings.project_namespaced_class}: ""
|
|
30
|
+
CONTENT
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def with_template
|
|
34
|
+
path = "%project_name%/.config/rubocop/config.yml.erb"
|
|
35
|
+
builder.call settings.with(template_path: path)
|
|
36
|
+
end
|
|
26
37
|
end
|
|
27
38
|
end
|
|
28
39
|
end
|
|
@@ -31,6 +31,10 @@ module Hanamismith
|
|
|
31
31
|
builder.call(settings.with(template_path: "%project_name%/app/action.rb.erb")).render
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
def add_mailer
|
|
35
|
+
builder.call(settings.with(template_path: "%project_name%/app/mailer.rb.erb")).render
|
|
36
|
+
end
|
|
37
|
+
|
|
34
38
|
def add_view
|
|
35
39
|
builder.call(settings.with(template_path: "%project_name%/app/view.rb.erb")).render
|
|
36
40
|
end
|
|
@@ -22,10 +22,7 @@ module Hanamismith
|
|
|
22
22
|
%project_name%/app/providers/logger.rb.erb
|
|
23
23
|
%project_name%/spec/app/providers/logger_spec.rb.erb
|
|
24
24
|
%project_name%/config/providers/logger.rb.erb
|
|
25
|
-
%project_name%/
|
|
26
|
-
%project_name%/spec/app/aspects/logging/rack_adapter_spec.rb.erb
|
|
27
|
-
%project_name%/config/initializers/rack_logger_patch.rb.erb
|
|
28
|
-
%project_name%/config/initializers/sql_logger_patch.rb.erb
|
|
25
|
+
%project_name%/config/initializers/universal_logger_patch.rb.erb
|
|
29
26
|
].each { build it }
|
|
30
27
|
end
|
|
31
28
|
|
|
@@ -37,8 +34,7 @@ module Hanamismith
|
|
|
37
34
|
/require/,
|
|
38
35
|
<<~REQUIRES
|
|
39
36
|
|
|
40
|
-
require_relative "initializers/
|
|
41
|
-
require_relative "initializers/sql_logger_patch"
|
|
37
|
+
require_relative "initializers/universal_logger_patch"
|
|
42
38
|
REQUIRES
|
|
43
39
|
)
|
|
44
40
|
end
|
|
@@ -13,12 +13,21 @@ module Hanamismith
|
|
|
13
13
|
return false unless settings.build_rake
|
|
14
14
|
|
|
15
15
|
super
|
|
16
|
+
process
|
|
17
|
+
true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def process
|
|
16
23
|
builder.call(settings.with(template_path: "%project_name%/Rakefile.erb"))
|
|
17
24
|
.render
|
|
25
|
+
.replace(
|
|
26
|
+
"Reek::Rake::Task.new",
|
|
27
|
+
%(Reek::Rake::Task.new { it.source_files = "{app,config,lib,slices}/**/*.rb" })
|
|
28
|
+
)
|
|
18
29
|
.insert_after(%r(bundler/setup), %(require "hanami/rake_tasks"))
|
|
19
30
|
.insert_after(/RuboCop::RakeTask/, %(\nRake.add_rakelib "lib/tasks"\n))
|
|
20
|
-
|
|
21
|
-
true
|
|
22
31
|
end
|
|
23
32
|
end
|
|
24
33
|
end
|
|
@@ -12,20 +12,29 @@ module Hanamismith
|
|
|
12
12
|
return false unless settings.build_reek
|
|
13
13
|
|
|
14
14
|
super
|
|
15
|
-
|
|
15
|
+
add_duplicate_exclusion
|
|
16
|
+
add_too_many_statements_exclusion
|
|
16
17
|
true
|
|
17
18
|
end
|
|
18
19
|
|
|
19
|
-
def
|
|
20
|
+
def add_duplicate_exclusion
|
|
21
|
+
with_template.insert_before(
|
|
22
|
+
/LongParameterList:\n/,
|
|
23
|
+
<<~DETECTORS.gsub(/^/, " ")
|
|
24
|
+
DuplicateMethodCall:
|
|
25
|
+
exclude:
|
|
26
|
+
- UniversalLoggerPatch#_log_structured
|
|
27
|
+
DETECTORS
|
|
28
|
+
)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def add_too_many_statements_exclusion
|
|
20
32
|
with_template.insert_after(
|
|
21
33
|
/enabled:\sfalse\n/,
|
|
22
34
|
<<~DETECTORS.gsub(/^/, " ")
|
|
23
35
|
TooManyStatements:
|
|
24
36
|
exclude:
|
|
25
|
-
-
|
|
26
|
-
UtilityFunction:
|
|
27
|
-
exclude:
|
|
28
|
-
- SQLLoggerPatch#log_query
|
|
37
|
+
- UniversalLoggerPatch#_log_structured
|
|
29
38
|
DETECTORS
|
|
30
39
|
)
|
|
31
40
|
end
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
def prepare = require "cogger"
|
|
17
17
|
|
|
18
18
|
def start
|
|
19
|
+
add_aliases
|
|
19
20
|
add_filters
|
|
20
21
|
register :logger, build_instance
|
|
21
22
|
end
|
|
@@ -24,7 +25,23 @@
|
|
|
24
25
|
|
|
25
26
|
attr_reader :environment, :resolver, :id
|
|
26
27
|
|
|
27
|
-
def
|
|
28
|
+
def add_aliases
|
|
29
|
+
cogger.add_formatter(
|
|
30
|
+
:rack,
|
|
31
|
+
Cogger::Formatters::Emoji,
|
|
32
|
+
"%<emoji:dynamic>s <dynamic>[%<id>s] [%<level>s] [%<at>s] %<verb>s " \
|
|
33
|
+
"%<status>s %<elapsed>s %<ip>s %<path>s %<length>s </dynamic>"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
cogger.add_formatter :sql,
|
|
37
|
+
Cogger::Formatters::Emoji,
|
|
38
|
+
"%<emoji:dynamic>s <dynamic>[%<id>s] [%<level>s] [%<at>s] %<db>s " \
|
|
39
|
+
"%<elapsed>s%<elapsed_unit>s %<query>s</dynamic>"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def add_filters
|
|
43
|
+
cogger.add_filters :csrf, :HTTP_ID, :mac_address, :password, :password_confirmation
|
|
44
|
+
end
|
|
28
45
|
|
|
29
46
|
def build_instance
|
|
30
47
|
io = "log/#{environment}.log"
|
|
@@ -10,12 +10,6 @@ require "hanami"
|
|
|
10
10
|
Dry::Schema.load_extensions :monads
|
|
11
11
|
Dry::Validation.load_extensions :monads
|
|
12
12
|
|
|
13
|
-
prepare_container do |container|
|
|
14
|
-
container.config.component_dirs.dir "app" do |dir|
|
|
15
|
-
dir.memoize = -> component { component.key.start_with? "repositories." }
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
13
|
config.actions.content_security_policy.then do |csp|
|
|
20
14
|
csp[:manifest_src] = "'self'"
|
|
21
15
|
csp[:script_src] += " 'unsafe-eval' 'unsafe-inline'"
|
|
@@ -29,15 +23,5 @@ require "hanami"
|
|
|
29
23
|
expire_after: 3_600 # 1 hour.
|
|
30
24
|
}
|
|
31
25
|
# rubocop:enable Layout/FirstArrayElementLineBreak
|
|
32
|
-
|
|
33
|
-
environment :development do
|
|
34
|
-
# :nocov:
|
|
35
|
-
config.logger.options[:colorize] = true
|
|
36
|
-
|
|
37
|
-
config.logger = config.logger.instance.add_backend(
|
|
38
|
-
colorize: false,
|
|
39
|
-
stream: root.join("log/development.log")
|
|
40
|
-
)
|
|
41
|
-
end
|
|
42
26
|
end
|
|
43
27
|
<% end %>
|
data/lib/hanamismith/templates/%project_name%/config/initializers/universal_logger_patch.rb.erb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# auto_register: false
|
|
2
|
+
|
|
3
|
+
# Patches Hanami's universal logger to work with Cogger.
|
|
4
|
+
module UniversalLoggerPatch
|
|
5
|
+
def _log_structured method, message, payload
|
|
6
|
+
tags = _current_tags
|
|
7
|
+
block_content = yield if block_given?
|
|
8
|
+
|
|
9
|
+
logger.formatter = case tags
|
|
10
|
+
in [:rack] then tags.delete :rack
|
|
11
|
+
in [:sql] if block_content.is_a? Hash then tags.delete :sql
|
|
12
|
+
else Hanami.env == :development ? :emoji : :json
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
unless block_content.is_a? Hash
|
|
16
|
+
message = block_content
|
|
17
|
+
block_content = {}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
logger.public_send method, message, tags:, **block_content.merge!(payload)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
Hanami::UniversalLogger.prepend UniversalLoggerPatch
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
development = ENV.fetch("HANAMI_ENV", "development") == "development"
|
|
2
2
|
|
|
3
|
-
require "concurrent"
|
|
4
3
|
require "localhost" if development
|
|
5
4
|
|
|
6
5
|
Bundler.require :tools if development
|
|
@@ -8,9 +7,10 @@ Bundler.root.join("tmp").then { |path| path.mkdir unless path.exist? }
|
|
|
8
7
|
|
|
9
8
|
max_threads = ENV.fetch "HANAMI_MAX_THREADS", 5
|
|
10
9
|
min_threads = ENV.fetch "HANAMI_MIN_THREADS", max_threads
|
|
11
|
-
concurrency = ENV.fetch "HANAMI_WEB_CONCURRENCY",
|
|
10
|
+
concurrency = Integer ENV.fetch "HANAMI_WEB_CONCURRENCY", 0
|
|
12
11
|
|
|
13
12
|
threads min_threads, max_threads
|
|
13
|
+
max_io_threads 5
|
|
14
14
|
port ENV.fetch("HANAMI_PORT", 2300)
|
|
15
15
|
environment ENV.fetch("HANAMI_ENV", "development")
|
|
16
16
|
workers concurrency
|
|
@@ -18,5 +18,4 @@ worker_timeout 3600 if development
|
|
|
18
18
|
ssl_bind "localhost", 2443 if development
|
|
19
19
|
pidfile ENV.fetch("PIDFILE", "tmp/server.pid")
|
|
20
20
|
plugin :tmp_restart
|
|
21
|
-
|
|
22
|
-
preload_app! && before_fork { Hanami.shutdown } if concurrency.to_i.positive?
|
|
21
|
+
before_fork { Hanami.shutdown } if concurrency > 1
|
|
@@ -15,7 +15,7 @@ using Refinements::Pathname
|
|
|
15
15
|
|
|
16
16
|
ENV["LD_PRELOAD"] = nil
|
|
17
17
|
Capybara.app = Hanami.app
|
|
18
|
-
Capybara.server = :puma, {Silent: true, Threads: "
|
|
18
|
+
Capybara.server = :puma, {Silent: true, Threads: "2:2"}
|
|
19
19
|
Capybara.javascript_driver = :cuprite
|
|
20
20
|
Capybara.save_path = Hanami.app.root.join "tmp/capybara"
|
|
21
21
|
Capybara.register_driver :cuprite do |app|
|
|
@@ -56,6 +56,14 @@ RSpec.configure do |config|
|
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
config.prepend_before :each, :mailers do
|
|
60
|
+
Hanami.app.with_slices.each do |slice|
|
|
61
|
+
next unless slice.key? "mailers.delivery_method"
|
|
62
|
+
|
|
63
|
+
slice["mailers.delivery_method"].clear
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
59
67
|
config.append_after :each, :db do
|
|
60
68
|
databases.call.each { |db| DatabaseCleaner[:sequel, db:].clean }
|
|
61
69
|
end
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hanamismith
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brooke Kuhlmann
|
|
@@ -153,14 +153,14 @@ dependencies:
|
|
|
153
153
|
requirements:
|
|
154
154
|
- - "~>"
|
|
155
155
|
- !ruby/object:Gem::Version
|
|
156
|
-
version: '
|
|
156
|
+
version: '10.0'
|
|
157
157
|
type: :runtime
|
|
158
158
|
prerelease: false
|
|
159
159
|
version_requirements: !ruby/object:Gem::Requirement
|
|
160
160
|
requirements:
|
|
161
161
|
- - "~>"
|
|
162
162
|
- !ruby/object:Gem::Version
|
|
163
|
-
version: '
|
|
163
|
+
version: '10.0'
|
|
164
164
|
- !ruby/object:Gem::Dependency
|
|
165
165
|
name: runcom
|
|
166
166
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -283,7 +283,6 @@ files:
|
|
|
283
283
|
- lib/hanamismith/templates/%project_name%/Procfile.dev.erb
|
|
284
284
|
- lib/hanamismith/templates/%project_name%/Procfile.erb
|
|
285
285
|
- lib/hanamismith/templates/%project_name%/app/action.rb.erb
|
|
286
|
-
- lib/hanamismith/templates/%project_name%/app/aspects/logging/rack_adapter.rb.erb
|
|
287
286
|
- lib/hanamismith/templates/%project_name%/app/assets/css/colors.css.erb
|
|
288
287
|
- lib/hanamismith/templates/%project_name%/app/assets/css/defaults.css.erb
|
|
289
288
|
- lib/hanamismith/templates/%project_name%/app/assets/css/layout.css.erb
|
|
@@ -295,6 +294,7 @@ files:
|
|
|
295
294
|
- lib/hanamismith/templates/%project_name%/app/db/relation.rb.erb
|
|
296
295
|
- lib/hanamismith/templates/%project_name%/app/db/repository.rb.erb
|
|
297
296
|
- lib/hanamismith/templates/%project_name%/app/db/struct.rb.erb
|
|
297
|
+
- lib/hanamismith/templates/%project_name%/app/mailer.rb.erb
|
|
298
298
|
- lib/hanamismith/templates/%project_name%/app/providers/logger.rb.erb
|
|
299
299
|
- lib/hanamismith/templates/%project_name%/app/templates/layouts/app.html.erb.erb
|
|
300
300
|
- lib/hanamismith/templates/%project_name%/app/view.rb.erb
|
|
@@ -304,8 +304,7 @@ files:
|
|
|
304
304
|
- lib/hanamismith/templates/%project_name%/config/app.rb.erb
|
|
305
305
|
- lib/hanamismith/templates/%project_name%/config/assets.js.erb
|
|
306
306
|
- lib/hanamismith/templates/%project_name%/config/initializers/rack_attack.rb.erb
|
|
307
|
-
- lib/hanamismith/templates/%project_name%/config/initializers/
|
|
308
|
-
- lib/hanamismith/templates/%project_name%/config/initializers/sql_logger_patch.rb.erb
|
|
307
|
+
- lib/hanamismith/templates/%project_name%/config/initializers/universal_logger_patch.rb.erb
|
|
309
308
|
- lib/hanamismith/templates/%project_name%/config/providers/db.rb.erb
|
|
310
309
|
- lib/hanamismith/templates/%project_name%/config/providers/htmx.rb.erb
|
|
311
310
|
- lib/hanamismith/templates/%project_name%/config/providers/logger.rb.erb
|
|
@@ -336,7 +335,6 @@ files:
|
|
|
336
335
|
- lib/hanamismith/templates/%project_name%/slices/home/view.rb.erb
|
|
337
336
|
- lib/hanamismith/templates/%project_name%/slices/home/views/context.rb.erb
|
|
338
337
|
- lib/hanamismith/templates/%project_name%/slices/home/views/show.rb.erb
|
|
339
|
-
- lib/hanamismith/templates/%project_name%/spec/app/aspects/logging/rack_adapter_spec.rb.erb
|
|
340
338
|
- lib/hanamismith/templates/%project_name%/spec/app/providers/logger_spec.rb.erb
|
|
341
339
|
- lib/hanamismith/templates/%project_name%/spec/features/home_spec.rb.erb
|
|
342
340
|
- lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
|
|
@@ -368,7 +366,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
368
366
|
- !ruby/object:Gem::Version
|
|
369
367
|
version: '0'
|
|
370
368
|
requirements: []
|
|
371
|
-
rubygems_version: 4.0.
|
|
369
|
+
rubygems_version: 4.0.15
|
|
372
370
|
specification_version: 4
|
|
373
371
|
summary: A command line interface for smithing Hanami projects.
|
|
374
372
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<% namespace do %>
|
|
2
|
-
module Aspects
|
|
3
|
-
module Logging
|
|
4
|
-
# Adapts Cogger Rack middleware for provider registration.
|
|
5
|
-
module RackAdapter
|
|
6
|
-
module_function
|
|
7
|
-
|
|
8
|
-
def with logger
|
|
9
|
-
@logger = logger
|
|
10
|
-
self
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def new application
|
|
14
|
-
@application = Cogger::Rack::Logger.new application, {logger: @logger}
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def call(environment) = @application.call environment
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
<% end %>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require "dry/system"
|
|
2
|
-
|
|
3
|
-
# Patches Hanami's default providers.
|
|
4
|
-
module RackLoggerPatch
|
|
5
|
-
def prepare_app_providers
|
|
6
|
-
require "hanami/providers/inflector"
|
|
7
|
-
|
|
8
|
-
logger = Class.new Hanami::Provider::Source do
|
|
9
|
-
def start
|
|
10
|
-
slice.start :logger
|
|
11
|
-
register :monitor, <%= settings.project_namespaced_class %>::Aspects::Logging::RackAdapter.with(slice[:logger])
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
register_provider :inflector, source: Hanami::Providers::Inflector
|
|
16
|
-
register_provider :rack, source: logger, namespace: true
|
|
17
|
-
register_provider :db_logging, source: Hanami::Providers::DBLogging
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
Hanami::App::ClassMethods.prepend RackLoggerPatch
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
require "dry-monitor"
|
|
2
|
-
require "dry/monitor/sql/logger"
|
|
3
|
-
|
|
4
|
-
# Patches Hanami's default SQL logger.
|
|
5
|
-
module SQLLoggerPatch
|
|
6
|
-
def log_query time:, name:, query:
|
|
7
|
-
# :nocov:
|
|
8
|
-
Hanami.app[:logger].info { {message: query, tags: [{db: name, duration: time}]} }
|
|
9
|
-
# :nocov:
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
Dry::Monitor::SQL::Logger.prepend SQLLoggerPatch
|
data/lib/hanamismith/templates/%project_name%/spec/app/aspects/logging/rack_adapter_spec.rb.erb
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require "hanami_helper"
|
|
2
|
-
|
|
3
|
-
RSpec.describe <%= settings.project_namespaced_class %>::Aspects::Logging::RackAdapter do
|
|
4
|
-
subject(:adapter) { described_class }
|
|
5
|
-
|
|
6
|
-
include_context "with application dependencies"
|
|
7
|
-
|
|
8
|
-
let(:application) { proc { [200, {"Content-Type" => "text/plain"}, "test"] } }
|
|
9
|
-
|
|
10
|
-
describe ".with" do
|
|
11
|
-
it "answers itself" do
|
|
12
|
-
expect(adapter.with(nil)).to eq(adapter)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
describe ".new" do
|
|
17
|
-
it "answers Cogger middleware" do
|
|
18
|
-
expect(adapter.with(logger).new(application)).to be_a(Cogger::Rack::Logger)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
describe ".call" do
|
|
23
|
-
let(:middleware) { adapter.with(logger).new application }
|
|
24
|
-
|
|
25
|
-
it "answers application" do
|
|
26
|
-
expect(middleware.call({})).to eq([200, {"Content-Type" => "text/plain"}, "test"])
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "logs request" do
|
|
30
|
-
middleware.call({})
|
|
31
|
-
expect(logger.reread).to match(/level.+INFO.+status.+200/)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|