stimpack 0.7.1 → 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: be1d3fa462f2ec696d5c72721fd96cead8a0bb2c08f238f2ffab9af6ce753ea9
4
- data.tar.gz: 2a09c371fea45fca32c6d386ec6588887a04326ee306b81199edeb7e4ffa2cb3
3
+ metadata.gz: aedf6786a9c8dce60f5d90bf3f9b97bea858d3faeac218c2991a5ed5dd61503e
4
+ data.tar.gz: 1b7c218dc706f75f77d4d1e6e099f174520c26ebbf573f985f05e6e28a343af8
5
5
  SHA512:
6
- metadata.gz: 56a878d5ccc64a91ab8366759d6900758e80a59f0a4ad60b8c8397849e975f2043e46926bff5ac6ec1745aad5d69fd78ba5cc7dcce2242f45aeb374a5483863a
7
- data.tar.gz: 8767f7b944326da96773793170b32b5e880bfebc1ad0e8ab657e2d84154a874c9a50603ebd0c1e9e5bd4fead7c13810e5e93e10e6072e40e99fa9485d550fa09
6
+ metadata.gz: be4a82f48f0c966edfc9c86c096d4e8cbfe7f23177007ddd91bffe769ac7fab05921f6b7c2855b8fbadc49c54aede9024b1820f76ecbe988b492507adc3fc212
7
+ data.tar.gz: 889c48f4b28b1260e6387ba6205f5b586846630c33182f680bbbaf8bfe0a18f89529b16ef87c562991452da74bbd2191168189d1b7f4380e56448eabe586fae1
data/README.md CHANGED
@@ -1,126 +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 pack's 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.
57
-
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:
61
-
62
- ```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
- ```
7
+ ## Installation
73
8
 
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.
9
+ Add this line to your application's Gemfile:
76
10
 
77
11
  ```ruby
78
- # packs/my_domain/config/routes/my_domain.rb
79
- resources :my_resource
80
-
81
- # config/routes.rb
82
- draw(:my_domain)
12
+ gem "stimpack"
83
13
  ```
84
14
 
85
- ### Making your Package an Engine
86
- Add `engine: true` to your `package.yml` to make it an actual Rails engine:
87
- ```yml
88
- # packs/my_pack/package.yml
89
- enforce_dependencies: true
90
- enforce_privacy: true
91
- metadata:
92
- engine: true
93
- ```
15
+ And then execute:
94
16
 
95
- ### RSpec Integration
96
- Simply add `--require stimpack/rspec` to your `.rspec`.
97
- Or, if you'd like, pass it as an argument to `rspec`:
17
+ $ bundle install
98
18
 
99
- ```
100
- $ rspec --require stimpack/rspec ...
101
- ```
19
+ Or install it yourself as:
102
20
 
103
- Integration will allow you to run tests as such:
104
- ```
105
- # Run all specs in your entire application (packs and all):
106
- rspec
21
+ $ gem install stimpack
107
22
 
108
- # Run just that one test:
109
- rspec spec/some/specific_spec.rb
23
+ ## Usage
110
24
 
111
- # Run all tests under the "foobar" pack and all the tests of its nested packs:
112
- rspec packs/foobar
25
+ TODO: Write usage instructions here
113
26
 
114
- # Same as above but also adds the "binbaz" pack:
115
- rspec packs/foobar pack/binbaz
27
+ ## Development
116
28
 
117
- # Run all test files inside the "packs/foobar/spec" directory:
118
- rspec packs/foobar/spec
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.
119
30
 
120
- # Run all specs under the "packs/foobar/nested_pack" pack:
121
- rspec packs/foobar/nested_pack
122
- ```
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).
123
32
 
124
33
  ## Contributing
125
34
 
126
- 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,11 +1,11 @@
1
1
  module Stimpack
2
2
  module Integrations
3
3
  class FactoryBot
4
- def initialize(app)
5
- return unless app.config.respond_to?(:factory_bot)
4
+ def self.install
5
+ return unless Rails.configuration.respond_to?(:factory_bot)
6
6
 
