Skip to content

Commit

Permalink
Remove support for wrappers, I felt they are too complex.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 21, 2024
1 parent b5ecd8a commit 61fc8dd
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 137 deletions.
10 changes: 0 additions & 10 deletions bake.rb
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@

wrap('test') do
before do
puts "Before test..."
end

after do
puts "After test..."
end
end
15 changes: 0 additions & 15 deletions lib/bake/bakefile_scope.rb

This file was deleted.

4 changes: 0 additions & 4 deletions lib/bake/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ def lookup(command)
@recipes[command]
end

def wrap(...)
@registry.wrap(...)
end

def to_s
if @root
"#{self.class} #{File.basename(@root)}"
Expand Down
12 changes: 1 addition & 11 deletions lib/bake/registry/aggregate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

require_relative 'directory_loader'
require_relative 'bakefile_loader'
require_relative 'wrappers'

module Bake
# Structured access to the working directory and loaded gems for loading bakefiles.
Expand Down Expand Up @@ -36,12 +35,6 @@ def initialize

# The ordered list of loaders:
@ordered = Array.new

@wrappers = Wrappers.new
end

def wrap(...)
@wrappers.wrap(...)
end

# Whether any registry are defined.
Expand All @@ -53,19 +46,16 @@ def empty?
# Enumerate the registry in order.
def each(&block)
@ordered.each(&block)
yield @wrappers
end

def scopes_for(path, &block)
@ordered.each do |registry|
registry.scopes_for(path, &block)
end

@wrappers.scopes_for(path, &block)
end

def append_bakefile(path)
@ordered << BakefileLoader.new(path, @wrappers)
@ordered << BakefileLoader.new(path)
end

# Append a specific project path to the search path for recipes.
Expand Down
11 changes: 2 additions & 9 deletions lib/bake/registry/bakefile_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
# Copyright, 2020-2024, by Samuel Williams.

require_relative '../scope'
require_relative '../bakefile_scope'

module Bake
module Registry
class BakefileLoader
def initialize(path, wrappers)
def initialize(path)
@path = path
@wrappers = wrappers
end

def to_s
Expand All @@ -26,12 +24,7 @@ def each(&block)

def scopes_for(path)
if path == []
scope = Scope.load(@path, []) do |scope|
scope.extend(BakefileScope)
scope.wrappers = @wrappers
end

yield scope
yield Scope.load(@path, [])
end
end
end
Expand Down
49 changes: 0 additions & 49 deletions lib/bake/registry/wrappers.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/bake/scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.load(file_path, path = [])
scope.const_set(:FILE_PATH, file_path)
scope.const_set(:PATH, path)

yield scope if block_given?
# yield scope if block_given?

scope.module_eval(File.read(file_path), file_path)

Expand Down
38 changes: 0 additions & 38 deletions test/bake/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,4 @@
expect(parent.instance).to be(:respond_to?, :parent)
end
end

with '#wrap' do
it "can wrap specific methods" do
events = []

context.wrap('wrap') do
before('invoked') do
events << :before
end

after('invoked') do
events << :after
end
end

context.call('wrap')

expect(events).to be == [:before, :after]
end

it "can wrap unspecified methods" do
events = []

context.wrap('wrap') do
before do
events << :before
end

after do
events << :after
end
end

context.call('wrap')

expect(events).to be == [:before, :after]
end
end
end

0 comments on commit 61fc8dd

Please sign in to comment.