bridgetown-builder 1.0.0.alpha2 → 1.0.0.alpha3

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: 5daed3d805daca68bcf04c10c5a129aa3543958ed7cb40e7fd1bfc48ff1b5d71
4
+ data.tar.gz: 1bf1cab7474d8a296fabd72f1c64d7bb98460a56104f56a154565d59424f3ded
5
5
  SHA512:
6
- metadata.gz: eb054f8e6d98563ce0a51eb107541b5eb29bcba3b37a5e8f8dd2a291c09b4afca853636bd2607336d5913051df4a42ff181e2f4c53f1f23db73bd3708b01f516
7
- data.tar.gz: 59afe7e839fe814961cca180b6fd89941b564635bf9bef5dd100812c33e2634c8ede3fa46de3381b88ad9d064034c47c5296696f7958d79a5f33790d75cb412f
6
+ metadata.gz: 869e94944138ff6dbf0d756a51828f3d6a520b9f843b98a812d21113c8fc543dfecd1e4b10b82d0566945e31137b5b902d08c3d91de5990fd21da9a092db90db
7
+ data.tar.gz: 105b9688d9065c50a7ff21a01f0f34c91d6c10c73aea3f56803f9ebecda2b1dcf411fb7d56e9167d05df24d2e5c385cd32c15f613fcd40ad6ec78b23f4afb24a
@@ -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.alpha3
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-18 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.alpha3
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.alpha3
27
27
  description:
28
28
  email: maintainers@bridgetownrb.com
29
29
  executables: []