7
- Packs.all.each do |pack|
8
- 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
9
9
  end
10
10
  end
11
11
  end
@@ -1,46 +1,12 @@
1
1
  module Stimpack
2
2
  module Integrations
3
3
  class RSpec
4
- def initialize
5
- # This is the list of directories RSpec was told to run.
6
- to_run = ::RSpec.configuration.instance_variable_get(:@files_or_directories_to_run)
7
- default_path = ::RSpec.configuration.default_path
4
+ def self.install
5
+ return unless defined?(::RSpec)
8
6
 
9
- if to_run == [default_path]
10
- # This is the default case when you run `rspec`. We want to add all the pack's spec paths
11
- # to the collection of directories to run.
12
-
13
- pack_paths = Packs.all.map do |pack|
14
- spec_path = pack.relative_path.join(default_path)
15
- spec_path.to_s if spec_path.exist?
16
- end
17
-
18
- to_run.concat(pack_paths)
19
- else
20
- # This is when `rspec` is run with a list of directories or files. We scan this list to see
21
- # if any of them matches a pack's directory. If it does, we concat the `default_path` to the
22
- # end of it.
23
- #
24
- # packs/my_pack => packs/my_pack/spec
25
- #
26
- # If it doesn't match a pack path, we leave it alone.
27
-
28
- to_run.map! do |path|
29
- if pack = Packs.all_by_path[path]
30
- [
31
- pack,
32
- *Packs.all(pack)
33
- ].map do |pack|
34
- spec_path = pack.relative_path.join(default_path)
35
- spec_path.to_s if spec_path.exist?
36
- end
37
- else
38
- path
39
- end
40
- end
7
+ Packs.each do |pack|
8
+ ::RSpec.configuration.pattern.concat(",#{pack.settings.relative_path.join("spec/**/*_spec.rb")}")
41
9
  end
42
-
43
- ::RSpec.configuration.files_or_directories_to_run = to_run.flatten.compact.uniq
44
10
  end
45
11
  end
46
12
  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
@@ -1,47 +1,56 @@
1
- # frozen_string_literal: true
2
-
3
1
  require "active_support"
2
+ require "pathname"
3
+ require "rails"
4
4
 
5
5
  module Stimpack
6
6
  module Packs
7
- PACKAGE_GLOB_PATTERN = "*/#{Pack::PACKAGE_FILE}"
7
+ PATH = Pathname.new("packs").freeze
8
+ PACK_CLASS = "Pack".freeze
8
9
 
9
10
  class << self
10
- def root
11
- @root ||= Stimpack.root.join(Stimpack.config.root)
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)
12
22
  end
13
23
 
14
24
  def find(path)
15
- @find_pack_paths ||= all_by_path.keys.sort_by(&:length).reverse!.map { |path| "#{path}/" }
16
25
  path = "#{path}/"
17
- @find_pack_paths.find do |pack_path|
18
- path.start_with?(pack_path)
26
+
27
+ @packs.values.find do |pack|
28
+ path.start_with?("#{pack.root}/")
19
29
  end
20
30
  end
21
31
 
22
- def all(parent = nil)
23
- @all ||= resolve(root).each_with_object({}) do |pack, map|
24
- map[pack] = resolve(pack.path).freeze
25
- end.freeze
26
-
27
- if parent
28
- @all[parent]
29
- else
30
- @all.keys + @all.values.flatten
31
- end
32
+ def [](name)
33
+ @packs[name]
32
34
  end
33
35
 
34
- def all_by_path
35
- @all_by_path ||= all.each_with_object({}) do |pack, map|
36
- map[pack.relative_path.to_s] = pack
37
- end
36
+ def each(*args, &block)
37
+ @packs.each_value(*args, &block)
38
38
  end
39
39
 
40
40
  private
41
41
 
42
- def resolve(directory)
43
- directory.glob(PACKAGE_GLOB_PATTERN).map { |path| Pack.new(path.dirname) }
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
44
51
  end
45
52
  end
