hanamismith 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1547f2b3305d29362da3bfc4779fd1093aba4834ddf8ab7a09d684722325b708
4
- data.tar.gz: 9b83495269ac455d6eca644ff635127746bef385bda1ce0593a389cdfe421175
3
+ metadata.gz: 95bcf45f1ad28134657402afeab54487757c5269166ee13cbddd23571cf749ca
4
+ data.tar.gz: ed18cbcf1ea054fb8cc7794590cd89006738f8ea08495e7a26e1ff7c146c3531
5
5
  SHA512:
6
- metadata.gz: c351b54ab430d6c0f54e5b9bfa562fc052bd532ac1f95af6d9ddac58a957d49330eb5da490336fc2e72ad245fef324965fd05a25c633845c2f3dea0a40fb6c70
7
- data.tar.gz: 73767e229d91778bb6f21df1edf5cafebd94794c9f7ae97471eaca9876fe0d39cd242cb1b70f194af067a3cf1c3511f2445a7a5f36f28119eb0ab8716b09ba72
6
+ metadata.gz: 138d4fddb7fbbdeb608ca6f218b32006c851679197c36a63ceadcbb62954a88c5b05995dc7de2e24e06d80ea60b7c4c278d8db0c581038d478f4a67cb0fcff16
7
+ data.tar.gz: 15b01e9c02efbe60f6f0aad5137a952040ad8edb9cdfd832f76508cb134dcd4405a9f60a3285c8c57b1619695f5566a6a2ce5ade60356715a98af990c80bb2f2
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -2,16 +2,21 @@
2
2
  :toclevels: 5
3
3
  :figure-caption!:
4
4
 
5
+ :capybara_link: link:https://github.com/teamcapybara/capybara[Capybara]
5
6
  :cuprite_link: link:https://cuprite.rubycdp.com[Cuprite]
6
7
  :dry_link: link:https://dry-rb.org[Dry RB]
8
+ :dotenv_link: link:https://github.com/bkeepers/dotenv[Dotenv]
7
9
  :dotfiles_link: link:https://www.alchemists.io/projects/dotfiles[Dotfiles]
8
10
  :hanami_link: link:https://hanamirb.org[Hanami]
9
11
  :htmx_link: link:https://htmx.org[HTMX]
12
+ :pg_link: link:https://github.com/ged/ruby-pg[pg]
13
+ :puma_link: link:https://puma.io[Puma]
14
+ :rom_link: link:https://rom-rb.org[ROM]
10
15
  :rubysmith_link: link:https://www.alchemists.io/projects/rubysmith[Rubysmith]
11
16
 
12
17
  = Hanamismith
13
18
 
14
- Hanamismith is a Command Line Interface (CLI) for smithing Hanami projects. Perfect for when you need a professional and robust tool for building new project skeletons. To quote from the {dry_link} and {hanami_link} team:
19
+ Hanamismith is a Command Line Interface (CLI) for smithing Hanami projects. Perfect for when you need a professional and robust tool for building new project skeletons. To quote from the {dry_link} and {hanami_link} teams:
15
20
  ____
16
21
  If you're looking for new ways to build maintainable, secure, faster and testable Ruby applications, you're in for a treat. *Hanami is built for people like you*.
17
22
 
@@ -24,11 +29,14 @@ toc::[]
24
29
 
25
30
  == Features
26
31
 
27
- * Supports all {rubysmith_link} features.
28
- * Supports {dry_link} functional programming.
29
- * Supports {hanami_link} for web application development.
30
- * Supports {htmx_link} for proper REST (hypermedia) architectures (i.e. HTML over the wire) so you can write less code and avoid bloated JavaScript stacks.
31
- * Supports {cuprite_link} for full, headless, feature testing.
32
+ * Built atop {rubysmith_link} and leverages all features.
33
+ * Uses {dry_link} functional programming.
34
+ * Uses {hanami_link} for web application development.
35
+ * Uses {htmx_link} for proper REST (hypermedia) architectures (i.e. HTML over the wire) so you can write less code and avoid bloated JavaScript stacks.
36
+ * Uses {pg_link} coupled with {rom_link} for database management.
37
+ * Uses {puma_link} as the default web server and fully configured for local and production environments.
38
+ * Uses {capybara_link} with {cuprite_link} (driver) for full, headless, feature testing.
39
+ * Uses {dotenv_link} for managing your environment configurations.
32
40
 
