bridgetown-builder 1.3.4 → 2.0.0.beta1

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: ba0aa68627e53754dfcd113621877b2e078baad0ae85e642bfa1d4150935bb00
4
- data.tar.gz: 6315eb5d983efc7b58e99e3473882fe6313ea386cb6e00c2bc4e5cba862c4758
3
+ metadata.gz: be80790b8d2984c7d6fd2eb4e1b8a00ab76aff9130b25a3cd4064dd3bbadfd82
4
+ data.tar.gz: b96958d6a9b1bd6cdc1a180af7ae53f54069290d7e679a0ec0adcfc0d85835b5
5
5
  SHA512:
6
- metadata.gz: e58f5415f1f4479dbcb82d1c79804796e1f0ccef250148a14fd20f19ca45d2b26c9318cabed64d9a315331e22609526548bd24cd211f8b804aa2e22a58dd6b6f
7
- data.tar.gz: c5b73e93eb2024b95b4de65f006c482f10587b51405034c1db27dded504d64994bd797336a4450de98103e12aa28fe0f59c1976bdb3d0634661ed8d79ea6ccb7
6
+ metadata.gz: d428ae3dd232c91771cbe169510daaddb332d62421003ca877c8c7d0c6dc176d5ad20640bc6f0d2070f0adf5189a6ce62cbe969e3905c0de2578931fd55d4f9e
7
+ data.tar.gz: 06ce5dd04af8f8c25277200d6f22d7754ad2f0436dbcf83ef3725fb245f05a21eb826b556976bd99e8e768e741dec90f86ca571b956bb6a5a6b06047b679fd05
@@ -3,31 +3,33 @@
3
3
  module Bridgetown
4
4
  # Superclass for a website's SiteBuilder abstract class
5
5
  class Builder < Bridgetown::Builders::PluginBuilder
6
- extend ActiveSupport::DescendantsTracker
7
- include ActiveSupport::Callbacks
8
-
9
- define_callbacks :build
10
-
11
6
  class << self
12
7
  def register
13
8
  Bridgetown::Builders::PluginBuilder.plugin_registrations << self
14
9
  end
15
10
 
16
- def before_build(*args, **kwargs, &block)
17
- set_callback :build, :before, *args, **kwargs, &block
11
+ def before_build(...)
12
+ add_callback(:before, ...)
13
+ end
14
+
15
+ def after_build(...)
16
+ add_callback(:after, ...)
18
17
  end
19
18
 
20
- def after_build(*args, **kwargs, &block)
21
- set_callback :build, :after, *args, **kwargs, &block
19
+ def callbacks
20
+ @callbacks ||= {}
22
21
  end
23
22
 
24
- def around_build(*args, **kwargs, &block)
25
- set_callback :build, :around, *args, **kwargs, &block
23
+ def add_callback(name, method_name = nil, &block)
24
+ callbacks[name] ||= []
25
+ callbacks[name] << (block || proc { send(method_name) })
26
26
  end
27
27
  end
28
28
 
29
29
  def build_with_callbacks
30
- run_callbacks(:build) { build }
30
+ self.class.callbacks[:before]&.each { instance_exec(&_1) }
31
+ build
32
+ self.class.callbacks[:after]&.each { instance_exec(&_1) }
31
33
  self
32
34
  end
33
35
 
@@ -29,7 +29,7 @@ module Bridgetown
29
29
  site.generators << anon_generator.new(site.config)
30
30
  site.generators.sort!
31
31
 
32
- functions << { name: name, generator: anon_generator }
32
+ functions << { name:, generator: anon_generator }
33
33
  end
34
34
  end
35
35
  end
@@ -8,36 +8,28 @@ module Bridgetown
8
8
  @helpers # could be nil
9
9
  end
10
10
 
11
- def helper(helper_name, method_name = nil, helpers_scope: false, &block)
11
+ def helper(helper_name, method_name = nil, &block)
12
12
  m = Module.new
13
13
 
14
- if block && helpers_scope
15
- Deprecator.deprecation_message(
16
- "The `helpers_scope' functionality is deprecated. Use the `helpers' builder " \
17
- "method to access the helpers scope in your plugin."
18
- )
19
- m.define_method helper_name, &block
20
- else
21
- builder_self = self
22
- method_name ||= helper_name unless block
23
- unless method_name
24
- method_name = :"__helper_#{helper_name}"
25
- builder_self.define_singleton_method(method_name) do |*args, **kwargs, &block2|
26
- block.(*args, **kwargs, &block2)
27
- end
14
+ builder_self = self
15
+ method_name ||= helper_name unless block
16
+ unless method_name
17
+ method_name = :"__helper_#{helper_name}"
18
+ builder_self.define_singleton_method(method_name) do |*args, **kwargs, &block2|
19
+ block.(*args, **kwargs, &block2)
28
20
  end
