diff --git a/lib/stimpack/packs.rb b/lib/stimpack/packs.rb index 785a377..c5d3512 100644 --- a/lib/stimpack/packs.rb +++ b/lib/stimpack/packs.rb @@ -12,8 +12,9 @@ def root end def resolve - # Gather all the packs under the root directory and create packs. - root.children.select(&:directory?).sort!.each do |path| + # Gather all the parent packs and the children packs. + package_locations = root.glob('*/{package.yml,*/package.yml}').map(&:dirname) + package_locations.sort!.each do |path| next unless pack = Pack.create(path) @packs[pack.name] = pack end diff --git a/lib/stimpack/railtie.rb b/lib/stimpack/railtie.rb index dd2524c..d1674b0 100644 --- a/lib/stimpack/railtie.rb +++ b/lib/stimpack/railtie.rb @@ -4,6 +4,8 @@ module Stimpack class Railtie < Rails::Railtie config.before_configuration do |app| Stimpack.load(app) + # This is not used within stimpack. Rather, this allows OTHER tools to + # hook into Stimpack via ActiveSupport hooks. ActiveSupport.run_load_hooks(:stimpack, Packs) end end diff --git a/lib/stimpack/version.rb b/lib/stimpack/version.rb index 26d6bca..8781090 100644 --- a/lib/stimpack/version.rb +++ b/lib/stimpack/version.rb @@ -1,3 +1,3 @@ module Stimpack - VERSION = "0.5.0".freeze + VERSION = "0.6.0".freeze end diff --git a/spec/fixtures/rails-7.0/packs/pants/shorts/app/models/shorts/zipper.rb b/spec/fixtures/rails-7.0/packs/pants/shorts/app/models/shorts/zipper.rb new file mode 100644 index 0000000..beb89f5 --- /dev/null +++ b/spec/fixtures/rails-7.0/packs/pants/shorts/app/models/shorts/zipper.rb @@ -0,0 +1,4 @@ +module Shorts + class Zipper + end +end diff --git a/spec/fixtures/rails-7.0/packs/pants/shorts/app/services/shorts/khaki.rb b/spec/fixtures/rails-7.0/packs/pants/shorts/app/services/shorts/khaki.rb new file mode 100644 index 0000000..e181768 --- /dev/null +++ b/spec/fixtures/rails-7.0/packs/pants/shorts/app/services/shorts/khaki.rb @@ -0,0 +1,4 @@ +module Shorts + class Khaki + end +end diff --git a/spec/fixtures/rails-7.0/packs/pants/shorts/app/services/shorts/linen.rb b/spec/fixtures/rails-7.0/packs/pants/shorts/app/services/shorts/linen.rb new file mode 100644 index 0000000..c9e3372 --- /dev/null +++ b/spec/fixtures/rails-7.0/packs/pants/shorts/app/services/shorts/linen.rb @@ -0,0 +1,4 @@ +module Shorts + class Linen + end +end diff --git a/spec/fixtures/rails-7.0/packs/pants/shorts/package.yml b/spec/fixtures/rails-7.0/packs/pants/shorts/package.yml new file mode 100644 index 0000000..e69de29 diff --git a/spec/stimpack_spec.rb b/spec/stimpack_spec.rb index 66b713f..6ff8074 100644 --- a/spec/stimpack_spec.rb +++ b/spec/stimpack_spec.rb @@ -17,4 +17,16 @@ it "creates engines namespace for engine packs" do expect(defined?(Shoes::Engine)).to eq("constant") end + + context 'nested packs' do + it "autoloads classes in autoload paths" do + expect(defined?(Shorts::Linen)).to eq("constant") + end + + it "adds pack paths to the application" do + Stimpack.config.paths.each do |path| + expect(Rails.application.paths[path].paths).to include(rails_dir.join(Stimpack.config.root, "pants", "shorts", path)) + end + end + end end diff --git a/test/test_helper.rb b/test/test_helper.rb deleted file mode 100644 index 0af9fd4..0000000 --- a/test/test_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -require "minitest/autorun" -require_relative "../lib/stimpack"