stimpack 0.8.3 → 1.0.0.alpha1

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: ee9d95c857e2c73710212e52a6e971fb95acff552596eeddb6f4f43363c8a691
4
- data.tar.gz: fea0ccd68662307735ce43893ca3fc00167d31a8a557449aaffe2393ced6c796
3
+ metadata.gz: aedf6786a9c8dce60f5d90bf3f9b97bea858d3faeac218c2991a5ed5dd61503e
4
+ data.tar.gz: 1b7c218dc706f75f77d4d1e6e099f174520c26ebbf573f985f05e6e28a343af8
5
5
  SHA512:
6
- metadata.gz: 4efa4b625c20b4169d696e28357a14dd7b06b194673852c3b8d59ad449dcff42bc618ea62a23ae0bfed668d4318b3a8c7de12ece8a22585782afd29da88077b7
7
- data.tar.gz: 004d9f9c681456efead9801881330d635af3410131b125eb149b5fe535f62fb84372dc4c586d073c7c93787f3345872f08c3efa22571fa9099dc6a8345f746c2
6
+ metadata.gz: be4a82f48f0c966edfc9c86c096d4e8cbfe7f23177007ddd91bffe769ac7fab05921f6b7c2855b8fbadc49c54aede9024b1820f76ecbe988b492507adc3fc212
7
+ data.tar.gz: 889c48f4b28b1260e6387ba6205f5b586846630c33182f680bbbaf8bfe0a18f89529b16ef87c562991452da74bbd2191168189d1b7f4380e56448eabe586fae1
data/README.md CHANGED
@@ -1,149 +1,35 @@
1
1
  # Stimpack
2
2
 
