Skip to content

Commit

Permalink
Add functionality for nested packs (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Evanczuk authored Aug 12, 2022
1 parent 2d12203 commit 300b462
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/stimpack/packs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/stimpack/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/stimpack/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Stimpack
VERSION = "0.5.0".freeze
VERSION = "0.6.0".freeze
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Shorts
class Zipper
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Shorts
class Khaki
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Shorts
class Linen
end
end
Empty file.
12 changes: 12 additions & 0 deletions spec/stimpack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions test/test_helper.rb

This file was deleted.

0 comments on commit 300b462

Please sign in to comment.