jets-railtie 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -0
  3. data/lib/generators/jets/engine/USAGE +5 -0
  4. data/lib/generators/jets/engine/engine_generator.rb +8 -0
  5. data/lib/generators/jets/engine/templates/app/controllers/%name%/application_controller.rb.tt +4 -0
  6. data/lib/generators/jets/engine/templates/config/routes.rb.tt +2 -0
  7. data/lib/generators/jets/engine/templates/lib/%name%/engine.rb.tt +18 -0
  8. data/lib/generators/jets/engine/templates/spec/internal/config/database.yml.tt +1 -1
  9. data/lib/generators/jets/engine/templates/spec/rails_helper.rb.tt +9 -2
  10. data/lib/generators/jets/engine/templates/spec/spec_helper.rb +1 -1
  11. data/lib/generators/jets/gem/USAGE +5 -0
  12. data/lib/generators/jets/gem/gem_generator.rb +21 -0
  13. data/lib/generators/jets/gem/templates/%name%.gemspec.tt +24 -0
  14. data/lib/generators/jets/gem/templates/Gemfile +15 -0
  15. data/lib/generators/jets/gem/templates/Gemfile.runtime +0 -0
  16. data/lib/generators/jets/gem/templates/README.md.tt +29 -0
  17. data/lib/generators/jets/gem/templates/Rakefile.tt +8 -0
  18. data/lib/generators/jets/gem/templates/bin/console.tt +8 -0
  19. data/lib/generators/jets/gem/templates/lib/%name%.rb.tt +3 -0
  20. data/lib/generators/jets/gem/templates/lib/%name%/version.rb.tt +5 -0
  21. data/lib/generators/jets/gem/templates/spec/rails_helper.rb +5 -0
  22. data/lib/generators/jets/gem/templates/spec/spec_helper.rb +6 -0
  23. data/lib/generators/jets/install/install_generator.rb +5 -0
  24. data/lib/jets/rails/railtie.rb +1 -0
  25. data/lib/jets/rails/version.rb +1 -1
  26. metadata +17 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00d4d29cdd04a8e856cacc269780141d118483015e3fe7ed3ab9bec6cd28e002
4
- data.tar.gz: 6aefe043bf6070c6b4eea6126b0750cb201b9ce579e3cdc56e6c8237eb3cd6df
3
+ metadata.gz: 1d88132a962ea916b76cb977db82b70ec9911e6331b46686ad32d5b81fa273d5
4
+ data.tar.gz: 600db5cb2897447a3a26df713338b9b0e17f8261fb40382d02c6abfe2588abc5
5
5
  SHA512:
6
- metadata.gz: a7c7e987600ef48095b9b7ab2ad195322381b956ef186aa1a0ef1c8dee4b31909e8fefb1585c9cc65e6bef82ec24ea15d6f9d8ed52d48a3705f8c30daf4b84e2
7
- data.tar.gz: 9757b2e3a5953e7e217d4183a8d36d907d536b04ee4460ca668bca6dd2fb3decf14f8a4ead3fc3d3d3bcc1d70e613514545517b73c292c9a5cdcec2433a607b6
6
+ metadata.gz: 6f4aace375c8ae534a1afb2b1b4515895331c86452dca29bed5e5a9375ce16be137d67e0326cd1b2ed7aacf67482c651773c9807e7b8a68ccbcd993e4d0f1a29
7
+ data.tar.gz: acd0ab0b46ca22140e66aca065c4330406a158b6da74672bdc2bd3af460bcbec847582726cb7b580ba062c09cf401602033dbcadf46335b178c91b3e6665b642
data/README.md CHANGED
@@ -16,3 +16,15 @@ This library officially supports the following Ruby versions:
16
16
  ## License
17
17
 
18
18
  See `LICENSE` file.
