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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0c8864aa328874754512be314522a523aa831bdbae209bafeec22a5e31bd0bb
4
- data.tar.gz: 899e32fcfdced1478fc8b08f5e0a00758d300992417bcc723f91439f21a497e9
3
+ metadata.gz: b4e6465af13be82767b09daf96a78a165ec3d75ea5a06c5996bb231898054e70
4
+ data.tar.gz: c5ae3527f7210a600d383d6ad0af738e96bfbf65a36aadd3ad31cc9a17b8eed3
5
5
  SHA512:
6
- metadata.gz: bdad438b6b4e9e46200ee87866f94e5f631cc35c41a2e018b517871a5e7cab61320063ac30936ea7e298345ac38eeaf1e1d4bc34a8ee8fa09e91b8d403e319fa
7
- data.tar.gz: 5a646edeefdaae29dcb4cf5cb260e3f43fc0c9b95fc35dc74b32859836848b9844953709644c36c6de3bae374a646b07e63daba033e7a6f7fd4625e4cf00987d
6
+ metadata.gz: 3117fdf9052c7ed06089b83d559118c9ee404b07fd2b99132e5fc3d734ab530f18d37826e379dc32b9693ca83e38583f9e8f4b5e18e1e6a9ad1a829ec09b5eb0
7
+ data.tar.gz: 0a0e943ef27c675f0a8782816614f7d97a8d021490324ac71f88a29c3f58c5e22b40968459c8fd52ca465b21f25e377b112efcabd63fd2a31441f538112e5b91
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 = "3.0.0"
5
+ spec.version = "3.1.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/hanamismith"
@@ -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
- .insert_before(/environment/, " config.middleware.use Rack::Attack\n\n")
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(/Rack::Attack/, " config.middleware.use Rack::Deflater\n")
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
- private_subnets = [
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
- private_subnets.any? { |subnet| subnet.include? request.ip }
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)
@@ -8,6 +8,7 @@
8
8
  "type": "module",
9
9
  "keywords": ["hanami", "htmx", "ruby"],
10
10
  "dependencies": {
11
+ "esbuild": "^0.28.1",
11
12
  "hanami-assets": "^3.0.0",
12
13
  "htmx.org": "^2.0.10"
13
14
  },
@@ -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.slices.with_nested.prepend(Hanami.app).each.with_object Set.new do |slice, dbs|
38
+ Hanami.app.with_slices.each_with_object Set.new do |slice, databases|
40
39
  next unless slice.key? "db.rom"
41
40
 
42
- dbs.merge slice["db.rom"].gateways.values.map(&:connection).to_enum
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.append_after :each, :db do
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.0.0
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