bridgetown-builder 0.16.0 → 0.18.2

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: b81d6c5ce68477ceb3db93d8f06c120a7d8177c499c37e54e140e2250ca4e941
4
- data.tar.gz: 2a99639a7cf8a44e667048045b40b2c87d7c8b649b0acbf2888966cce2550fdc
3
+ metadata.gz: 4b32f79ca6d8f760521955ac5e5f37e54fac0ef8920835186507c45e4852d04e
4
+ data.tar.gz: 0f8a5c72b1a50d81eb1731e0edeb83eef9a52900712e97803403a26340830b5b
5
5
  SHA512:
6
- metadata.gz: 31bec085d4259785fe2924bf41618f1bcab6c95867a71d1d8d1dc50135db91d315e122c97443e3baa2ef9f7d2cc207811ef137d704b73796142fd0a4588bfbd4
7
- data.tar.gz: 7c1b1c10bf00fe2fbbc40d1f294bbe925fec0ef475519deb3baf2518433b8ccbcc14cf8cc46e5f44b2e49e89729dd9772b512aabf1107839adbf70af6f9abf40
6
+ metadata.gz: 4ad71a1915d2df5b8410739202619e205c2cda8ad33806c065d453aeb430419202af35b54c8cf2c9b822ab960f7c269a3ec251664819ee49e9883263078a249d
7
+ data.tar.gz: a73161919bea8ce9c2beee579dd5cf5bf22cce9ec39cd6a93c31a590fd768de6be1b6589ac2083d3ac6b41b99872a7dfdb4b00be83c9afa22d970fdea9e97981
@@ -8,7 +8,7 @@ AllCops:
8
8
 
9
9
  Metrics/AbcSize:
10
10
  Exclude:
11
- - lib/bridgetown-builder/dsl/*
11
+ - lib/bridgetown-builder/dsl/generators.rb
12
12
  Metrics/MethodLength:
13
13
  Exclude:
14
14
  - lib/bridgetown-builder/dsl/*
@@ -8,7 +8,7 @@ module Bridgetown
8
8
  def initialize(site, path)
9
9
  @site = site
10
10
  @path = path
11
- @data = ActiveSupport::HashWithIndifferentAccess.new
11
+ @data = HashWithDotAccess::Hash.new
12
12
  end
13
13
 
14
14
  def front_matter(data)
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ module Builders
5
+ module DSL
6
+ module Helpers
7
+ def helper(helper_name, method_name = nil, helpers_scope: false, &block)
8
+ builder_self = self
9
+ m = Module.new
10
+
11
+ if block && !helpers_scope
12
+ m.define_method helper_name do |*args|
13
+ builder_self.instance_exec(*args, &block)
14
+ end
15
+ else
16
+ block = method(method_name) if method_name
17
+ m.define_method helper_name, &block
18
+ end
19
+
20
+ Bridgetown::RubyTemplateView::Helpers.include(m)
21
+
22
+ functions << { name: name, filter: m }
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -5,10 +5,18 @@ module Bridgetown
5
5
  module DSL
6
6
  module Liquid
7
7
  def liquid_filter(filter_name, method_name = nil, &block)
8
- block = method(method_name) if method_name.is_a?(Symbol)
9
-
8
+ builder_self = self
10
9
  m = Module.new
11
- m.send(:define_method, filter_name, &block)
10
+
11
+ if block
12
+ m.define_method filter_name do |*args|
13
+ builder_self.instance_exec(*args, &block)
14
+ end
15
+ elsif method_name
16
+ block = method(method_name)
17
+ m.define_method filter_name, &block
18
+ end
19
+
12
20
  ::Liquid::Template.register_filter(m)
13
21
 
14
22
  functions << { name: name, filter: m }
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bridgetown-builder/dsl/generators"
4
+ require "bridgetown-builder/dsl/helpers"
4
5
  require "bridgetown-builder/dsl/hooks"
5
6
  require "bridgetown-builder/dsl/http"
6
7
  require "bridgetown-builder/dsl/liquid"
@@ -8,6 +9,7 @@ module Bridgetown
8
9
  module Builders
9
10
  class PluginBuilder
10
11
  include DSL::Generators
12
+ include DSL::Helpers
11
13
  include DSL::Hooks
12
14
  include DSL::HTTP
13
15
  include DSL::Liquid
@@ -21,7 +23,7 @@ module Bridgetown
21
23
 
22
24
  self.config = if defined?(self.class::CONFIG_DEFAULTS)
23
25
  Bridgetown::Utils.deep_merge_hashes(
24
- self.class::CONFIG_DEFAULTS.with_indifferent_access, site.config
26
+ self.class::CONFIG_DEFAULTS.with_dot_access, site.config
25
27
  )
26
28
  else
27
29
  site.config
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: 0.16.0
4
+ version: 0.18.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-28 00:00:00.000000000 Z
11
+ date: 2020-10-30 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: 0.16.0
19
+ version: 0.18.2
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: 0.16.0
26
+ version: 0.18.2
27
27
  description:
28
28
  email: maintainers@bridgetownrb.com
29
29
  executables: []
@@ -38,6 +38,7 @@ files:
38
38
  - lib/bridgetown-builder/document.rb
39
39
  - lib/bridgetown-builder/documents_generator.rb
40
40
  - lib/bridgetown-builder/dsl/generators.rb
41
+ - lib/bridgetown-builder/dsl/helpers.rb
41
42
  - lib/bridgetown-builder/dsl/hooks.rb
42
43
  - lib/bridgetown-builder/dsl/http.rb
43
44
  - lib/bridgetown-builder/dsl/liquid.rb
@@ -61,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
62
  - !ruby/object:Gem::Version
62
63
  version: '0'
63
64
  requirements: []
64
- rubygems_version: 3.0.6
65
+ rubygems_version: 3.1.4
65
66
  signing_key:
66
67
  specification_version: 4
67
68
  summary: A Bridgetown plugin to provide a sophisticated DSL for writing plugins at