53
+
54
+ @packs = {}
46
55
  end
47
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,35 +1,32 @@
1
1
  module Stimpack
2
2
  class Stim < Module
3
- def initialize(pack, namespace)
4
- @pack = pack
5
- @namespace = namespace
3
+ def initialize(path)
4
+ @path = path
6
5
  super()
7
6
  end
8
7
 
9
8
  def included(engine)
10
- engine.called_from = @pack.path
9
+ engine.called_from = @path
11
10
  engine.extend(ClassMethods)
12
- engine.isolate_namespace(@namespace)
11
+ settings = engine.settings
13
12
 
14
- # Set all of these paths to nil because we want the Rails integration to take
15
- # care of them. The purpose of this Engine is really just for the namespace
16
- # isolation.
17
- (Stimpack.config.paths +
18
- # In addition to the paths we've delegated to the main app, we don't allow
19
- # Engine Packs to have various capabilities.
20
- %w(
21
- config/environments
22
- db/migrate
23
- )
24
- ).uniq.each do |path|
25
- engine.paths[path] = nil
13
+ if settings.isolate_namespace?
14
+ engine.isolate_namespace(settings.namespace)
26
15
  end
16
+
17
+ # if settings.implicit_namespace?
18
+ # engine.paths["lib"].skip_load_path!
19
+ # end
27
20
  end
28
21
 
29
22
  module ClassMethods
30
23
  def find_root(_from)
31
24
  called_from
32
25
  end
26
+
27
+ def settings
28
+ @settings ||= Stimpack::Settings.new(self)
29
+ end
33
30
  end
34
31
  end
35
32
  end
@@ -1,3 +1,3 @@
1
1
  module Stimpack
2
- VERSION = "0.7.1".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,42 +1,58 @@
1
1
  require "active_support"
2
- require "rails/application"
2
+ require "rails"
3
3
 
4
4
  module Stimpack
5
5
  extend ActiveSupport::Autoload
6
6
 
7
7
  autoload :Integrations
8
- autoload :Pack
8
+ autoload :Autoloaders
9
9
  autoload :Packs
10
- autoload :Railtie
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
28
+ end
29
+
30
+ def finalize!
31
+ @finalized = @finalized ? return : true
32
+
33
+ Require.setup
20
34
  end
21
- end
22
35
 
23
- @config = ActiveSupport::OrderedOptions.new
24
- @config.root = "packs".freeze
25
- @config.paths = %w(
26
- app
27
- app/controllers
28
- app/channels
29
- app/helpers
30
- app/models
31
- app/mailers
32
- app/views
33
- lib
34
- lib/tasks
35
- config
36
- config/locales
37
- config/initializers
38
- config/routes
39
- )
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
40
54
  end
41
55
 
42
56
  require "stimpack/railtie"
57
+ # require "stimpack/require"
58
+ # require "stimpack/kernel"
metadata CHANGED
@@ -1,31 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
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: 2022-09-08 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
14
+ name: rails
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ">="
@@ -66,64 +52,7 @@ dependencies:
66
52
  - - ">="
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: debug
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: sorbet
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: tapioca
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: rails
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
- description: stimpack establishes and implements a set of conventions for splitting
126
- up large monoliths.
55
+ description: Package your code.
127
56
  email:
128
57
  - gusto-opensource-buildkite@gusto.com
129
58
  executables: []
@@ -133,19 +62,22 @@ files:
133
62
  - README.md
134
63
  - bin/console
135
64
  - bin/setup
136
- - bin/tapioca
137
65
  - lib/stimpack.rb
66
+ - lib/stimpack/autoloaders.rb
67
+ - lib/stimpack/instance.rb
138
68
  - lib/stimpack/integrations.rb
139
69
  - lib/stimpack/integrations/factory_bot.rb
140
- - lib/stimpack/integrations/rails.rb
141
70
  - lib/stimpack/integrations/rspec.rb
142
- - lib/stimpack/pack.rb
143
- - lib/stimpack/pack/configuration.rb
71
+ - lib/stimpack/kernel.rb
72
+ - lib/stimpack/package.rb
73
+ - lib/stimpack/packages.rb
144
74
  - lib/stimpack/packs.rb