33
41
  == Requirements
34
42
 
@@ -138,7 +146,7 @@ git commit # (repeat until finished with implementation)
138
146
  overmind start --port-step 10 --procfile Procfile.dev
139
147
 
140
148
  # Run: Without Overmind
141
- hanami start
149
+ hanami server
142
150
 
143
151
  # Deploy
144
152
  git push
@@ -159,7 +167,9 @@ The above is what I use via my {dotfiles_link} project.
159
167
 
160
168
  === Demonstration
161
169
 
162
- If you'd like a fully working demonstration appliation -- as built by this gem -- then check ouh the link:https://github.com/bkuhlmann/hemo[Hemo] project.
170
+ If you'd like a fully working demonstration application -- as built by this gem -- then check out the link:https://github.com/bkuhlmann/hemo[Hemo] project. Here's a quick screencast overview of demonstration application:
171
+
172
+ video::https://www.alchemists.io/videos/projects/hemo/demo.mp4[poster=https://www.alchemists.io/images/projects/hemo/demo.png,width=1028,height=854,role=focal_point]
163
173
 
164
174
  == Development
165
175
 
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 = "0.0.0"
5
+ spec.version = "0.1.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://www.alchemists.io/projects/hanamismith"
@@ -16,6 +16,7 @@ module Hanamismith
16
16
  alter_groups
17
17
  append_development_group
18
18
  append_test_group
19
+ insert_development_and_test_group
19
20
  remove_zeitwerk
20
21
  configuration
21
22
  end
@@ -49,10 +50,12 @@ module Hanamismith
49
50
 
50
51
  def alter_groups
51
52
  with_template.insert_after(/group :code_quality/, %( gem "rubocop-sequel", "~> 0.3"\n))
52
- .insert_after(/group :development/, %( gem "localhost", "~> 1.1"\n))
53
- .insert_after(/group :development/, %( gem "rerun", "~> 0.14"\n))
53
+ .insert_after(/group :development do/, %( gem "localhost", "~> 1.1"\n))
54
+ .insert_after(/group :development do/, %( gem "rerun", "~> 0.14"\n))
54
55
  .insert_after(/group :test/, %( gem "capybara", "~> 3.38"\n))
55
56
  .insert_after(/group :test/, %( gem "cuprite", "~> 0.14"\n))
57
+ .insert_after(/group :test/, %( gem "database_cleaner-sequel", "~> 2.0"\n))
58
+ .insert_after(/group :test/, %( gem "launchy", "~> 2.5"\n))
56
59
  .insert_after(/group :test/, %( gem "rack-test", "~> 2.0"\n))
57
60
  .insert_after(/group :test/, %( gem "rom-factory", "~> 0.11"\n))
