domain_engine 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +2 -0
- data/README.md +79 -0
- data/domain_engine.gemspec +18 -0
- data/lib/domain_engine/version.rb +3 -0
- data/lib/domain_engine.rb +4 -0
- data/lib/generators/domain_engine/new_generator.rb +70 -0
- data/lib/generators/templates/application_controller.rb.tt +4 -0
- data/lib/generators/templates/controller_extension.rb.tt +20 -0
- data/lib/generators/templates/engine.rb.tt +5 -0
- data/lib/generators/templates/hellos_controller.rb.tt +7 -0
- data/lib/generators/templates/hellos_controller_spec.rb.tt +11 -0
- data/lib/generators/templates/package.yml.tt +2 -0
- data/lib/generators/templates/package_helper.rb.tt +8 -0
- data/lib/generators/templates/routes.rb.tt +3 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c5754785172c640582cb6a3f167192920be3d02a4a21079137126cdc2bcbe79a
|
4
|
+
data.tar.gz: d13ffd999cd838669b9f563b01a7192ceed44892d08fa0a3185fcfdee52724ac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 71dc0bc572601fb9f2da82cca6bfdae3ce659528fdd6a5d26c3bcdc484a4cf8c569fbaaad90a0472ad39d8f1067f388fa45cab71b2e08db34ea14c90e9b10bd6
|
7
|
+
data.tar.gz: 507e0274e5fcc7bade0f6d259fe7808b8c0763267290acab007e0f8bc935df538ddcb546b545dce4b4af9af9068dbeaac0c87f5801336bb2455a7d913eefdd65
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Domain Engine
|
2
|
+
|
3
|
+
This gem provides a rails generator for scaffolding new domain engines in a Rails project.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add it to your Gemfile under the development dependencies:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
group :development do
|
11
|
+
gem "domain_engine"
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
You can invoke it like any other generator. It requires an argument for the name of your domain.
|
18
|
+
The name can be provided as a class name (`MyDomain`) or a file name (`my_domain`)
|
19
|
+
|
20
|
+
`rails g domain_engine:new MyDomain`
|
21
|
+
|
22
|
+
The following folders are created under a `domains` folder in the root of the Rails app (`domains` is also created if it does not exist):
|
23
|
+
|
24
|
+
``` shell
|
25
|
+
domains/my_domain/
|
26
|
+
├── app
|
27
|
+
│ ├── blueprints
|
28
|
+
│ │ └── my_domain
|
29
|
+
│ ├── commands
|
30
|
+
│ │ └── my_domain
|
31
|
+
│ ├── controllers
|
32
|
+
│ │ └── my_domain
|
33
|
+
│ │ ├── application_controller.rb
|
34
|
+
│ │ └── hellos_controller.rb
|
35
|
+
│ ├── domain
|
36
|
+
│ │ └── my_domain
|
37
|
+
│ ├── infrastructure
|
38
|
+
│ │ └── my_domain
|
39
|
+
│ ├── jobs
|
40
|
+
│ │ └── my_domain
|
41
|
+
│ ├── models
|
42
|
+
│ │ └── my_domain
|
43
|
+
│ └── queries
|
44
|
+
│ └── my_domain
|
45
|
+
├── config
|
46
|
+
│ └── routes.rb
|
47
|
+
├── doc
|
48
|
+
├── lib
|
49
|
+
│ ├── engine.rb
|
50
|
+
│ └── tasks
|
51
|
+
├── package.yml
|
52
|
+
└── spec
|
53
|
+
├── commands
|
54
|
+
│ └── my_domain
|
55
|
+
├── controllers
|
56
|
+
│ └── my_domain
|
57
|
+
│ └── hellos_controller_spec.rb
|
58
|
+
├── domain
|
59
|
+
│ └── my_domain
|
60
|
+
├── factories
|
61
|
+
├── fixtures
|
62
|
+
├── infrastructure
|
63
|
+
│ └── my_domain
|
64
|
+
├── jobs
|
65
|
+
│ └── my_domain
|
66
|
+
├── models
|
67
|
+
│ └── my_domain
|
68
|
+
├── package_helper.rb
|
69
|
+
├── queries
|
70
|
+
│ └── my_domain
|
71
|
+
├── requests
|
72
|
+
│ └── my_domain
|
73
|
+
└── support
|
74
|
+
└── controller_extension.rb
|
75
|
+
```
|
76
|
+
|
77
|
+
## Verify
|
78
|
+
|
79
|
+
Once completed you can verify that your domain works by running `rspec domains/my_domain` and see the example spec pass.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path('lib/domain_engine/version', __dir__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'domain_engine'
|
5
|
+
spec.version = DomainEngine::VERSION
|
6
|
+
spec.authors = ['Josh Cass']
|
7
|
+
spec.email = ['josh@bonus.ly']
|
8
|
+
spec.summary = 'Provides a rails generator for Bonusly domain engines'
|
9
|
+
spec.homepage = 'https://gitlab.com/bonusly/engineering/gems/domain-engine'
|
10
|
+
spec.license = 'MIT'
|
11
|
+
spec.required_ruby_version = '>= 3.2.2'
|
12
|
+
spec.require_paths = ['lib']
|
13
|
+
spec.files = Dir['README.md', 'lib/**/*.rb', 'lib/**/*.rb.tt', 'lib/**/*.yml.tt', 'domain_engine.gemspec', 'Gemfile', 'Rakefile']
|
14
|
+
|
15
|
+
spec.add_dependency 'railties', '>= 7.0'
|
16
|
+
|
17
|
+
spec.add_development_dependency 'solargraph', '>= 0.50'
|
18
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module DomainEngine
|
4
|
+
module Generators
|
5
|
+
class NewGenerator < Rails::Generators::NamedBase
|
6
|
+
desc 'Generates scaffolding for a package engine under /domains/NAME'
|
7
|
+
|
8
|
+
source_root File.expand_path('../templates', __dir__)
|
9
|
+
|
10
|
+
def create_top_level_directories
|
11
|
+
empty_directory 'domains'
|
12
|
+
empty_directory "domains/#{file_name}"
|
13
|
+
empty_directory "domains/#{file_name}/app"
|
14
|
+
empty_directory "domains/#{file_name}/config"
|
15
|
+
empty_directory "domains/#{file_name}/lib"
|
16
|
+
empty_directory "domains/#{file_name}/spec"
|
17
|
+
empty_directory_with_keep_file "domains/#{file_name}/doc"
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_sub_directories
|
21
|
+
empty_directory "domains/#{file_name}/app/controllers/#{file_name}"
|
22
|
+
empty_directory "domains/#{file_name}/spec/controllers/#{file_name}"
|
23
|
+
empty_directory "domains/#{file_name}/spec/support"
|
24
|
+
|
25
|
+
empty_directory_with_keep_file "domains/#{file_name}/app/blueprints/#{file_name}"
|
26
|
+
empty_directory_with_keep_file "domains/#{file_name}/app/commands/#{file_name}"
|
27
|
+
empty_directory_with_keep_file "domains/#{file_name}/app/domain/#{file_name}"
|
28
|
+
empty_directory_with_keep_file "domains/#{file_name}/app/infrastructure/#{file_name}"
|
29
|
+
empty_directory_with_keep_file "domains/#{file_name}/app/jobs/#{file_name}"
|
30
|
+
empty_directory_with_keep_file "domains/#{file_name}/app/models/#{file_name}"
|
31
|
+
empty_directory_with_keep_file "domains/#{file_name}/app/queries/#{file_name}"
|
32
|
+
|
33
|
+
empty_directory_with_keep_file "domains/#{file_name}/lib/tasks"
|
34
|
+
|
35
|
+
empty_directory_with_keep_file "domains/#{file_name}/spec/factories"
|
36
|
+
empty_directory_with_keep_file "domains/#{file_name}/spec/fixtures"
|
37
|
+
empty_directory_with_keep_file "domains/#{file_name}/spec/commands/#{file_name}"
|
38
|
+
empty_directory_with_keep_file "domains/#{file_name}/spec/domain/#{file_name}"
|
39
|
+
empty_directory_with_keep_file "domains/#{file_name}/spec/infrastructure/#{file_name}"
|
40
|
+
empty_directory_with_keep_file "domains/#{file_name}/spec/jobs/#{file_name}"
|
41
|
+
empty_directory_with_keep_file "domains/#{file_name}/spec/models/#{file_name}"
|
42
|
+
empty_directory_with_keep_file "domains/#{file_name}/spec/queries/#{file_name}"
|
43
|
+
empty_directory_with_keep_file "domains/#{file_name}/spec/requests/#{file_name}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def create_files
|
47
|
+
template 'package.yml', "domains/#{file_name}/package.yml"
|
48
|
+
template 'engine.rb', "domains/#{file_name}/lib/engine.rb"
|
49
|
+
template 'routes.rb', "domains/#{file_name}/config/routes.rb"
|
50
|
+
template 'application_controller.rb', "domains/#{file_name}/app/controllers/#{file_name}/application_controller.rb"
|
51
|
+
template 'hellos_controller.rb', "domains/#{file_name}/app/controllers/#{file_name}/hellos_controller.rb"
|
52
|
+
template 'package_helper.rb', "domains/#{file_name}/spec/package_helper.rb"
|
53
|
+
template 'controller_extension.rb', "domains/#{file_name}/spec/support/controller_extension.rb"
|
54
|
+
template 'hellos_controller_spec.rb',
|
55
|
+
"domains/#{file_name}/spec/controllers/#{file_name}/hellos_controller_spec.rb"
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def empty_directory_with_keep_file(destination)
|
61
|
+
empty_directory destination
|
62
|
+
keep_file destination
|
63
|
+
end
|
64
|
+
|
65
|
+
def keep_file(destination)
|
66
|
+
create_file("#{destination}/.keep")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module <%= class_name %>
|
2
|
+
module ControllerExtension
|
3
|
+
def self.included(base)
|
4
|
+
base.routes { <%=class_name %>::Engine.routes }
|
5
|
+
end
|
6
|
+
|
7
|
+
# You may add more controller extension code here
|
8
|
+
# for example you might want to provide a method to
|
9
|
+
# easily authenticate a user in your specs:
|
10
|
+
#
|
11
|
+
# def authenticate_user(user_id: BSON::ObjectId.new, company_id: BSON::ObjectId.new)
|
12
|
+
# allow(controller).to receive(:authenticator).and_return(
|
13
|
+
# double("Mock::Api::Authenticator",
|
14
|
+
# authenticate: true,
|
15
|
+
# authenticated_user_id: user_id,
|
16
|
+
# authenticated_company_id: company_id)
|
17
|
+
# )
|
18
|
+
# end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require_relative '../../package_helper'
|
2
|
+
|
3
|
+
RSpec.describe <%= class_name %>::HellosController do
|
4
|
+
include <%= class_name %>::ControllerExtension
|
5
|
+
|
6
|
+
it "says hello" do
|
7
|
+
get :index
|
8
|
+
|
9
|
+
expect(JSON.parse(response.body)["message"]).to eq "hello world!"
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Load spec helper from the main app
|
2
|
+
require File.expand_path("../../../spec/spec_helper.rb", __dir__)
|
3
|
+
|
4
|
+
# Load package engine factories
|
5
|
+
Dir.glob(File.expand_path("factories/**/*.rb", __dir__)).sort.each { |f| require f }
|
6
|
+
|
7
|
+
# Load package engine spec support
|
8
|
+
Dir.glob(File.expand_path("support/**/*.rb", __dir__)).sort.each { |f| require f }
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: domain_engine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Cass
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 1980-01-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '7.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '7.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: solargraph
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.50'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.50'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- josh@bonus.ly
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- Gemfile
|
49
|
+
- README.md
|
50
|
+
- domain_engine.gemspec
|
51
|
+
- lib/domain_engine.rb
|
52
|
+
- lib/domain_engine/version.rb
|
53
|
+
- lib/generators/domain_engine/new_generator.rb
|
54
|
+
- lib/generators/templates/application_controller.rb.tt
|
55
|
+
- lib/generators/templates/controller_extension.rb.tt
|
56
|
+
- lib/generators/templates/engine.rb.tt
|
57
|
+
- lib/generators/templates/hellos_controller.rb.tt
|
58
|
+
- lib/generators/templates/hellos_controller_spec.rb.tt
|
59
|
+
- lib/generators/templates/package.yml.tt
|
60
|
+
- lib/generators/templates/package_helper.rb.tt
|
61
|
+
- lib/generators/templates/routes.rb.tt
|
62
|
+
homepage: https://gitlab.com/bonusly/engineering/gems/domain-engine
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 3.2.2
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubygems_version: 3.4.22
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Provides a rails generator for Bonusly domain engines
|
85
|
+
test_files: []
|