145
75
  - lib/stimpack/railtie.rb
146
- - lib/stimpack/rspec.rb
76
+ - lib/stimpack/require.rb
77
+ - lib/stimpack/settings.rb
147
78
  - lib/stimpack/stim.rb
148
79
  - lib/stimpack/version.rb
80
+ - lib/stimpack/zeitwerk_proxy.rb
149
81
  homepage: https://github.com/Gusto/stimpack
150
82
  licenses: []
151
83
  metadata:
@@ -163,11 +95,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
95
  version: '2.7'
164
96
  required_rubygems_version: !ruby/object:Gem::Requirement
165
97
  requirements:
166
- - - ">="
98
+ - - ">"
167
99
  - !ruby/object:Gem::Version
168
- version: '0'
100
+ version: 1.3.1
169
101
  requirements: []
170
- rubygems_version: 3.3.7
102
+ rubygems_version: 3.1.2
171
103
  signing_key:
172
104
  specification_version: 4
173
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,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/inflections"
4
-
5
- module Stimpack
6
- module Integrations
7
- class Rails
8
- def initialize(app)
9
- @app = app
10
-
11
- Stimpack.config.paths.freeze
12
- create_engines
13
- inject_paths
14
- end
15
-
16
- def create_engines
17
- Packs.all.each do |pack|
18
- next unless pack.config.engine?
19
-
20
- pack.engine = create_engine(pack)
21
- end
22
- end
23
-
24
- def inject_paths
25
- Packs.all.each do |pack|
26
- Stimpack.config.paths.each do |path|
27
- @app.paths[path] << pack.path.join(path)
28
- end
29
- end
30
- end
31
-
32
- private
33
-
34
- def create_namespace(name)
35
- namespace = ActiveSupport::Inflector.camelize(name)
36
- namespace.split("::").reduce(Object) do |base, mod|
37
- if base.const_defined?(mod, false)
38
- base.const_get(mod, false)
39
- else
40
- base.const_set(mod, Module.new)
41
- end
42
- end
43
- end
44
-
45
- def create_engine(pack)
46
- name = pack.path.relative_path_from(Stimpack::Packs.root)
47
- namespace = create_namespace(pack.name)
48
- stim = Stim.new(pack, namespace)
49
- namespace.const_set("Engine", Class.new(::Rails::Engine)).include(stim)
50
- end
51
- end
52
- end
53
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "yaml"
4
-
5
- module Stimpack
6
- class Pack
7
- class Configuration
8
- KEY = "metadata"
9
-
10
- def initialize(path)
11
- @path = path
12
- end
13
-
14
- def engine
15
- data.fetch("engine", false)
16
- end
17
- alias_method :engine?, :engine
18
-
19
- private
20
-
21
- def data
22
- @data ||= begin
23
- contents = YAML.respond_to?(:safe_load_file) ? YAML.safe_load_file(@path) : YAML.load_file(@path)
24
- contents ||= {}
25
- contents.fetch(KEY, {}).freeze
26
- end
27
- end
28
- end
29
- end
30
- end
data/lib/stimpack/pack.rb DELETED
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "pathname"
4
-
5
- module Stimpack
6
- class Pack
7
- PACKAGE_FILE = "package.yml"
8
-
9
- autoload :Configuration, "stimpack/pack/configuration"
10
-
11
- attr_reader :path
12
- attr_reader :name
13
- attr_accessor :engine
14
-
15
- def initialize(path)
16
- @path = path
17
- @name = path.basename.to_s
18
- end
19
-
20
- def relative_path
21
- @relative_path ||= path.relative_path_from(Stimpack.root)
22
- end
23
-
24
- def config
25
- @config ||= Configuration.new(path.join(PACKAGE_FILE))
26
- end
27
- end
28
- end
@@ -1,3 +0,0 @@
1
- require "stimpack"
2
-
3
- Stimpack::Integrations::RSpec.new