58
61
  .replace(/gem "rspec.+/, %(gem "hanami-rspec", "~> 2.0"))
@@ -62,7 +65,6 @@ module Hanamismith
62
65
  return if configuration.markdown? || configuration.build_rake || configuration.build_yard
63
66
 
64
67
  with_template.append <<~CONTENT
65
-
66
68
  group :development do
67
69
  gem "localhost", "~> 1.1"
68
70
  gem "rerun", "~> 0.14"
@@ -78,13 +80,25 @@ module Hanamismith
78
80
  group :test do
79
81
  gem "capybara", "~> 3.38"
80
82
  gem "cuprite", "~> 0.14"
83
+ gem "database_cleaner-sequel", "~> 2.0"
81
84
  gem "hanami-rspec", "~> 2.0"
85
+ gem "launchy", "~> 2.5"
82
86
  gem "rack-test", "~> 2.0"
83
87
  gem "rom-factory", "~> 0.11"
84
88
  end
85
89
  CONTENT
86
90
  end
87
91
 
92
+ def insert_development_and_test_group
93
+ with_template.insert_before(/group :development/, <<~CONTENT)
94
+
95
+ group :development, :test do
96
+ gem "dotenv", "~> 2.8"
97
+ end
98
+
99
+ CONTENT
100
+ end
101
+
88
102
  def remove_zeitwerk = with_template.replace(/.+zeitwerk.+\n\n/, "\n")
89
103
 
90
104
  def with_template
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+
5
+ module Hanamismith
6
+ module Builders
7
+ module Environments
8
+ # Builds development environment skeleton.
9
+ class Development
10
+ using Refinements::Structs
11
+
12
+ def self.call(...) = new(...).call
13
+
14
+ def initialize configuration, builder: Rubysmith::Builder
15
+ @configuration = configuration
16
+ @builder = builder
17
+ end
18
+
19
+ def call
20
+ builder.call(configuration.merge(template_path: "%project_name%/env.development.erb"))
21
+ .render
22
+ .rename(".env.development")
23
+
24
+ configuration
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :configuration, :builder
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+
5
+ module Hanamismith
6
+ module Builders
7
+ module Environments
8
+ # Builds test environment skeleton.
9
+ class Test
10
+ using Refinements::Structs
11
+
12
+ def self.call(...) = new(...).call
13
+
14
+ def initialize configuration, builder: Rubysmith::Builder
15
+ @configuration = configuration
16
+ @builder = builder
17
+ end
18
+
19
+ def call
20
+ builder.call(configuration.merge(template_path: "%project_name%/env.test.erb"))
21
+ .render
22
+ .rename(".env.test")
23
+
24
+ configuration
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :configuration, :builder
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+
5
+ module Hanamismith
6
+ module Builders
7
+ module RSpec
8
+ # Builds project skeleton RSpec application shared context.
9
+ class ApplicationSharedContext
10
+ using Refinements::Structs
11
+
12
+ def self.call(...) = new(...).call
13
+
14
+ def initialize configuration, builder: Rubysmith::Builder
15
+ @configuration = configuration
16
+ @builder = builder
17
+ end
18
+
19
+ def call
20
+ return configuration unless configuration.build_rspec
21
+
22
+ path = "%project_name%/spec/support/shared_contexts/application.rb.erb"
23
+ builder.call(configuration.merge(template_path: path)).render
24
+
25
+ configuration
26
+ end
27
+
28
+ private
29
+
30
+ attr_reader :configuration, :builder
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+
5
+ module Hanamismith
6
+ module Builders
7
+ module RSpec
8
+ # Builds project skeleton RSpec application database support.
9
+ class Database
10
+ using Refinements::Structs
11
+
12
+ def self.call(...) = new(...).call
13
+
14
+ def initialize configuration, builder: Rubysmith::Builder
15
+ @configuration = configuration
16
+ @builder = builder
17
+ end
18
+
19
+ def call
20
+ return configuration unless configuration.build_rspec
21
+
22
+ path = "%project_name%/spec/support/database.rb.erb"
23
+ builder.call(configuration.merge(template_path: path)).render
24
+
25
+ configuration
26
+ end
27
+
28
+ private
29
+
30
+ attr_reader :configuration, :builder
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+
5
+ module Hanamismith
6
+ module Builders
7
+ module RSpec
8
+ # Builds project skeleton RSpec application database support.
9
+ class Factory
10
+ using Refinements::Structs
11
+
12
+ def self.call(...) = new(...).call
13
+
14
+ def initialize configuration, builder: Rubysmith::Builder
15
+ @configuration = configuration
16
+ @builder = builder
17
+ end
18
+
19
+ def call
20
+ return configuration unless configuration.build_rspec
21
+
22
+ path = "%project_name%/spec/support/factory.rb.erb"
23
+ builder.call(configuration.merge(template_path: path)).render
24
+
25
+ configuration
26
+ end
27
+
28
+ private
29
+
30
+ attr_reader :configuration, :builder
31
+ end
32
+ end
33
+ end
34
+ end
@@ -30,6 +30,9 @@ module Hanamismith
30
30
  Rubysmith::Builders::Reek,
31
31
  Rubysmith::Builders::RSpec::Binstub,
32
32
  Rubysmith::Builders::RSpec::Context,
33
+ Builders::RSpec::ApplicationSharedContext,
34
+ Builders::RSpec::Database,
35
+ Builders::RSpec::Factory,
33
36
  Builders::RSpec::Helper,
34
37
  Builders::RSpec::Hanami,
35
38
  Builders::Rack,
@@ -40,7 +43,8 @@ module Hanamismith
40
43
  Rubysmith::Extensions::Pragmater,
41
44
  Rubysmith::Extensions::Tocer,
42
45
  Rubysmith::Extensions::Rubocop,
43
- Builders::Environment,
46
+ Builders::Environments::Development,
47
+ Builders::Environments::Test,
44
48
  Builders::Git::Commit
45
49
  ].freeze