29
- m.define_method helper_name do |*args, **kwargs, &block2|
30
- prev_var = builder_self.instance_variable_get(:@helpers)
31
- builder_self.instance_variable_set(:@helpers, self)
32
- builder_self.send(method_name, *args, **kwargs, &block2).tap do
33
- builder_self.instance_variable_set(:@helpers, prev_var)
34
- end
21
+ end
22
+ m.define_method helper_name do |*args, **kwargs, &block2|
23
+ prev_var = builder_self.instance_variable_get(:@helpers)
24
+ builder_self.instance_variable_set(:@helpers, self)
25
+ builder_self.send(method_name, *args, **kwargs, &block2).tap do
26
+ builder_self.instance_variable_set(:@helpers, prev_var)
35
27
  end
36
28
  end
37
29
 
38
30
  Bridgetown::RubyTemplateView::Helpers.include(m)
39
31
 
40
- functions << { name: name, filter: m }
32
+ functions << { name:, filter: m }
41
33
  end
42
34
  end
43
35
  end
@@ -13,8 +13,8 @@ module Bridgetown
13
13
  )
14
14
  block = method(method_name) if method_name.is_a?(Symbol)
15
15
 
16
- hook_block = Bridgetown::Hooks.register_one(owner, event, priority: priority, &block)
17
- functions << { name: name, hook: [owner, event, priority, hook_block] }
16
+ hook_block = Bridgetown::Hooks.register_one(owner, event, priority:, &block)
17
+ functions << { name:, hook: [owner, event, priority, hook_block] }
18
18
  end
19
19
 
20
20
  def add_data(data_key)
@@ -8,7 +8,7 @@ module Bridgetown
8
8
  module HTTP
9
9
  def get(url, headers: {}, parse_json: true, **params)
10
10
  body = begin
11
- connection(parse_json: parse_json).get(url, params, headers).body
11
+ connection(parse_json:).get(url, params, headers).body
12
12
  rescue Faraday::ParsingError
13
13
  Bridgetown.logger.error(
14
14
  "Faraday::ParsingError",
@@ -22,7 +22,7 @@ module Bridgetown
22
22
  def connection(headers: {}, parse_json: true)
23
23
  headers["Content-Type"] = "application/json" if parse_json
24
24
 
25
- Faraday.new(headers: headers) do |faraday|
25
+ Faraday.new(headers:) do |faraday|
26
26
  faraday.response :follow_redirects
27
27
 
28
28
  if parse_json
@@ -41,7 +41,7 @@ module Bridgetown
41
41
 
42
42
  ::Liquid::Template.register_filter(m)
43
43
 
44
- functions << { name: name, filter: m }
44
+ functions << { name:, filter: m }
45
45
  end
46
46
 
47
47
  def liquid_tag(tag_name, method_name = nil, as_block: false, &block)
@@ -68,7 +68,7 @@ module Bridgetown
68
68
  end
69
69
 
70
70
  ::Liquid::Template.register_tag tag_name, tag
71
- functions << { name: name, tag: [tag_name, tag] }
71
+ functions << { name:, tag: [tag_name, tag] }
72
72
  end
73
73
  end
74
74
  end
@@ -9,7 +9,7 @@ module Bridgetown
9
9
  end
10
10
 
11
11
  def add_resource(collection_name, path, &block) # rubocop:todo Metrics/AbcSize
12
- data = Bridgetown::Utils::RubyFrontMatter.new(scope: self).tap do |fm|
12
+ data = Bridgetown::FrontMatter::RubyFrontMatter.new(scope: self).tap do |fm|
13
13
  fm.define_singleton_method(:___) do |hsh|
14
14
  hsh.each do |k, v|
15
15
  fm.set k, v
@@ -41,23 +41,7 @@ module Bridgetown
41
41
  self.functions = Set.new
42
42
  self.name = name || self.class.name
43
43
  self.site = current_site || Bridgetown::Current.site
44
-
45
- self.config = if defined?(self.class::CONFIG_DEFAULTS)
46
- Deprecator.deprecation_message(
47
- "Using `CONFIG_DEFAULTS' in your builder is deprecated. " \
48
- "Switch to defining config data via an initializer instead."
49
- )
50
- Bridgetown::Utils.deep_merge_hashes(
51
- self.class::CONFIG_DEFAULTS.with_dot_access, site.config
52
- )
53
- else
54
- site.config
55
- end
56
- end
57
-
58
- def doc(*)
59
- raise Bridgetown::Errors::FatalException,
60
- "The `doc' method has been removed. Please use the `new_resource' builder DSL instead"
44
+ self.config = site.config
61
45
  end
62
46
  end
63
47
  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.3.4
4
+ version: 2.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-28 00:00:00.000000000 Z
11
+ date: 2024-08-02 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.3.4
19
+ version: 2.0.0.beta1
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.3.4
26
+ version: 2.0.0.beta1
27
27
  description:
28
28
  email: maintainers@bridgetownrb.com
29
29
  executables: []
@@ -62,11 +62,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
62
  version: '0'
63
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ">="
65
+ - - ">"
66
66
  - !ruby/object:Gem::Version
67
- version: '0'
67
+ version: 1.3.1
68
68
  requirements: []
69
- rubygems_version: 3.2.33
69
+ rubygems_version: 3.3.26
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: A Bridgetown plugin to provide a sophisticated DSL for writing plugins at