packs-rails 0.0.5 → 0.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 +4 -4
- data/README.md +32 -22
- data/bin/console +3 -3
- data/bin/tapioca +6 -6
- data/lib/packs/rails/integrations/factory_bot.rb +2 -2
- data/lib/packs/rails/integrations/rails.rb +1 -41
- data/lib/packs/rails/integrations/rspec.rb +3 -2
- data/lib/packs/rails/integrations.rb +4 -4
- data/lib/packs/rails/railtie.rb +1 -2
- data/lib/packs/rails/rspec.rb +1 -1
- data/lib/packs/rails/version.rb +1 -1
- data/lib/packs-rails.rb +5 -6
- metadata +23 -13
- data/lib/packs/rails/stim.rb +0 -42
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d2e9f532a3a4f70f1b79b28f767749552e96090e125f0db9747f44d3af937eaa
|
|
4
|
+
data.tar.gz: ec421b9cba3a19abe3ba0ac684b954889905bd98718f36958a3436cae837b8a6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 06fcc2e86606108d58294af5602d885b50824abf18fef2e370b755d8972a3392a2ff7405fcc18107e75f7f590749334c8d097203545ad49f0d987ab03456650a
|
|
7
|
+
data.tar.gz: 93b094f556c388de9f22dfdb6edada5124bc549789d3d3c16394fc7b49b202c48aa5914406b0e8166d051301720e63dcbd60ab1d097ba6bf1bc03808e8092be8
|
data/README.md
CHANGED
|
@@ -59,6 +59,21 @@ From there, you can create a `./packs` folder and structure it using the convent
|
|
|
59
59
|
|
|
60
60
|
If you wish to use a different directory name, eg `components` instead of `packs`, you can customize this by configuring `packs.yml`. See [`packs`](https://github.com/rubyatscale/packs) for more information.
|
|
61
61
|
|
|
62
|
+
If you want to have your packs code namespaced without adding a directory with the pack's name into the directory structure, you can use the [automatic namespaces gem](https://github.com/gap777/automatic_namespaces).
|
|
63
|
+
|
|
64
|
+
## Modify spring to detect pack moves
|
|
65
|
+
|
|
66
|
+
If you use spring, when you move a pack, you'll want spring to update its cache
|
|
67
|
+
|
|
68
|
+
Add this to one of your initializers
|
|
69
|
+
```ruby
|
|
70
|
+
Packs::Specification::Configuration.fetch.pack_paths.each do |dir|
|
|
71
|
+
Dir["#{dir}/package.yml"].each do |package_yml|
|
|
72
|
+
Spring.watch(package_yml)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
```
|
|
76
|
+
|
|
62
77
|
### Splitting routes
|
|
63
78
|
`packs-rails` allows you to split your application routes for every pack. You just have to create a file describing your routes and then `draw` them in your root `config/routes.rb` file (NOTE: the `draw` function is only in Rails 6.1+).
|
|
64
79
|
|
|
@@ -72,28 +87,6 @@ Rails.application.routes.draw do
|
|
|
72
87
|
end
|
|
73
88
|
```
|
|
74
89
|
|
|
75
|
-
### Making your Package an Engine
|
|
76
|
-
Add `engine: true` to your `package.yml` to make it an actual Rails engine ([read more about what this means here](https://guides.rubyonrails.org/engines.html)):
|
|
77
|
-
```yml
|
|
78
|
-
# packs/my_pack/package.yml
|
|
79
|
-
enforce_dependencies: true
|
|
80
|
-
enforce_privacy: true
|
|
81
|
-
metadata:
|
|
82
|
-
engine: true
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Add `engine_name: ` to your `package.yml` to use a specific, maybe namespaced, engine name instead of the last package folder name.
|
|
86
|
-
```yml
|
|
87
|
-
# packs/my_pack/package.yml
|
|
88
|
-
enforce_dependencies: true
|
|
89
|
-
enforce_privacy: true
|
|
90
|
-
metadata:
|
|
91
|
-
engine: true
|
|
92
|
-
engine_name: namespaced/my_pack
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
The engine is created as `Namespaced::MyPack::Engine` instead of `MyPack::Engine`.
|
|
96
|
-
|
|
97
90
|
## Ecosystem and Integrations
|
|
98
91
|
|
|
99
92
|
### RSpec Integration
|
|
@@ -150,6 +143,23 @@ packs/
|
|
|
150
143
|
my_private_namespaced_model_factory.rb
|
|
151
144
|
```
|
|
152
145
|
|
|
146
|
+
#### rubocop-rails
|
|
147
|
+
[rubocop-rails](https://github.com/rubocop/rubocop-rails) [targets paths](https://github.com/rubocop/rubocop-rails/blob/master/config/default.yml) starting with `app/`. You might need to override the `Include` globs to include your packs code.
|
|
148
|
+
|
|
149
|
+
Examples:
|
|
150
|
+
```yml
|
|
151
|
+
Rails/EnumHash:
|
|
152
|
+
Include:
|
|
153
|
+
- '**/app/models/**/*.rb'
|
|
154
|
+
Rails/InverseOf:
|
|
155
|
+
Include:
|
|
156
|
+
- '**/app/models/**/*.rb'
|
|
157
|
+
Rails/LexicallyScopedActionFilter:
|
|
158
|
+
Include:
|
|
159
|
+
- '**/app/controllers/**/*.rb'
|
|
160
|
+
- '**/app/mailers/**/*.rb'
|
|
161
|
+
```
|
|
162
|
+
|
|
153
163
|
#### parallel_tests
|
|
154
164
|
|
|
155
165
|
`parallel_tests` has it its own spec discovery mechanism, so packs-rails's RSpec integration doesn't do anything when you use them together.
|
data/bin/console
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'packs-rails'
|
|
5
5
|
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
|
@@ -10,5 +10,5 @@ require "packs-rails"
|
|
|
10
10
|
# require "pry"
|
|
11
11
|
# Pry.start
|
|
12
12
|
|
|
13
|
-
require
|
|
13
|
+
require 'irb'
|
|
14
14
|
IRB.start(__FILE__)
|
data/bin/tapioca
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
# this file is here to facilitate running it.
|
|
9
9
|
#
|
|
10
10
|
|
|
11
|
-
require
|
|
12
|
-
ENV[
|
|
11
|
+
require 'pathname'
|
|
12
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
|
13
13
|
Pathname.new(__FILE__).realpath)
|
|
14
14
|
|
|
15
|
-
bundle_binstub = File.expand_path(
|
|
15
|
+
bundle_binstub = File.expand_path('bundle', __dir__)
|
|
16
16
|
|
|
17
17
|
if File.file?(bundle_binstub)
|
|
18
18
|
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
@@ -23,7 +23,7 @@ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this
|
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
require
|
|
27
|
-
require
|
|
26
|
+
require 'rubygems'
|
|
27
|
+
require 'bundler/setup'
|
|
28
28
|
|
|
29
|
-
load Gem.bin_path(
|
|
29
|
+
load Gem.bin_path('tapioca', 'tapioca')
|
|
@@ -8,8 +8,8 @@ module Packs
|
|
|
8
8
|
return unless app.config.respond_to?(:factory_bot)
|
|
9
9
|
|
|
10
10
|
Packs.all.reject(&:is_gem?).each do |pack|
|
|
11
|
-
app.config.factory_bot.definition_file_paths << pack.relative_path.join(
|
|
12
|
-
app.config.factory_bot.definition_file_paths << pack.relative_path.join(
|
|
11
|
+
app.config.factory_bot.definition_file_paths << pack.relative_path.join('spec/factories').to_s
|
|
12
|
+
app.config.factory_bot.definition_file_paths << pack.relative_path.join('test/factories').to_s
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -1,67 +1,27 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
# typed: true
|
|
3
3
|
|
|
4
|
-
require
|
|
4
|
+
require 'active_support/inflections'
|
|
5
5
|
|
|
6
6
|
module Packs
|
|
7
7
|
module Rails
|
|
8
8
|
module Integrations
|
|
9
9
|
class Rails
|
|
10
|
-
CONFIG_ROUTES_PATH = "config/routes".freeze
|
|
11
|
-
|
|
12
10
|
def initialize(app)
|
|
13
11
|
@app = app
|
|
14
12
|
|
|
15
13
|
Packs::Rails.config.paths.freeze
|
|
16
14
|
|
|
17
|
-
create_engines
|
|
18
15
|
inject_paths
|
|
19
16
|
end
|
|
20
17
|
|
|
21
|
-
def create_engines
|
|
22
|
-
Packs.all.reject(&:is_gem?).each do |pack|
|
|
23
|
-
next unless pack.metadata['engine']
|
|
24
|
-
|
|
25
|
-
create_engine(pack)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
18
|
def inject_paths
|
|
30
19
|
Packs.all.reject(&:is_gem?).each do |pack|
|
|
31
20
|
Packs::Rails.config.paths.each do |path|
|
|
32
|
-
# Prior to Rails 6.1, the "config/routes" app path is nil and was not added until drawable routes feature was implemented
|
|
33
|
-
# https://github.com/rails/rails/pull/37892/files#diff-a785e41df3f87063a8fcffcac726856a25d8eae6d1f9bca2b36989fe88613f8eR62
|
|
34
|
-
next if pre_rails_6_1? && path == CONFIG_ROUTES_PATH
|
|
35
|
-
|
|
36
21
|
@app.paths[path] << pack.relative_path.join(path)
|
|
37
22
|
end
|
|
38
23
|
end
|
|
39
24
|
end
|
|
40
|
-
|
|
41
|
-
private
|
|
42
|
-
|
|
43
|
-
def pre_rails_6_1?
|
|
44
|
-
return @_pre_rails_6_1 if defined?(@_pre_rails_6_1)
|
|
45
|
-
@_pre_rails_6_1 = ::Rails.gem_version < Gem::Version.new("6.1")
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def create_namespace(name)
|
|
49
|
-
namespace = ActiveSupport::Inflector.camelize(name)
|
|
50
|
-
namespace.split("::").reduce(Object) do |base, mod|
|
|
51
|
-
if base.const_defined?(mod, false)
|
|
52
|
-
base.const_get(mod, false)
|
|
53
|
-
else
|
|
54
|
-
base.const_set(mod, Module.new)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def create_engine(pack)
|
|
60
|
-
name = pack.metadata.fetch("engine_name", pack.last_name)
|
|
61
|
-
namespace = create_namespace(name)
|
|
62
|
-
stim = Stim.new(pack, namespace)
|
|
63
|
-
namespace.const_set("Engine", Class.new(::Rails::Engine)).include(stim)
|
|
64
|
-
end
|
|
65
25
|
end
|
|
66
26
|
end
|
|
67
27
|
end
|
|
@@ -17,6 +17,7 @@ module Packs
|
|
|
17
17
|
|
|
18
18
|
pack_paths = Packs.all.map do |pack|
|
|
19
19
|
next if pack.is_gem?
|
|
20
|
+
|
|
20
21
|
spec_path = pack.relative_path.join(default_path)
|
|
21
22
|
spec_path.to_s if spec_path.exist?
|
|
22
23
|
end
|
|
@@ -28,11 +29,11 @@ module Packs
|
|
|
28
29
|
# end of it.
|
|
29
30
|
#
|
|
30
31
|
# packs/my_pack => packs/my_pack/spec
|
|
31
|
-
#
|
|
32
|
+
#
|
|
32
33
|
# If it doesn't match a pack path, we leave it alone.
|
|
33
34
|
|
|
34
35
|
to_run.map! do |path|
|
|
35
|
-
if pack = Packs.find(path)
|
|
36
|
+
if (pack = Packs.find(path))
|
|
36
37
|
[
|
|
37
38
|
pack,
|
|
38
39
|
*nested_packs_for(pack)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'active_support'
|
|
2
2
|
|
|
3
3
|
module Packs
|
|
4
4
|
module Rails
|
|
5
5
|
module Integrations
|
|
6
|
-
autoload :FactoryBot,
|
|
7
|
-
autoload :Rails,
|
|
8
|
-
autoload :RSpec,
|
|
6
|
+
autoload :FactoryBot, 'packs/rails/integrations/factory_bot'
|
|
7
|
+
autoload :Rails, 'packs/rails/integrations/rails'
|
|
8
|
+
autoload :RSpec, 'packs/rails/integrations/rspec'
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
end
|
data/lib/packs/rails/railtie.rb
CHANGED
data/lib/packs/rails/rspec.rb
CHANGED
data/lib/packs/rails/version.rb
CHANGED
data/lib/packs-rails.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'packs'
|
|
2
|
-
require
|
|
3
|
-
require
|
|
2
|
+
require 'active_support'
|
|
3
|
+
require 'rails/application'
|
|
4
4
|
require 'sorbet-runtime'
|
|
5
5
|
|
|
6
6
|
module Packs
|
|
@@ -9,7 +9,6 @@ module Packs
|
|
|
9
9
|
|
|
10
10
|
autoload :Integrations
|
|
11
11
|
autoload :Railtie
|
|
12
|
-
autoload :Stim
|
|
13
12
|
|
|
14
13
|
class Error < StandardError; end
|
|
15
14
|
|
|
@@ -22,7 +21,7 @@ module Packs
|
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
@config = ActiveSupport::OrderedOptions.new
|
|
25
|
-
@config.paths = %w
|
|
24
|
+
@config.paths = %w[
|
|
26
25
|
app
|
|
27
26
|
app/controllers
|
|
28
27
|
app/channels
|
|
@@ -36,8 +35,8 @@ module Packs
|
|
|
36
35
|
config/locales
|
|
37
36
|
config/initializers
|
|
38
37
|
config/routes
|
|
39
|
-
|
|
38
|
+
]
|
|
40
39
|
end
|
|
41
40
|
|
|
42
|
-
require
|
|
41
|
+
require 'packs/rails/railtie'
|
|
43
42
|
end
|
metadata
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: packs-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ngan Pham
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
13
|
+
name: activesupport
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
@@ -25,7 +24,7 @@ dependencies:
|
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '0'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
27
|
+
name: packs
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
30
|
- - ">="
|
|
@@ -39,14 +38,28 @@ dependencies:
|
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: '0'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
41
|
+
name: railties
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
44
|
- - ">="
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
46
|
+
version: '7'
|
|
48
47
|
type: :runtime
|
|
49
48
|
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '7'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: debug
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
50
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
64
|
requirements:
|
|
52
65
|
- - ">="
|
|
@@ -81,7 +94,7 @@ dependencies:
|
|
|
81
94
|
- !ruby/object:Gem::Version
|
|
82
95
|
version: '0'
|
|
83
96
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
97
|
+
name: rubocop
|
|
85
98
|
requirement: !ruby/object:Gem::Requirement
|
|
86
99
|
requirements:
|
|
87
100
|
- - ">="
|
|
@@ -155,7 +168,6 @@ files:
|
|
|
155
168
|
- lib/packs/rails/integrations/rspec.rb
|
|
156
169
|
- lib/packs/rails/railtie.rb
|
|
157
170
|
- lib/packs/rails/rspec.rb
|
|
158
|
-
- lib/packs/rails/stim.rb
|
|
159
171
|
- lib/packs/rails/version.rb
|
|
160
172
|
homepage: https://github.com/rubyatscale/packs-rails
|
|
161
173
|
licenses:
|
|
@@ -164,7 +176,6 @@ metadata:
|
|
|
164
176
|
homepage_uri: https://github.com/rubyatscale/packs-rails
|
|
165
177
|
source_code_uri: https://github.com/rubyatscale/packs-rails
|
|
166
178
|
changelog_uri: https://github.com/rubyatscale/packs-rails/releases
|
|
167
|
-
post_install_message:
|
|
168
179
|
rdoc_options: []
|
|
169
180
|
require_paths:
|
|
170
181
|
- lib
|
|
@@ -172,15 +183,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
172
183
|
requirements:
|
|
173
184
|
- - ">="
|
|
174
185
|
- !ruby/object:Gem::Version
|
|
175
|
-
version: '
|
|
186
|
+
version: '3.1'
|
|
176
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
188
|
requirements:
|
|
178
189
|
- - ">="
|
|
179
190
|
- !ruby/object:Gem::Version
|
|
180
191
|
version: '0'
|
|
181
192
|
requirements: []
|
|
182
|
-
rubygems_version: 3.
|
|
183
|
-
signing_key:
|
|
193
|
+
rubygems_version: 3.6.9
|
|
184
194
|
specification_version: 4
|
|
185
195
|
summary: A Rails helper to package your code.
|
|
186
196
|
test_files: []
|
data/lib/packs/rails/stim.rb
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# typed: true
|
|
2
|
-
|
|
3
|
-
module Packs
|
|
4
|
-
module Rails
|
|
5
|
-
class Stim < Module
|
|
6
|
-
extend T::Sig
|
|
7
|
-
|
|
8
|
-
sig { params(pack: Packs::Pack, namespace: Module).void }
|
|
9
|
-
def initialize(pack, namespace)
|
|
10
|
-
@pack = pack
|
|
11
|
-
@namespace = namespace
|
|
12
|
-
super()
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def included(engine)
|
|
16
|
-
engine.called_from = @pack.relative_path
|
|
17
|
-
engine.extend(ClassMethods)
|
|
18
|
-
engine.isolate_namespace(@namespace)
|
|
19
|
-
|
|
20
|
-
# Set all of these paths to nil because we want the Rails integration to take
|
|
21
|
-
# care of them. The purpose of this Engine is really just for the namespace
|
|
22
|
-
# isolation.
|
|
23
|
-
(Packs::Rails.config.paths +
|
|
24
|
-
# In addition to the paths we've delegated to the main app, we don't allow
|
|
25
|
-
# Engine Packs to have various capabilities.
|
|
26
|
-
%w(
|
|
27
|
-
config/environments
|
|
28
|
-
db/migrate
|
|
29
|
-
)
|
|
30
|
-
).uniq.each do |path|
|
|
31
|
-
engine.paths[path] = nil
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
module ClassMethods
|
|
36
|
-
def find_root(_from)
|
|
37
|
-
T.unsafe(self).called_from
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|