46
50
 
@@ -1 +1 @@
1
- web: rerun --pattern="**/*.{css,erb,js,rb}" -- bundle exec puma --config ./config/puma.rb
1
+ web: rerun --dir app,config,lib,slices --pattern="**/*.{css,erb,js,rb}" -- bundle exec puma --config ./config/puma.rb
@@ -0,0 +1 @@
1
+ DATABASE_URL=postgres://localhost/<%= configuration.project_name %>_development
@@ -0,0 +1 @@
1
+ DATABASE_URL=postgres://localhost/<%= configuration.project_name %>_test
@@ -1,22 +1,44 @@
1
1
  require "capybara/cuprite"
2
2
  require "capybara/rspec"
3
+ require "database_cleaner/sequel"
3
4
  require "rack/test"
4
5
  require "spec_helper"
5
6
 
6
7
  ENV["HANAMI_ENV"] = "test"
8
+
7
9
  require "hanami/prepare"
10
+ require_relative "support/database"
11
+ require_relative "support/factory"
12
+
13
+ using Refinements::Pathnames
8
14
 
15
+ Capybara.app = Hanami.app
9
16
  Capybara.server = :puma, {Silent: true}
10
17
  Capybara.javascript_driver = :cuprite
18
+ Capybara.save_path = Hanami.app.root.join "tmp/capybara"
11
19
  Capybara.register_driver :cuprite do |app|
12
20
  Capybara::Cuprite::Driver.new app, window_size: [1200, 800]
13
21
  end
14
22
 
15
- RSpec.shared_context "with Hanami application" do
16
- let(:app) { Hanami.app }
17
- end
23
+ DatabaseCleaner[:sequel].strategy = :transaction
24
+
25
+ Pathname.require_tree SPEC_ROOT, "support/factories/**/*.rb"
18
26
 
19
27
  RSpec.configure do |config|
28
+ config.include Capybara::DSL, Capybara::RSpecMatchers, :web
20
29
  config.include Rack::Test::Methods, type: :request
30
+ config.include Test::Database, :db
21
31
  config.include_context "with Hanami application", type: :request
32
+
33
+ config.before :suite do
34
+ Hanami.app.start :persistence
35
+ DatabaseCleaner[:sequel].clean_with :truncation
36
+ end
37
+
38
+ config.prepend_before :each, :db do |example|
39
+ DatabaseCleaner[:sequel].strategy = example.metadata[:js] ? :truncation : :transaction
40
+ DatabaseCleaner[:sequel].start
41
+ end
42
+
43
+ config.append_after(:each, :db) { DatabaseCleaner[:sequel].clean }
22
44
  end
@@ -0,0 +1,10 @@
1
+ module Test
2
+ # Provides convenience methods for testing purposes.
3
+ module Database
4
+ def self.relations = rom.relations
5
+
6
+ def self.rom = Hanami.app["persistence.rom"]
7
+
8
+ def self.db = Hanami.app["persistence.db"]
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ require "rom-factory"
2
+ require_relative "database"
3
+
4
+ module Test
5
+ Factory = ROM::Factory.configure { |config| config.rom = Test::Database.rom }
6
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.shared_context "with Hanami application" do
2
+ let(:app) { Hanami.app }
3
+ 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: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,7 +28,7 @@ cert_chain:
28
28
  CxDe2+VuChj4I1nvIHdu+E6XoEVlanUPKmSg6nddhkKn2gC45Kyzh6FZqnzH/CRp
