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 +4 -4
- data/lib/bridgetown-builder/builder.rb +14 -12
- data/lib/bridgetown-builder/dsl/generators.rb +1 -1
- data/lib/bridgetown-builder/dsl/helpers.rb +14 -22
- data/lib/bridgetown-builder/dsl/hooks.rb +2 -2
- data/lib/bridgetown-builder/dsl/http.rb +2 -2
- data/lib/bridgetown-builder/dsl/liquid.rb +2 -2
- data/lib/bridgetown-builder/dsl/resources.rb +1 -1
- data/lib/bridgetown-builder/plugin.rb +1 -17
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be80790b8d2984c7d6fd2eb4e1b8a00ab76aff9130b25a3cd4064dd3bbadfd82
|
4
|
+
data.tar.gz: b96958d6a9b1bd6cdc1a180af7ae53f54069290d7e679a0ec0adcfc0d85835b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
17
|
-
|
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
|
21
|
-
|
19
|
+
def callbacks
|
20
|
+
@callbacks ||= {}
|
22
21
|
end
|
23
22
|
|
24
|
-
def
|
25
|
-
|
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
|
-
|
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
|
|
@@ -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,
|
11
|
+
def helper(helper_name, method_name = nil, &block)
|
12
12
|
m = Module.new
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
)
|
19
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
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
|
17
|
-
functions << { name
|
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:
|
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:
|
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
|
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
|
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::
|
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:
|
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-
|
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:
|
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:
|
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:
|
67
|
+
version: 1.3.1
|
68
68
|
requirements: []
|
69
|
-
rubygems_version: 3.
|
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
|