hanamismith 3.0.0 → 4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0c8864aa328874754512be314522a523aa831bdbae209bafeec22a5e31bd0bb
4
- data.tar.gz: 899e32fcfdced1478fc8b08f5e0a00758d300992417bcc723f91439f21a497e9
3
+ metadata.gz: b69a002fb43fc9cc1a0ff0ea8b13ff00ba6ee8661f9e306150ed25bc62f8e8cc
4
+ data.tar.gz: d7ee04ba5d164cbb8d488f1fb248e0441c480e43eed16f85ee1dd87709c94b86
5
5
  SHA512:
6
- metadata.gz: bdad438b6b4e9e46200ee87866f94e5f631cc35c41a2e018b517871a5e7cab61320063ac30936ea7e298345ac38eeaf1e1d4bc34a8ee8fa09e91b8d403e319fa
7
- data.tar.gz: 5a646edeefdaae29dcb4cf5cb260e3f43fc0c9b95fc35dc74b32859836848b9844953709644c36c6de3bae374a646b07e63daba033e7a6f7fd4625e4cf00987d
6
+ metadata.gz: a5381fcb09a4d24e59fbc1b39c35b79668e849881418545e0d5fc662fd1c2a19ec7322d88f56294890038b4ed8f6ae1acd94fa403db8016f09f5284b8d575941
7
+ data.tar.gz: 7a5f1cc3c074d83b01ffd7a4ba0a03126fbae2146a87ea485a8bbe1d34273e1bf4d4bd8ed0a1ba1710607913003284234973228d9d7f8fe25395f487cbbe4502
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 = "4.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", "~> 10.0"
35
+ spec.add_dependency "rubysmith", "~> 11.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"
@@ -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
@@ -20,8 +20,6 @@ module Hanamismith
20
20
  .replace("<!-- stylesheet -->", stylesheet)
21
21
  .replace("<!-- javascript -->", javascript)
22
22
  .replace("<!-- yield -->", "<%= yield %>")
23
- .replace("<!-- flash:alert -->", flash(:alert))
24
- .replace("<!-- flash:notice -->", flash(:notice))
25
23
 
26
24
  true
27
25
  end
@@ -53,15 +51,6 @@ module Hanamismith
53
51
  %( type: "image/png" %>)
54
52
  end
55
53
 
56
- # :reek:UtilityFunction
57
- def flash kind
58
- %(<% if flash[:#{kind}] %>\n) +
59
- %( <div class="site-#{kind}">\n) +
60
- %( <p><%= flash[:#{kind}] %></p>\n) +
61
- %( </div>\n) +
62
- %( <% end %>\n)
63
- end
64
-
65
54
  def manifest
66
55
  %(<%= tag.link title: "#{settings.project_label}: Manifest",\n) +
67
56
  %( rel: :manifest,\n) +
@@ -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 %>
@@ -28,8 +28,6 @@
28
28
  </head>
29
29
 
30
30
  <body class="site-page">
31
- <!-- flash:alert -->
32
- <!-- flash:notice -->
33
31
  <!-- yield -->
34
32
  </body>
35
33
  </html>
@@ -3,9 +3,7 @@ require "hanami"
3
3
  <% namespace do %>
4
4
  # The application base configuration.
5
5
  class App < Hanami::App
6
- # :nocov:
7
6
  RubyVM::YJIT.enable
8
- # :nocov:
9
7
 
10
8
  Dry::Schema.load_extensions :monads
11
9
  Dry::Validation.load_extensions :monads
@@ -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
@@ -4,10 +4,20 @@ RSpec.describe Health::Actions::Show do
4
4
  subject(:action) { described_class.new }
5
5
 
6
6
  describe "#call" do
7
- it "answers green background" do
7
+ it "answers green background on success" do
8
8
  expect(action.call({}).body.first).to include(
9
9
  %(<main style="background-color: green; height: 100vh;">\n</main>)
10
10
  )
11
11
  end
12
+
13
+ it "answers red background on failure" do
14
+ action = described_class.new.dup
15
+
16
+ def action.handle(*) = fail StandardError, "Danger!"
17
+
18
+ expect(action.call({}).body.first).to include(
19
+ %(<main style="background-color: red; height: 100vh;">\n</main>)
20
+ )
21
+ end
12
22
  end
13
23
  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: 4.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: '10.0'
156
+ version: '11.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: '10.0'
163
+ version: '11.0'
164
164
  - !ruby/object:Gem::Dependency
165
165
  name: runcom
166
166
  requirement: !ruby/object:Gem::Requirement
@@ -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
@@ -366,7 +367,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
366
367
  - !ruby/object:Gem::Version
367
368
  version: '0'
368
369
  requirements: []
369
- rubygems_version: 4.0.15
370
+ rubygems_version: 4.0.16
370
371
  specification_version: 4
371
372
  summary: A command line interface for smithing Hanami projects.
372
373
  test_files: []
metadata.gz.sig CHANGED
Binary file