29
29
  RFE=
30
30
  -----END CERTIFICATE-----
31
- date: 2023-01-18 00:00:00.000000000 Z
31
+ date: 2023-01-19 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: cogger
@@ -205,13 +205,17 @@ files:
205
205
  - lib/hanamismith/builders/console.rb
206
206
  - lib/hanamismith/builders/core.rb
207
207
  - lib/hanamismith/builders/documentation/readme.rb
208
- - lib/hanamismith/builders/environment.rb
208
+ - lib/hanamismith/builders/environments/development.rb
209
+ - lib/hanamismith/builders/environments/test.rb
209
210
  - lib/hanamismith/builders/git/commit.rb
210
211
  - lib/hanamismith/builders/guard.rb
211
212
  - lib/hanamismith/builders/puma/configuration.rb
212
213
  - lib/hanamismith/builders/puma/procfile.rb
213
214
  - lib/hanamismith/builders/rack.rb
214
215
  - lib/hanamismith/builders/rake.rb
216
+ - lib/hanamismith/builders/rspec/application_shared_context.rb
217
+ - lib/hanamismith/builders/rspec/database.rb
218
+ - lib/hanamismith/builders/rspec/factory.rb
215
219
  - lib/hanamismith/builders/rspec/hanami.rb
216
220
  - lib/hanamismith/builders/rspec/helper.rb
217
221
  - lib/hanamismith/builders/slices/main.rb
@@ -240,7 +244,8 @@ files:
240
244
  - lib/hanamismith/templates/%project_name%/config/puma.rb.erb
241
245
  - lib/hanamismith/templates/%project_name%/config/routes.rb.erb
242
246
  - lib/hanamismith/templates/%project_name%/config/settings.rb.erb
243
- - lib/hanamismith/templates/%project_name%/envrc.erb
247
+ - lib/hanamismith/templates/%project_name%/env.development.erb
248
+ - lib/hanamismith/templates/%project_name%/env.test.erb
244
249
  - lib/hanamismith/templates/%project_name%/lib/%project_path%/types.rb.erb
245
250
  - lib/hanamismith/templates/%project_name%/slices/main/action.rb.erb
246
251
  - lib/hanamismith/templates/%project_name%/slices/main/actions/home/show.rb.erb
@@ -250,6 +255,9 @@ files:
250
255
  - lib/hanamismith/templates/%project_name%/slices/main/view.rb.erb
251
256
  - lib/hanamismith/templates/%project_name%/slices/main/views/home/show.rb.erb
252
257
  - lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
258
+ - lib/hanamismith/templates/%project_name%/spec/support/database.rb.erb
259
+ - lib/hanamismith/templates/%project_name%/spec/support/factory.rb.erb
260
+ - lib/hanamismith/templates/%project_name%/spec/support/shared_contexts/application.rb.erb
253
261
  homepage: https://www.alchemists.io/projects/hanamismith
254
262
  licenses:
255
263
  - Hippocratic-2.1
metadata.gz.sig CHANGED
Binary file
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "refinements/structs"
4
-
5
- module Hanamismith
6
- module Builders
7
- # Builds project environment skeleton.
8
- class Environment
9
- using Refinements::Structs
10
-
11
- def self.call(...) = new(...).call
12
-
13
- def initialize configuration, builder: Rubysmith::Builder
14
- @configuration = configuration
15
- @builder = builder
16
- end
17
-
18
- def call
19
- builder.call(configuration.merge(template_path: "%project_name%/envrc.erb"))
20
- .render
21
- .rename(".envrc")
22
-
23
- configuration
24
- end
25
-
26
- private
27
-
28
- attr_reader :configuration, :builder
29
- end
30
- end
31
- end
@@ -1 +0,0 @@
1
- export DATABASE_URL=postgres://localhost/<%= configuration.project_name %>_development