19
+
20
+ ## Credits
21
+
22
+ Original inspiration for the Jets project comes from [Vladimir Dementyev's](https://github.com/palkan)
23
+ excellent presentation on component-based Rails monolith applications and his [Engems](https://github.com/palkan/engems)
24
+ showcase repository.
25
+
26
+ Code:
27
+ - [Engems](https://github.com/palkan/engems)
28
+
29
+ Talks:
30
+ - [Between monoliths and microservices](https://noti.st/palkan/VWPOSd/between-monoliths-and-microservices)
@@ -0,0 +1,5 @@
1
+ Description:
2
+ This generator creates a skeleton of a Rails engine with Jets conventions and configurations.
3
+
4
+ Example:
5
+ rails generate jets:engine <name>
@@ -17,6 +17,14 @@ module Jets
17
17
  chmod "engines/#{name}/bin/console", 0o755, verbose: false
18
18
  chmod "engines/#{name}/bin/rails", 0o755, verbose: false
19
19
  end
20
+
21
+ def mount_engine_to_routes
22
+ route "mount #{class_name}::Engine, at: \"/\", as: :#{name}_root"
23
+ end
24
+
25
+ def add_engine_to_gemfile_as_component
26
+ append_to_file "Gemfile", "component \"#{name}\""
27
+ end
20
28
  end
21
29
  end
22
30
  end
@@ -0,0 +1,4 @@
1
+ module <%= class_name %>
2
+ class ApplicationController < Engine.config.application_controller.constantize
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ <%= class_name %>::Engine.routes.draw do
2
+ end
@@ -14,6 +14,9 @@ module <%= class_name %>
14
14
 
15
15
  config.autoload_paths += Dir["#{config.root}/app/**/concerns"]
16
16
 
17
+ # Specify the application controller base class, defaults to main application's ApplicationController
18
+ config.application_controller = "ApplicationController"
19
+
17
20
  initializer "<%= name %>" do |app|
18
21
  app.config.paths["db/migrate"].concat(config.paths["db/migrate"].expanded)
19
22
 
@@ -27,5 +30,20 @@ module <%= class_name %>
27
30
  FactoryBot.definition_file_paths.unshift engine_factories_path
28
31
  end
29
32
  end
33
+
34
+ initialize "<%= name %>.subscribe_to_events" do
35
+ ActiveSupport.on_load :active_event_store do |store|
36
+ # async subscriber is invoked from a background job, enqueued after the transaction commits
37
+ # store.subscribe MyEventHandler, to: EventHappened
38
+
39
+ # anonymous handler
40
+ # store.subscribe(to: EventHappened, sync: true) do |event|
41
+ # # do something
42
+ # end
43
+
44
+ # subscribes to EventHappened automatically
45
+ # store.subscribe OnEventHappened::DoThat
46
+ end
47
+ end
30
48
  end
31
49
  end
@@ -1,6 +1,6 @@
1
1
  test:
2
2
  adapter: postgresql
3
- url: <%%= ENV["DATABASE_URL"].sub("postgres://", "postgis://") %>
3
+ url: <%%= ENV["DATABASE_URL"] %>
4
4
  pool: <%%= ENV["DB_POOL_SIZE"] || 5 %>
5
5
  timeout: 5000
6
6
  database: engine_<%= name %>_test
@@ -3,7 +3,9 @@
3
3
  # Engine root is used by rails_configuration to correctly
4
4
  # load fixtures and support files
5
5
 
6
- ENGINE_ROOT = Pathname.new(File.expand_path("..", __dir__))
6
+ unless defined?(ENGINE_ROOT)
7
+ ENGINE_ROOT = Pathname.new(File.expand_path("..", __dir__))
8
+ end
7
9
 
8
10
  ENV["RAILS_ENV"] = "test"
9
11
  ENV["BOOTSNAP_CACHE_DIR"] = File.join(ENGINE_ROOT, "spec", "internal", "tmp", "cache")
@@ -41,7 +43,12 @@ end
41
43
  # Rails.application.default_url_options[:host] = "localhost"
42
44
  # <%= class_name %>::Engine.routes.default_url_options[:host] = "localhost"
43
45
 
44
- require "jets/testing/rails_configuration"
46
+ module Jets
47
+ module Testing
48
+ end
49
+ end
50
+
51
+ require "jets/testing/rails"
45
52
 
46
53
  # action_policy helpers
47
54
  # require "action_policy/rspec"
@@ -3,4 +3,4 @@
3
3
  require "bundler/setup"
4
4
  require "pry-byebug"
5
5
 
6
- require "jets/testing/rspec_configuration"
6
+ require "jets/testing/rspec"
@@ -0,0 +1,5 @@
1
+ Description:
2
+ This generator creates skeleton of a shared gem for the project.
3
+
4
+ Example:
5
+ rails generate jets:gem <name>
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+
5
+ module Jets
6
+ module Generators
7
+ class GemGenerator < ::Rails::Generators::NamedBase
8
+ namespace "jets:gem"
9
+ source_root File.expand_path("templates", __dir__)
10
+
11
+ desc "Generates a gem with given NAME with Jets conventions " \
12
+ "and configurations. \n\n"
13
+
14
+ def create_gem_file
15
+ directory(".", "gems/#{name}")
16
+
17
+ chmod "engines/#{name}/bin/console", 0o755, verbose: false
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path("lib", __dir__)
4
+
5
+ require "<%= name %>/version"
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "<%= name %>"
9
+ s.version = <%= class_name %>::VERSION
10
+ s.authors = ["TODO"]
11
+ s.summary = "TODO:"
12
+ s.description = "TODO:"
13
+
14
+ s.files = Dir["{config,lib}/**/*", "Rakefile"]
15
+ s.require_paths = ["lib"]
16
+
17
+ s.add_development_dependency "bundler", "~> 2"
18
+ s.add_development_dependency "pry-byebug", "~> 3.4"
19
+ s.add_development_dependency "rake", "~> 13.0"
20
+
21
+ # Internal
22
+ s.add_development_dependency "jets-rubocop", "~> 0.1"
23
+ s.add_development_dependency "jets-testing", "~> 0.1"
24
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) do |repo_name|
6
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
7
+ "https://github.com/#{repo_name}.git"
8
+ end
9
+
10
+ gemspec
11
+
12
+ eval_gemfile "./Gemfile.runtime"
13
+
14
+ gem "jets-testing"
15
+ gem "jets-rubocop"
@@ -0,0 +1,29 @@
1
+ # <%= class_name %>
2
+
3
+ ## Purpose
4
+
5
+ TODO: Purpose of this gem.
6
+
7
+ ## Architecture
8
+
9
+ TODO: Define the architecture of this gem.
10
+
11
+ ## Development Environment
12
+
13
+ TODO: Write instructions how to set up a development environment for this gem.
14
+
15
+ ## Test Environment
16
+
17
+ TODO: Write instructions how to set up a test environment for this gem.
18
+
19
+ ## Production Environment
20
+
21
+ TODO: Write instructions how to use this gem in production.
22
+
23
+ ## Continuous Integration
24
+
25
+ TODO: Write instructions on how this gem is continuously integrated.
26
+
27
+ ## Coding Style
28
+
29
+ TODO: Define coding style for this gem.
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "<%= name %>"
6
+
7
+ require "pry"
8
+ Pry.start
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "<%= name %>/version"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module <%= class_name %>
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV["RAILS_ENV"] = "test"
4
+
5
+ require "jets/testing/rails"
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+ require "pry-byebug"
5
+
6
+ require "jets/testing/rspec"
@@ -13,6 +13,11 @@ module Jets
13
13
  def set_rails_version
14
14
  template ".rails-version", "./.rails-version"
15
15
  end
16
+
17
+ def modify_gemfile
18
+ prepend_to_file "Gemfile", 'require "bundler/component"'
19
+ prepend_to_file "Gemfile", 'require "bundler/eval_gemfile"'
20
+ end
16
21
  end
17
22
  end
18
23
  end
@@ -10,6 +10,7 @@ module Jets
10
10
  class Railtie < ::Rails::Railtie
11
11
  generators do
12
12
  require "generators/jets/engine/engine_generator"
13
+ require "generators/jets/gem/gem_generator"
13
14
  require "generators/jets/install/install_generator"
14
15
  end
15
16
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jets
4
4
  module Rails
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jets-railtie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lauri Jutila
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-29 00:00:00.000000000 Z
11
+ date: 2020-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jets-bundler
@@ -159,14 +159,17 @@ extra_rdoc_files: []
159
159
  files:
160
160
  - README.md
161
161
  - jets-railtie.gemspec
162
+ - lib/generators/jets/engine/USAGE
162
163
  - lib/generators/jets/engine/engine_generator.rb
163
164
  - lib/generators/jets/engine/templates/%name%.gemspec.tt
164
165
  - lib/generators/jets/engine/templates/Gemfile
165
166
  - lib/generators/jets/engine/templates/Gemfile.runtime
166
167
  - lib/generators/jets/engine/templates/README.md.tt
167
168
  - lib/generators/jets/engine/templates/Rakefile.tt
169
+ - lib/generators/jets/engine/templates/app/controllers/%name%/application_controller.rb.tt
168
170
  - lib/generators/jets/engine/templates/bin/console.tt
169
171
  - lib/generators/jets/engine/templates/bin/rails.tt
172
+ - lib/generators/jets/engine/templates/config/routes.rb.tt
170
173
  - lib/generators/jets/engine/templates/lib/%name%.rb.tt
171
174
  - lib/generators/jets/engine/templates/lib/%name%/engine.rb.tt
172
175
  - lib/generators/jets/engine/templates/lib/%name%/version.rb.tt
@@ -175,6 +178,18 @@ files:
175
178
  - lib/generators/jets/engine/templates/spec/internal/db/schema.rb
176
179
  - lib/generators/jets/engine/templates/spec/rails_helper.rb.tt
177
180
  - lib/generators/jets/engine/templates/spec/spec_helper.rb
181
+ - lib/generators/jets/gem/USAGE
182
+ - lib/generators/jets/gem/gem_generator.rb
183
+ - lib/generators/jets/gem/templates/%name%.gemspec.tt
184
+ - lib/generators/jets/gem/templates/Gemfile
185
+ - lib/generators/jets/gem/templates/Gemfile.runtime
186
+ - lib/generators/jets/gem/templates/README.md.tt
187
+ - lib/generators/jets/gem/templates/Rakefile.tt
188
+ - lib/generators/jets/gem/templates/bin/console.tt
189
+ - lib/generators/jets/gem/templates/lib/%name%.rb.tt
190
+ - lib/generators/jets/gem/templates/lib/%name%/version.rb.tt
191
+ - lib/generators/jets/gem/templates/spec/rails_helper.rb
192
+ - lib/generators/jets/gem/templates/spec/spec_helper.rb
178
193
  - lib/generators/jets/install/install_generator.rb
179
194
  - lib/jets-railtie.rb
180
195
  - lib/jets/rails.rb