hanamismith 3.0.0 → 3.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/hanamismith.gemspec +1 -1
- data/lib/hanamismith/builders/core.rb +4 -0
- data/lib/hanamismith/builders/rack/attack.rb +4 -1
- data/lib/hanamismith/builders/rack/deflater.rb +4 -2
- data/lib/hanamismith/templates/%project_name%/app/contract.rb.erb +17 -0
- data/lib/hanamismith/templates/%project_name%/config/initializers/rack_attack.rb.erb +4 -3
- data/lib/hanamismith/templates/%project_name%/package.json.erb +1 -0
- data/lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb +6 -9
- data.tar.gz.sig +0 -0
- metadata +2 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b4e6465af13be82767b09daf96a78a165ec3d75ea5a06c5996bb231898054e70
|
|
4
|
+
data.tar.gz: c5ae3527f7210a600d383d6ad0af738e96bfbf65a36aadd3ad31cc9a17b8eed3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3117fdf9052c7ed06089b83d559118c9ee404b07fd2b99132e5fc3d734ab530f18d37826e379dc32b9693ca83e38583f9e8f4b5e18e1e6a9ad1a829ec09b5eb0
|
|
7
|
+
data.tar.gz: 0a0e943ef27c675f0a8782816614f7d97a8d021490324ac71f88a29c3f58c5e22b40968459c8fd52ca465b21f25e377b112efcabd63fd2a31441f538112e5b91
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/hanamismith.gemspec
CHANGED
|
@@ -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_contract
|
|
35
|
+
builder.call(settings.with(template_path: "%project_name%/app/contract.rb.erb")).render
|
|
36
|
+
end
|
|
37
|
+
|
|
34
38
|
def add_mailer
|
|
35
39
|
builder.call(settings.with(template_path: "%project_name%/app/mailer.rb.erb")).render
|
|
36
40
|
end
|
|
@@ -25,7 +25,10 @@ module Hanamismith
|
|
|
25
25
|
def add_middleware
|
|
26
26
|
builder.call(settings.with(template_path: "%project_name%/config/app.rb.erb"))
|
|
27
27
|
.insert_after(/require/, %(\nrequire_relative "initializers/rack_attack"\n))
|
|
28
|
-
.
|
|
28
|
+
.insert_after(
|
|
29
|
+
"rubocop:enable Layout/FirstArrayElementLineBreak\n",
|
|
30
|
+
"\n config.middleware.use Rack::Attack\n"
|
|
31
|
+
)
|
|
29
32
|
end
|
|
30
33
|
end
|
|
31
34
|
end
|
|
@@ -11,8 +11,10 @@ module Hanamismith
|
|
|
11
11
|
|
|
12
12
|
def call
|
|
13
13
|
builder.call(settings.with(template_path: "%project_name%/config/app.rb.erb"))
|
|
14
|
-
.insert_after(
|
|
15
|
-
|
|
14
|
+
.insert_after(
|
|
15
|
+
"rubocop:enable Layout/FirstArrayElementLineBreak\n",
|
|
16
|
+
"\n config.middleware.use Rack::Deflater\n"
|
|
17
|
+
)
|
|
16
18
|
true
|
|
17
19
|
end
|
|
18
20
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# auto_register: false
|
|
2
|
+
|
|
3
|
+
require "dry/validation"
|
|
4
|
+
|
|
5
|
+
<% namespace do %>
|
|
6
|
+
# The application base contract.
|
|
7
|
+
class Contract < Dry::Validation::Contract
|
|
8
|
+
config.messages.backend = :i18n
|
|
9
|
+
|
|
10
|
+
Hanami.app.config.i18n.tap do |i18n|
|
|
11
|
+
(i18n.shared_load_path + i18n.load_path).each do |entry|
|
|
12
|
+
path = Hanami.app.root.join entry.sub(/\*.*/, "")
|
|
13
|
+
config.messages.load_paths.merge path.glob("**/*.yml")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
<% end %>
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
require "ipaddr"
|
|
2
2
|
require "rack/attack"
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
allowed_subnets = [
|
|
5
5
|
IPAddr.new("10.0.0.0/8"),
|
|
6
6
|
IPAddr.new("172.16.0.0/12"),
|
|
7
7
|
IPAddr.new("192.168.0.0/16"),
|
|
8
8
|
IPAddr.new("127.0.0.1"),
|
|
9
|
-
IPAddr.new("::1")
|
|
9
|
+
IPAddr.new("::1"),
|
|
10
|
+
*ENV.fetch("RACK_ATTACK_ALLOWED_SUBNETS", "").split(",").map { IPAddr.new it }
|
|
10
11
|
]
|
|
11
12
|
|
|
12
13
|
Rack::Attack.safelist "allow private network" do |request|
|
|
13
|
-
|
|
14
|
+
allowed_subnets.any? { |subnet| subnet.include? request.ip }
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
Rack::Attack.throttle("requests by IP", limit: 100, period: 60, &:ip)
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
+
ENV["HANAMI_ENV"] = "test"
|
|
2
|
+
|
|
1
3
|
require "capybara/cuprite"
|
|
2
4
|
require "capybara/rspec"
|
|
3
5
|
require "capybara/validate_html5"
|
|
4
6
|
require "database_cleaner/sequel"
|
|
5
7
|
require "dry/monads"
|
|
8
|
+
require "hanami/prepare"
|
|
6
9
|
require "rack/test"
|
|
7
10
|
require "rom-factory"
|
|
8
11
|
require "spec_helper"
|
|
9
12
|
|
|
10
|
-
ENV["HANAMI_ENV"] = "test"
|
|
11
|
-
|
|
12
|
-
require "hanami/prepare"
|
|
13
|
-
|
|
14
13
|
using Refinements::Pathname
|
|
15
14
|
|
|
16
15
|
ENV["LD_PRELOAD"] = nil
|
|
@@ -36,10 +35,10 @@ RSpec.configure do |config|
|
|
|
36
35
|
config.include_context "with application dependencies", type: :feature
|
|
37
36
|
|
|
38
37
|
databases = proc do
|
|
39
|
-
Hanami.app.
|
|
38
|
+
Hanami.app.with_slices.each_with_object Set.new do |slice, databases|
|
|
40
39
|
next unless slice.key? "db.rom"
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
databases.merge slice["db.rom"].gateways.values.map(&:connection)
|
|
43
42
|
end
|
|
44
43
|
end
|
|
45
44
|
|
|
@@ -64,7 +63,5 @@ RSpec.configure do |config|
|
|
|
64
63
|
end
|
|
65
64
|
end
|
|
66
65
|
|
|
67
|
-
config.
|
|
68
|
-
databases.call.each { |db| DatabaseCleaner[:sequel, db:].clean }
|
|
69
|
-
end
|
|
66
|
+
config.after(:each, :db) { databases.call.each { DatabaseCleaner[:sequel, db: it].clean } }
|
|
70
67
|
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: 3.
|
|
4
|
+
version: 3.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brooke Kuhlmann
|
|
@@ -291,6 +291,7 @@ files:
|
|
|
291
291
|
- lib/hanamismith/templates/%project_name%/app/assets/images/icon.svg.erb
|
|
292
292
|
- lib/hanamismith/templates/%project_name%/app/assets/js/app.js.erb
|
|
293
293
|
- lib/hanamismith/templates/%project_name%/app/assets/pwa/manifest.webmanifest.erb
|
|
294
|
+
- lib/hanamismith/templates/%project_name%/app/contract.rb.erb
|
|
294
295
|
- lib/hanamismith/templates/%project_name%/app/db/relation.rb.erb
|
|
295
296
|
- lib/hanamismith/templates/%project_name%/app/db/repository.rb.erb
|
|
296
297
|
- lib/hanamismith/templates/%project_name%/app/db/struct.rb.erb
|
metadata.gz.sig
CHANGED
|
Binary file
|