3
- `stimpack` establishes and implements a set of conventions for splitting up large monoliths built on top of [`packwerk`](https://github.com/Shopify/packwerk). With `stimpack`, new packages' autoload paths are automatically added to Rails, so your code will immediately become usable and loadable without additional configuration.
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/stimpack`. To experiment with that code, run `bin/console` for an interactive prompt.
4
4
 
5
- Here is an example application that uses `stimpack`:
6
- ```
7
- package.yml # root level pack
8
- app/ # Unpackaged code
9
- models/
10
- ...
11
- packs/
12
- my_domain/
13
- package.yml # See the packwerk docs for more info
14
- deprecated_references.yml # See the packwerk docs for more info
15
- app/
16
- public/ # Recommended location for public API
17
- my_domain.rb # creates the primary namespaces
18
- my_domain/
19
- my_subdomain.rb
20
- services/ # Private services
21
- my_domain/
22
- some_private_class.rb
23
- models/ # Private models
24
- some_other_non_namespaced_private_model.rb # this works too
25
- my_domain/
26
- my_private_namespacd_model.rb
27
- controllers/
28
- views/
29
- config/
30
- initializers/ # Initializers can live in packs and load as expected
31
- lib/
32
- tasks/
33
- spec/ # With stimpack, specs for a pack live next to the pack
34
- public/
35
- my_domain_spec.rb
36
- my_domain/
37
- my_subdomain_spec.rb
38
- services/
39
- my_domain/
40
- some_private_class_spec.rb
41
- models/
42
- some_other_non_namespaced_private_model_spec.rb
43
- my_domain/
44
- my_private_namespaced_model_spec.rb
45
- factories/ # Stimpack will automatically load pack factories into FactoryBot
46
- my_domain/
47
- my_private_namespaced_model_factory.rb
48
- my_other_domain/
49
- ... # other packs have a similar structure
50
- my_other_other_domain/
51
- ...
52
- ```
53
-
54
- ## Usage
5
+ TODO: Delete this and the text above, and describe your gem
55
6
 
56
- Setting up `stimpack` is straightforward. Simply by including `stimpack` in your `Gemfile` in all environments, `stimpack` will automatically hook into and configure Rails.
7
+ ## Installation
57
8
 
58
- From there, you can create a `./packs` folder and structure it using the conventions listed above.
59
-
60
- If you wish to use a different directory name, eg `components` instead of `packs`, you can customize this in your `config/application.rb` file:
9
+ Add this line to your application's Gemfile:
61
10
 
62
11
  ```ruby
63
- # Customize Stimpack's root directory. Note that this has to be done _before_ the Application
64
- # class is declared.
65
- Stimpack.config.root = "components"
66
-
67
- module MyCoolApp
68
- class Application < Rails::Application
69
- # ...
70
- end
71
- end
72
- ```
73
-
74
- ### Splitting routes
75
- `stimpack` 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.
76
-
77
- ```ruby
78
- # packs/my_domain/config/routes/my_domain.rb
79
- resources :my_resource
80
-
81
- # config/routes.rb
82
- draw(:my_domain)
83
- ```
84
-
85
- ### Making your Package an Engine
86
- 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)):
87
- ```yml
88
- # packs/my_pack/package.yml
89
- enforce_dependencies: true
90
- enforce_privacy: true
91
- metadata:
92
- engine: true
93
- ```
94
-
95
- ## Ecosystem and Integrations
96
-
97
- ### RSpec Integration
98
- Simply add `--require stimpack/rspec` to your `.rspec`.
99
- Or, if you'd like, pass it as an argument to `rspec`:
100
-
101
- ```
102
- $ rspec --require stimpack/rspec ...
12
+ gem "stimpack"
103
13
  ```
104
14
 
105
- Integration will allow you to run tests as such:
106
- ```
107
- # Run all specs in your entire application (packs and all):
108
- rspec
109
-
110
- # Run just that one test:
111
- rspec spec/some/specific_spec.rb
15
+ And then execute:
112
16
 
113
- # Run all tests under the "foobar" pack and all the tests of its nested packs:
114
- rspec packs/foobar
17
+ $ bundle install
115
18
 
116
- # Same as above but also adds the "binbaz" pack:
117
- rspec packs/foobar pack/binbaz
19
+ Or install it yourself as:
118
20
 
119
- # Run all test files inside the "packs/foobar/spec" directory:
120
- rspec packs/foobar/spec
21
+ $ gem install stimpack
121
22
 
122
- # Run all specs under the "packs/foobar/nested_pack" pack:
123
- rspec packs/foobar/nested_pack
124
- ```
125
-
126
- #### parallel_tests
127
-
128
- `parallel_tests` has it its own spec discovery mechanism, so Stimpack's RSpec integration doesn't do anything when you use them together.
129
- To make them work, you'll need to explicitly specify the spec paths:
130
-
131
- ```bash
132
- RAILS_ENV=test bundle exec parallel_test spec packs/**/spec -t rspec <other_options>
133
- ```
23
+ ## Usage
134
24
 
135
- #### Knapsack (Pro)
25
+ TODO: Write usage instructions here
136
26
 
137
- Similarly, Knapsack (and its Pro version) has its own spec discovery mechanism and the API will find and queue the relevant specs.
138
- To make it discover your pack tests as well, you'll need to configure the following variables:
27
+ ## Development
139
28
 
140
- ```yaml
141
- KNAPSACK_PRO_TEST_DIR: spec
142
- KNAPSACK_PRO_TEST_FILE_PATTERN: '{spec,packs}/**{,/*/**}/*_spec.rb'
143
- ```
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
144
30
 
145
- Setting `KNAPSACK_PRO_TEST_FILE_PATTERN` will tell Knapsack where your specs are located, while setting `KNAPSACK_PRO_TEST_DIR` is necessary because otherwise an incorrect value is sent to rspec via the `--default-path` option.
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
146
32
 
147
33
  ## Contributing
148
34
 
149
- Bug reports and pull requests are welcome on GitHub at https://github.com/Gusto/stimpack.
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ngan/stimpack.
@@ -0,0 +1,11 @@
1
+ module Stimpack
2
+ module Autoloaders
3
+ def main
4
+ Stimpack.autoloader(super)
5
+ end
6
+
7
+ def once
8
+ Stimpack.autoloader(super)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ require "pathname"
2
+ require "active_support/inflector"
3
+
4
+ module Stimpack
5
+ class Instance
6
+ def initialize
7
+ Pathname.new("packages").glob("*/package.yml").each do |path|
8
+ path = path.realpath.dirname
9
+ name = ActiveSupport::Inflector.classify(path.basename)
10
+ Stimpack::Packages.create(name, path)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,14 +1,11 @@
1
- # typed: true
2
-
3
1
  module Stimpack
4
2
  module Integrations
5
3
  class FactoryBot
6
- def initialize(app)
7
- return unless app.config.respond_to?(:factory_bot)
8
- Stimpack.configure_packs
4
+ def self.install
5
+ return unless Rails.configuration.respond_to?(:factory_bot)
9
6
 
10
- Packs.all.reject(&:is_gem?).each do |pack|
11
- app.config.factory_bot.definition_file_paths << pack.relative_path.join("spec/factories").to_s
7
+ Packs.each do |pack|
8
+ Rails.configuration.factory_bot.definition_file_paths << pack.settings.relative_path.join("spec/factories").to_s
12
9
  end
13
10
  end
14
11
  end
@@ -1,58 +1,11 @@
1
- # typed: true
2
-
3
1
  module Stimpack
4
2
  module Integrations
5
3
  class RSpec
6
- extend T::Sig
7
-
8
- def initialize
9
- # This is the list of directories RSpec was told to run.
10
- to_run = ::RSpec.configuration.instance_variable_get(:@files_or_directories_to_run)
11
- default_path = ::RSpec.configuration.default_path
12
-
13
- Stimpack.configure_packs
14
-
15
- if to_run == [default_path]
16
- # This is the default case when you run `rspec`. We want to add all the pack's spec paths
17
- # to the collection of directories to run.
18
-
19
- pack_paths = Packs.all.map do |pack|
20
- spec_path = pack.relative_path.join(default_path)
21
- spec_path.to_s if spec_path.exist?
22
- end
23
-
24
- to_run.concat(pack_paths)
25
- else
26
- # This is when `rspec` is run with a list of directories or files. We scan this list to see
27
- # if any of them matches a pack's directory. If it does, we concat the `default_path` to the
28
- # end of it.
29
- #
30
- # packs/my_pack => packs/my_pack/spec
31
- #
32
- # If it doesn't match a pack path, we leave it alone.
33
-
34
- to_run.map! do |path|
35
- if pack = Packs.find(path)
36
- [
37
- pack,
38
- *nested_packs_for(pack)
39
- ].map do |pack|
40
- spec_path = pack.relative_path.join(default_path)
41
- spec_path.to_s if spec_path.exist?
42
- end
43
- else
44
- path
45
- end
46
- end
47
- end
48
-
49
- ::RSpec.configuration.files_or_directories_to_run = to_run.flatten.compact.uniq
50
- end
4
+ def self.install
5
+ return unless defined?(::RSpec)
51
6
 
52
- sig { params(parent_pack: Packs::Pack).returns(T::Array[Packs::Pack]) }
53
- def nested_packs_for(parent_pack)
54
- Packs.all.select do |pack|
55
- pack.name != parent_pack.name && pack.name.include?(parent_pack.name)
7
+ Packs.each do |pack|
8
+ ::RSpec.configuration.pattern.concat(",#{pack.settings.relative_path.join("spec/**/*_spec.rb")}")
56
9
  end
57
10
  end
58
11
  end
@@ -2,8 +2,9 @@ require "active_support"
2
2
 
3
3
  module Stimpack
4
4
  module Integrations
5
- autoload :FactoryBot, "stimpack/integrations/factory_bot"
6
- autoload :Rails, "stimpack/integrations/rails"
5
+ extend ActiveSupport::Autoload
6
+
7
7
  autoload :RSpec, "stimpack/integrations/rspec"
8
+ autoload :FactoryBot, "stimpack/integrations/factory_bot"
8
9
  end
9
10
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kernel
4
+ module_function
5
+
6
+ alias_method :stimpack_original_require, :require
7
+
8
+ def require(path)
9
+ stimpack_original_require(Stimpack::Require.resolve(path) || path)
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ require "rails"
2
+ require "active_support/core_ext/module/delegation"
3
+
4
+ module Stimpack
5
+ class Package < ::Rails::Engine
6
+ class << self
7
+ delegate :subclasses, to: :superclass
8
+
9
+ def find_root(from)
10
+ Packages.paths[module_parent.name]
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,35 @@
1
+ require "rails"
2
+
3
+ module Stimpack
4
+ module Packages
5
+ def self.paths
6
+ @paths ||= {}
7
+ end
8
+
9
+ def self.create(name, path)
10
+ paths[name] = path
11
+
12
+ class_eval(<<~RUBY, __FILE__, __LINE__ + 1)
13
+ module ::#{name}
14
+ class Engine < ::Stimpack::Package
15
+ end
16
+ end
17
+ RUBY
18
+
19
+ engine = const_get("::#{name}::Engine")
20
+ # Isolate the package namespace.
21
+ engine.isolate_namespace(engine.module_parent)
22
+
23
+ # Disable Railtie initializers for Packages.
24
+ engine.paths["config/initializers"] = nil
25
+
26
+ engine.paths["lib/tasks"] = "tasks"
27
+ engine.paths["db/migrate"] = "migrations"
28
+ engine.paths["config/routes.rb"] = "routes.rb"
29
+
30
+ if engine.paths["db/migrate"].existent.any?
31
+ ActiveRecord::Migrator.migrations_paths << engine.paths["db/migrate"].first
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,56 @@
1
+ require "active_support"
2
+ require "pathname"
3
+ require "rails"
4
+
5
+ module Stimpack
6
+ module Packs
7
+ PATH = Pathname.new("packs").freeze
8
+ PACK_CLASS = "Pack".freeze
9
+
10
+ class << self
11
+ def resolve
12
+ PATH.glob("**/#{Settings::PACKWERK_PACKAGE_CONFIG}").each do |path|
13
+ path = path.dirname
14
+ create(path.relative_path_from(PATH).to_s, path.expand_path)
15
+ end
16
+ end
17
+
18
+ def create(name, path)
19
+ namespace = create_namespace(name)
20
+ stim = Stim.new(path)
21
+ @packs[name] = namespace.const_set(PACK_CLASS, Class.new(Rails::Engine)).include(stim)
22
+ end
23
+
24
+ def find(path)
25
+ path = "#{path}/"
26
+
27
+ @packs.values.find do |pack|
28
+ path.start_with?("#{pack.root}/")
29
+ end
30
+ end
31
+
32
+ def [](name)
33
+ @packs[name]
34
+ end
35
+
36
+ def each(*args, &block)
37
+ @packs.each_value(*args, &block)
38
+ end
39
+
40
+ private
41
+
42
+ def create_namespace(name)
43
+ namespace = ActiveSupport::Inflector.camelize(name)
44
+ namespace.split("::").reduce(Object) do |base, mod|
45
+ if base.const_defined?(mod)
46
+ base.const_get(mod)
47
+ else
48
+ base.const_set(mod, Module.new)
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ @packs = {}
55
+ end
56
+ end
@@ -1,14 +1,13 @@
1
- require "rails/railtie"
1
+ require "rails"
2
2
 
3
3
  module Stimpack
4
4
  class Railtie < Rails::Railtie
5
- config.before_configuration do |app|
6
- Integrations::Rails.new(app)
7
- Integrations::FactoryBot.new(app)
5
+ config.before_configuration do
6
+ Stimpack.start!
7
+ end
8
8
 
9
- # This is not used within stimpack. Rather, this allows OTHER tools to
10
- # hook into Stimpack via ActiveSupport hooks.
11
- ActiveSupport.run_load_hooks(:stimpack, Packs)
9
+ config.after_initialize do
10
+ Stimpack.finalize!
12
11
  end
13
12
  end
14
13
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stimpack
4
+ class Require
5
+ IGNORED_PATH_PREFIXES = ["/", "./"].freeze
6
+ RUBY_EXTENSION = ".rb"
7
+
8
+ include Singleton
9
+
10
+ attr_accessor :enabled
11
+
12
+ def self.resolve(path)
13
+ instance.resolve(path)
14
+ end
15
+
16
+ def self.setup
17
+ instance.setup
18
+ end
19
+
20
+ def initialize
21
+ @packs = {}
22
+ end
23
+
24
+ def setup
25
+ @setup = @setup ? return : true
26
+
27
+ Packs.each do |pack|
28
+ if pack.settings.implicit_namespace?
29
+ @packs["#{pack.settings.name}/"] = "#{pack.paths["lib"].first}/"
30
+ end
31
+ end
32
+ end
33
+
34
+ def resolve(path)
35
+ path = path.to_s
36
+ return if path.start_with?(*IGNORED_PATH_PREFIXES)
37
+
38
+ @packs.find do |pack_path, full_path|
39
+ if path.start_with?(pack_path)
40
+ full_pack_path = path.sub(pack_path, full_path)
41
+ full_pack_path.concat(RUBY_EXTENSION) unless full_pack_path.end_with?(RUBY_EXTENSION)
42
+ return File.exist?(full_pack_path) && full_pack_path
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stimpack
4
+ class Settings
5
+ PACKWERK_PACKAGE_CONFIG = "package.yml"
6
+
7
+ def initialize(pack)
8
+ @pack = pack
9
+
10
+ package_config = YAML.load_file(pack.root.join(PACKWERK_PACKAGE_CONFIG)) || {}
11
+ @config = package_config.fetch("metadata", {}).freeze
12
+ end
13
+
14
+ def path
15
+ @pack.called_from
16
+ end
17
+
18
+ def relative_path
19
+ @relative_path ||= path.relative_path_from(Rails.root)
20
+ end
21
+
22
+ def name
23
+ @name ||= ActiveSupport::Inflector.underscore(namespace.name)
24
+ end
25
+
26
+ def namespace
27
+ @pack.module_parent
28
+ end
29
+
30
+ # def implicit_namespace
31
+ # @config.fetch("implicit_namespace", true)
32
+ # end
33
+ # alias_method :implicit_namespace?, :implicit_namespace
34
+
35
+ def isolate_namespace
36
+ @config.fetch("isolate_namespace", true)
37
+ end
38
+ alias_method :isolate_namespace?, :isolate_namespace
39
+ end
40
+ end
data/lib/stimpack/stim.rb CHANGED
@@ -1,39 +1,31 @@
1
- # typed: true
2
-
3
1
  module Stimpack
4
2
  class Stim < Module
5
- extend T::Sig
6
-
7
- sig { params(pack: Packs::Pack, namespace: Module).void }
8
- def initialize(pack, namespace)
9
- @pack = pack
10
- @namespace = namespace
3
+ def initialize(path)
4
+ @path = path
11
5
  super()
12
6
  end
13
7
 
14
8
  def included(engine)
15
- engine.called_from = @pack.relative_path
9
+ engine.called_from = @path
16
10
  engine.extend(ClassMethods)
17
- engine.isolate_namespace(@namespace)
11
+ settings = engine.settings
18
12
 
19
- # Set all of these paths to nil because we want the Rails integration to take
20
- # care of them. The purpose of this Engine is really just for the namespace
21
- # isolation.
22
- (Stimpack.config.paths +
23
- # In addition to the paths we've delegated to the main app, we don't allow
24
- # Engine Packs to have various capabilities.
25
- %w(
26
- config/environments
27
- db/migrate
28
- )
29
- ).uniq.each do |path|
30
- engine.paths[path] = nil
13
+ if settings.isolate_namespace?
14
+ engine.isolate_namespace(settings.namespace)
31
15
  end
16
+
17
+ # if settings.implicit_namespace?
18
+ # engine.paths["lib"].skip_load_path!
19
+ # end
32
20
  end
33
21
 
34
22
  module ClassMethods
35
23
  def find_root(_from)
36
- T.unsafe(self).called_from
24
+ called_from
25
+ end
26
+
27
+ def settings
28
+ @settings ||= Stimpack::Settings.new(self)
37
29
  end
38
30
  end
39
31
  end
@@ -1,3 +1,3 @@
1
1
  module Stimpack
2
- VERSION = "0.8.3".freeze
2
+ VERSION = "1.0.0.alpha1".freeze
3
3
  end
@@ -0,0 +1,24 @@
1
+ require "active_support"
2
+
3
+ module Stimpack
4
+ class ZeitwerkProxy
5
+ delegate_missing_to :@loader
6
+
7
+ def initialize(loader)
8
+ @loader = loader
9
+ end
10
+
11
+ def push_dir(path, namespace: Object)
12
+ @loader.push_dir(path, namespace: _resolve_namespace(path) || namespace)
13
+ end
14
+
15
+ private
16
+
17
+ def _resolve_namespace(path)
18
+ pack = Packs.find(path)
19
+ return unless pack
20
+
21
+ pack.settings.namespace if pack.settings.implicit_namespace?
22
+ end
23
+ end
24
+ end
data/lib/stimpack.rb CHANGED
@@ -1,60 +1,58 @@
1
- require 'packs'
2
1
  require "active_support"
3
- require "rails/application"
4
- require 'sorbet-runtime'
2
+ require "rails"
5
3
 
6
4
  module Stimpack
7
5
  extend ActiveSupport::Autoload
8
6
 
9
7
  autoload :Integrations
10
- autoload :Railtie
8
+ autoload :Autoloaders
9
+ autoload :Packs
10
+ autoload :Settings
11
11
  autoload :Stim
12
+ autoload :Railtie
13
+ autoload :Require
14
+ autoload :ZeitwerkProxy
12
15
 
13
16
  class Error < StandardError; end
14
17
 
15
18
  class << self
16
- attr_reader :config
19
+ def start!
20
+ @started = @started ? return : true
21
+
22
+ # Override Rails' autoloader accessors.
23
+ # Rails::Autoloaders.singleton_class.prepend(Autoloaders)
24
+
25
+ Packs.resolve
17
26
 
18
- def root
19
- @root ||= Rails::Application.find_root(Dir.pwd)
27
+ install_integrations
20
28
  end
21
29
 
22
- #
23
- # This is temporary. For now, we allow Stimpack roots to be configured via Stimpack.config.root
24
- # Later, if clients configure packs directly, we can deprecate the Stimpack setting and
25
- # remove this function and its invocations.
26
- #
27
- def configure_packs
28
- Packs.configure do |config|
29
- roots = Array(Stimpack.config.root)
30
- pack_paths = roots.flat_map do |root|
31
- # Support nested packs by default. Later, this can be pushed to a client configuration.
32
- ["#{root}/*", "#{root}/*/*"]
33
- end
34
-
35
- config.pack_paths = pack_paths
36
- end
30
+ def finalize!
31
+ @finalized = @finalized ? return : true
32
+
33
+ Require.setup
37
34
  end
38
- end
39
35
 
40
- @config = ActiveSupport::OrderedOptions.new
41
- # Should this allow a plural version to be set? What are semantics of that?
42
- @config.root = Array("packs".freeze)
43
- @config.paths = %w(
44
- app
45
- app/controllers
46
- app/channels
47
- app/helpers
48
- app/models
49
- app/mailers
50
- app/views
51
- lib
52
- lib/tasks
53
- config
54
- config/locales
55
- config/initializers
56
- config/routes
57
- )
36
+ def autoloader(original)
37
+ return original if @finalized
38
+
39
+ @autoloader_proxies ||= {}
40
+ @autoloader_proxies[original] ||= ZeitwerkProxy.new(original)
41
+ end
42
+
43
+ def [](name)
44
+ Packs[name.to_s]
45
+ end
46
+
47
+ private
48
+
49
+ def install_integrations
50
+ Integrations::FactoryBot.install
51
+ Integrations::RSpec.install
52
+ end
53
+ end
58
54
  end
59
55
 
60
56
  require "stimpack/railtie"
57
+ # require "stimpack/require"
58
+ # require "stimpack/kernel"
metadata CHANGED
@@ -1,45 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 1.0.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ngan Pham
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-06 00:00:00.000000000 Z
11
+ date: 2021-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: railties
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: activesupport
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: packs
14
+ name: rails
43
15
  requirement: !ruby/object:Gem::Requirement
44
16
  requirements:
45
17
  - - ">="
@@ -80,64 +52,7 @@ dependencies:
80
52
  - - ">="
81
53
  - !ruby/object:Gem::Version
82
54
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: debug
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: sorbet
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: tapioca
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: rails
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- description: stimpack establishes and implements a set of conventions for splitting
140
- up large monoliths.
55
+ description: Package your code.
141
56
  email:
142
57
  - gusto-opensource-buildkite@gusto.com
143
58
  executables: []
@@ -147,16 +62,22 @@ files:
147
62
  - README.md
148
63
  - bin/console
149
64
  - bin/setup
150
- - bin/tapioca
151
65
  - lib/stimpack.rb
66
+ - lib/stimpack/autoloaders.rb
67
+ - lib/stimpack/instance.rb
152
68
  - lib/stimpack/integrations.rb
153
69
  - lib/stimpack/integrations/factory_bot.rb
154
- - lib/stimpack/integrations/rails.rb
155
70
  - lib/stimpack/integrations/rspec.rb
71
+ - lib/stimpack/kernel.rb
72
+ - lib/stimpack/package.rb
73
+ - lib/stimpack/packages.rb
74
+ - lib/stimpack/packs.rb
156
75
  - lib/stimpack/railtie.rb
157
- - lib/stimpack/rspec.rb
76
+ - lib/stimpack/require.rb
77
+ - lib/stimpack/settings.rb
158
78
  - lib/stimpack/stim.rb
159
79
  - lib/stimpack/version.rb
80
+ - lib/stimpack/zeitwerk_proxy.rb
160
81
  homepage: https://github.com/Gusto/stimpack
161
82
  licenses: []
162
83
  metadata:
@@ -174,11 +95,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
174
95
  version: '2.7'
175
96
  required_rubygems_version: !ruby/object:Gem::Requirement
176
97
  requirements:
177
- - - ">="
98
+ - - ">"
178
99
  - !ruby/object:Gem::Version
179
- version: '0'
100
+ version: 1.3.1
180
101
  requirements: []
181
- rubygems_version: 3.1.6
102
+ rubygems_version: 3.1.2
182
103
  signing_key:
183
104
  specification_version: 4
184
105
  summary: A Rails helper to package your code.
data/bin/tapioca DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'tapioca' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
- Pathname.new(__FILE__).realpath)
14
-
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
16
-
17
- if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
- load(bundle_binstub)
20
- else
21
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
- end
24
- end
25
-
26
- require "rubygems"
27
- require "bundler/setup"
28
-
29
- load Gem.bin_path("tapioca", "tapioca")
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
- # typed: true
3
-
4
- require "active_support/inflections"
5
-
6
- module Stimpack
7
- module Integrations
8
- class Rails
9
- def initialize(app)
10
- @app = app
11
-
12
- Stimpack.config.paths.freeze
13
- Stimpack.configure_packs
14
-
15
- create_engines
16
- inject_paths
17
- end
18
-
19
- def create_engines
20
- Packs.all.reject(&:is_gem?).each do |pack|
21
- next unless pack.metadata['engine']
22
-
23
- create_engine(pack)
24
- end
25
- end
26
-
27
- def inject_paths
28
- Packs.all.reject(&:is_gem?).each do |pack|
29
- Stimpack.config.paths.each do |path|
30
- @app.paths[path] << pack.relative_path.join(path)
31
- end
32
- end
33
- end
34
-
35
- private
36
-
37
- def create_namespace(name)
38
- namespace = ActiveSupport::Inflector.camelize(name)
39
- namespace.split("::").reduce(Object) do |base, mod|
40
- if base.const_defined?(mod, false)
41
- base.const_get(mod, false)
42
- else
43
- base.const_set(mod, Module.new)
44
- end
45
- end
46
- end
47
-
48
- def create_engine(pack)
49
- name = pack.last_name
50
- namespace = create_namespace(name)
51
- stim = Stim.new(pack, namespace)
52
- namespace.const_set("Engine", Class.new(::Rails::Engine)).include(stim)
53
- end
54
- end
55
- end
56
- end
@@ -1,3 +0,0 @@
1
- require "stimpack"
2
-
3
- Stimpack::Integrations::RSpec.new