bridgetown-builder 1.0.0.alpha1 → 1.0.0.alpha5

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: 3670da54487f5fb5c550eeeb4ce89d7437cfc2641e8557ed04636ba1853dcc37
4
- data.tar.gz: 3a699187328b8e8e508ac269b63e35f92e85c0d1017784783268d40df5a97736
3
+ metadata.gz: 480dce3843c12ad944e313aa1d31fadc4a4b91d7aaac47e408fd2627b9da09ab
4
+ data.tar.gz: e9d7a6a7878df212b3e3a96cced65f19e17649cd8f6faf29ede57739c9059627
5
5
  SHA512:
6
- metadata.gz: a21fc74c5433d45562505f4b1b300579f0c568546abd7d5b1355071936a8f7c4ee04c722499dde5ce9f0fd5601d307d60b181ed07004f21bfe3c4908cb906c8c
7
- data.tar.gz: ac73d8a594532014055ca161a4bcae5094eb5829088b520eb98abd2b7d2057f99431f699b38ead83cef2a081723379574e03368e01ced3c6268a6b374f4ff006
6
+ metadata.gz: f958566d2b63616e9db00315a97657b107b00d8bc2fac7c19a21f47efb72bb59299f1ce90210239fb0f5c944c56b0e1ff0ab15e6f765c736f23d1084ff7fd47e
7
+ data.tar.gz: c88214e34b9c7ddb0a2b43a36ee5d7d79843f813d934e0b713827781c3551f2cca0e5171c6054ec97edada9e0baff9f847832b06c6e4d12c3bf7ab6e7d130d1d
data/.rubocop.yml CHANGED
@@ -2,8 +2,9 @@
2
2
  inherit_from: ../.rubocop.yml
3
3
 
4
4
  AllCops:
5
- Include:
6
- - lib/**/*.rb
5
+ Exclude:
6
+ - "*.gemspec"
7
+ - test/**/*.rb
7
8
 
8
9
  Metrics/AbcSize:
9
10
  Exclude:
@@ -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
@@ -24,7 +38,8 @@ module Bridgetown
24
38
  end
25
39
 
26
40
  def self.descendants
27
- super.reject { |klass| ["SiteBuilder"].include?(klass.name) }
41
+ site_builder_name = "SiteBuilder"
42
+ super.reject { |klass| [site_builder_name].include?(klass.name) }
28
43
  end
29
44
  end
30
45
  end
@@ -10,14 +10,14 @@ module Bridgetown
10
10
  module HTTP
11
11
  def get(url, headers: {}, parse_json: true)
12
12
  body = begin
13
- connection(parse_json: parse_json).get(url, headers: headers).body
14
- rescue Faraday::ParsingError
15
- Bridgetown.logger.error(
16
- "Faraday::ParsingError",
17
- "The response from #{url} did not contain valid JSON"
18
- )
19
- nil
20
- end
13
+ connection(parse_json: parse_json).get(url, headers: headers).body
14
+ rescue Faraday::ParsingError
15
+ Bridgetown.logger.error(
16
+ "Faraday::ParsingError",
17
+ "The response from #{url} did not contain valid JSON"
18
+ )
19
+ nil
20
+ end
21
21
  yield body
22
22
  end
23
23
 
@@ -4,7 +4,7 @@ module Bridgetown
4
4
  module Builders
5
5
  module DSL
6
6
  module Resources
7
- def add_resource(collection_name, path, &block)
7
+ def add_resource(collection_name, path, &block) # rubocop:todo Metrics/AbcSize
8
8
  data = Bridgetown::Utils::RubyFrontMatter.new(scope: self).tap do |fm|
9
9
  fm.define_singleton_method(:___) do |hsh|
10
10
  hsh.each do |k, v|
@@ -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.alpha1
4
+ version: 1.0.0.alpha5
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-22 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.alpha1
19
+ version: 1.0.0.alpha5
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.alpha1
26
+ version: 1.0.0.alpha5
27
27
  description:
28
28
  email: maintainers@bridgetownrb.com
29
29
  executables: []