bridgetown-builder 1.0.0.alpha2 → 1.0.0.alpha6

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: d052e4df4a73dd7e9904d1a9ca2b9a14a3ba6539ba65133755a80a526d3ea88a
4
- data.tar.gz: 0ef018d8a40f09aedf1946503596499d231ada3509f122aac296768eb0484eec
3
+ metadata.gz: 8971524f8867ae02f9328bb0d3f053258af1f3aeeee7036766c7521516ec6f83
4
+ data.tar.gz: 0e9aa42948d5894926c8e19e92a862c4774707f1df93a94c2c1751c2c2c3f4ed
5
5
  SHA512:
6
- metadata.gz: eb054f8e6d98563ce0a51eb107541b5eb29bcba3b37a5e8f8dd2a291c09b4afca853636bd2607336d5913051df4a42ff181e2f4c53f1f23db73bd3708b01f516
7
- data.tar.gz: 59afe7e839fe814961cca180b6fd89941b564635bf9bef5dd100812c33e2634c8ede3fa46de3381b88ad9d064034c47c5296696f7958d79a5f33790d75cb412f
6
+ metadata.gz: 86aeb890d567bd79d9e40857648242820afaad0a62fc655f71e9295429a13a3bba8dc4e2bd1d244c7661bdbc06ec375aa4f30581a3ce37e39e36bc05e556a032
7
+ data.tar.gz: 810174f85545376b007088ed706a9f612b2aa07d1bcc251efc87d05a89f21107443a2fae530a6a5333e92800aa9a6b8f391cd9d08c3620ff2268ab396388b64f
@@ -4,19 +4,33 @@ module Bridgetown
4
4
  # Superclass for a website's SiteBuilder abstract class
5
5
  class Builder < Bridgetown::Builders::PluginBuilder
6
6
  extend ActiveSupport::DescendantsTracker
7
+ include ActiveSupport::Callbacks
8
+
9
+ define_callbacks :build
7
10
 
8
11
  class << self
9
12
  def register
10
13
  Bridgetown::Hooks.register_one :site, :pre_read, reloadable: false do |site|
11
- new(name, site)
14
+ new(name, site).build_with_callbacks
12
15
  end
13
16
  end
17
+
18
+ ruby2_keywords def before_build(*args, &block)
19
+ set_callback :build, :before, *args, &block
20
+ end
21
+
22
+ ruby2_keywords def after_build(*args, &block)
23
+ set_callback :build, :after, *args, &block
24
+ end
25
+
26
+ ruby2_keywords def around_build(*args, &block)
27
+ set_callback :build, :around, *args, &block
28
+ end
14
29
  end
15
30
 
16
- # Subclass is expected to implement #build
17
- def initialize(name, current_site = nil)
18
- super(name, current_site)
19
- build
31
+ def build_with_callbacks
32
+ run_callbacks(:build) { build }
33
+ self
20
34
  end
21
35
 
22
36
  def inspect
@@ -18,9 +18,9 @@ module Bridgetown
18
18
 
19
19
  attr_accessor :functions, :name, :site, :config
20
20
 
21
- def initialize(name, current_site = nil)
21
+ def initialize(name = nil, current_site = nil)
22
22
  self.functions = Set.new
23
- self.name = name
23
+ self.name = name || self.class.name
24
24
  self.site = current_site || Bridgetown.sites.first
25
25
 
26
26
  self.config = if defined?(self.class::CONFIG_DEFAULTS)
@@ -16,7 +16,7 @@ Bridgetown::Hooks.register_one :site, :pre_read, priority: :low, reloadable: fal
16
16
  # builders, but if the site hasn't defined it explicitly, this is a no-op
17
17
  if defined?(SiteBuilder)
18
18
  SiteBuilder.descendants.map do |c|
19
- c.new(c.name, site)
19
+ c.new(c.name, site).build_with_callbacks
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha2
4
+ version: 1.0.0.alpha6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-16 00:00:00.000000000 Z
11
+ date: 2021-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bridgetown-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0.alpha2
19
+ version: 1.0.0.alpha6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0.alpha2
26
+ version: 1.0.0.alpha6
27
27
  description:
28
28
  email: maintainers@bridgetownrb.com
29
29
  executables: []