bridgetown-core 1.2.0.beta5 → 1.2.0

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: 7db2117b99eb2b2943920e6cbfe4267b2a668842de44e360df645da6554ea877
4
- data.tar.gz: b8e3652ab12db38512546612a74df6939bd841166d9cfae371aa75d6ae8d8265
3
+ metadata.gz: 599f0ff57d4bac2146e5cacb12ccb8f2e7e02026815447c2db9cbf914ed9d3a2
4
+ data.tar.gz: be29cede2daa248b4db41bb6a7eaeebb7d3533b54a5cf891922b0762a6ca47e0
5
5
  SHA512:
6
- metadata.gz: 446f796d17a209b19afdb9d8f349d1e5197d7f5600598bc21be3c23c73df7d10c125379d739bd608322d404365ca37b4a37cbe9b38fa8bdd22a97c84c41bee7c
7
- data.tar.gz: 89293450447e8acb5718cdcdc782124699faa138c559474c5df66609715163fca809d4ed477cf5ee75b905f62e0bcbd540f62a46841b8c58fede225670ae429b
6
+ metadata.gz: 739ed852e60fabf0b6b2d352c8ce8993d4751a1f6cfec67c0bb7ed4cc5f0af41bb82fb8dc3eb34f5806a421bcec38e9050cd0fbcb50249a0482f5804e19a1d27
7
+ data.tar.gz: 97eea9cb28095624a8d47821f754df39790d8db46e62d79774371113c875fd914a796f3e445ad982e6f8de8e94d5babf7b8be1736c4bc93f3a9fe0a0f6862433
@@ -49,7 +49,6 @@ Gem::Specification.new do |s|
49
49
  s.add_runtime_dependency("roda", "~> 3.46")
50
50
  s.add_runtime_dependency("rouge", "~> 3.0")
51
51
  s.add_runtime_dependency("serbea", "~> 1.0")
52
- s.add_runtime_dependency("terminal-table", "~> 1.8")
53
52
  s.add_runtime_dependency("thor", "~> 1.1")
54
53
  s.add_runtime_dependency("tilt", "~> 2.0")
55
54
  s.add_runtime_dependency("webrick", "~> 1.7")
@@ -126,7 +126,7 @@ module Bridgetown
126
126
  Layouts, you'd run:\n
127
127
  bridgetown plugins cd SamplePlugin/Layouts
128
128
  DOC
129
- desc "cd <origin/dir>", "Open folder (content, layouts, etc.) within the plugin origin"
129
+ desc "cd <origin/dir>", "Open content folder within the plugin origin"
130
130
 
131
131
  # This is super useful if you want to copy files out of plugins to override.
132
132
  #
@@ -177,38 +177,43 @@ module Bridgetown
177
177
  end
178
178
  end
179
179
 
180
- desc "new NAME", "Create a new plugin NAME by cloning the sample plugin repo"
180
+ desc "new NAME", "Create a new plugin NAME (snake_case_name_preferred)"
181
181
  def new(name)
182
182
  folder_name = name.underscore
183
183
  module_name = folder_name.camelize
184
184
 
185
- run "git clone -b v1.2-initializer https://github.com/bridgetownrb/bridgetown-sample-plugin #{name}"
186
- new_gemspec = "#{name}.gemspec"
185
+ run "git clone https://github.com/bridgetownrb/bridgetown-sample-plugin #{name}"
186
+ new_gemspec = "#{folder_name}.gemspec"
187
187
 
188
188
  inside name do # rubocop:todo Metrics/BlockLength
189
189
  destroy_existing_repo
190
190
  initialize_new_repo
191
191
 
192
- FileUtils.mv "bridgetown-sample-plugin.gemspec", new_gemspec.to_s
192
+ FileUtils.mv "sample_plugin.gemspec", new_gemspec
193
193
  gsub_file new_gemspec, "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}"
194
194
  gsub_file new_gemspec, "bridgetown-sample-plugin", name
195
- gsub_file new_gemspec, "sample-plugin", name
195
+ gsub_file new_gemspec, "sample_plugin", folder_name
196
196
  gsub_file new_gemspec, "SamplePlugin", module_name
197
197
 
198
198
  gsub_file "package.json", "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}"
199
199
  gsub_file "package.json", "bridgetown-sample-plugin", name
200
+ gsub_file "package.json", "sample_plugin", folder_name
200
201
 
201
202
  FileUtils.mv "lib/sample_plugin.rb", "lib/#{folder_name}.rb"
202
- gsub_file "lib/#{name}.rb", "sample_plugin", folder_name
203
- gsub_file "lib/#{name}.rb", "SamplePlugin", module_name
203
+ gsub_file "lib/#{folder_name}.rb", "sample_plugin", folder_name
204
+ gsub_file "lib/#{folder_name}.rb", "SamplePlugin", module_name
204
205
 
205
206
  FileUtils.mv "lib/sample_plugin", "lib/#{folder_name}"
206
- gsub_file "lib/#{name}/builder.rb", "SamplePlugin", module_name
207
- gsub_file "lib/#{name}/version.rb", "SamplePlugin", module_name
207
+ gsub_file "lib/#{folder_name}/builder.rb", "SamplePlugin", module_name
208
+ gsub_file "lib/#{folder_name}/builder.rb", "sample_plugin", folder_name
209
+ gsub_file "lib/#{folder_name}/version.rb", "SamplePlugin", module_name
208
210
 
209
211
  FileUtils.mv "test/test_sample_plugin.rb", "test/test_#{folder_name}.rb"
210
212
  gsub_file "test/test_#{folder_name}.rb", "SamplePlugin", module_name
211
- gsub_file "test/helper.rb", "sample-plugin", name
213
+ gsub_file "test/test_#{folder_name}.rb", "sample plugin", module_name
214
+ gsub_file "test/helper.rb", "sample_plugin", folder_name
215
+ gsub_file "test/fixtures/src/index.html", "sample_plugin", folder_name
216
+ gsub_file "test/fixtures/config/initializers.rb", "sample_plugin", folder_name
212
217
 
213
218
  FileUtils.mv "components/sample_plugin", "components/#{folder_name}"
214
219
  FileUtils.mv "content/sample_plugin", "content/#{folder_name}"
@@ -220,14 +225,15 @@ module Bridgetown
220
225
 
221
226
  gsub_file "components/#{folder_name}/plugin_component.rb", "SamplePlugin", module_name
222
227
 
223
- gsub_file "frontend/javascript/index.js", "bridgetown-sample-plugin", name
228
+ gsub_file "frontend/javascript/index.js", "sample_plugin", folder_name
224
229
  gsub_file "frontend/javascript/index.js", "SamplePlugin", module_name
230
+ gsub_file "frontend/styles/index.css", "sample_plugin", folder_name
225
231
  end
226
232
  say ""
227
233
  say_status "Done!", "Have fun writing your new #{name} plugin :)"
228
234
  say_status "Remember:", "Don't forget to rename the SamplePlugin" \
229
235
  " code identifiers and paths to your own" \
230
- " indentifer, as well as update your README" \
236
+ " identifier, as well as update your README" \
231
237
  " and CHANGELOG files as necessary."
232
238
  end
233
239
 
@@ -9,9 +9,9 @@ module Bridgetown
9
9
 
10
10
  YAML_HEADER = %r!\A---\s*\n!.freeze
11
11
  YAML_BLOCK = %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m.freeze
12
- RUBY_HEADER = %r!\A[~`#\-]{3,}(?:ruby|<%|{%)\s*\n!.freeze
12
+ RUBY_HEADER = %r!\A[~`#-]{3,}(?:ruby|<%|{%)\s*\n!.freeze
13
13
  RUBY_BLOCK =
14
- %r!#{RUBY_HEADER.source}(.*?\n?)^((?:%>|%})?[~`#\-]{3,}\s*$\n?)!m.freeze
14
+ %r!#{RUBY_HEADER.source}(.*?\n?)^((?:%>|%})?[~`#-]{3,}\s*$\n?)!m.freeze
15
15
 
16
16
  def read_front_matter(file_path) # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
17
17
  file_contents = File.read(
@@ -72,6 +72,10 @@ module Bridgetown
72
72
  @scope.roda_initializers << block
73
73
  end
74
74
 
75
+ def timezone(tz) # rubocop:disable Naming/MethodParameterName
76
+ Bridgetown.set_timezone(tz)
77
+ end
78
+
75
79
  def method_missing(key, *value, &block) # rubocop:disable Style/MissingRespondToMissing
76
80
  return get(key) if value.empty? && block.nil?
77
81
 
@@ -132,7 +136,7 @@ module Bridgetown
132
136
 
133
137
  if require_initializer
134
138
  init_file_name = File.join(@scope.root_dir, "config", "#{name}.rb")
135
- require(init_file_name) if File.exist?(init_file_name)
139
+ load(init_file_name) if File.exist?(init_file_name)
136
140
  end
137
141
 
138
142
  @scope.initializers[name.to_sym]
@@ -134,7 +134,7 @@ module Bridgetown
134
134
  initializers_file = File.join(root_dir, "config", "initializers.rb")
135
135
  return unless File.file?(initializers_file)
136
136
 
137
- require initializers_file
137
+ load initializers_file
138
138
 
139
139
  return unless initializers # no initializers have been set up
140
140
 
@@ -17,7 +17,9 @@ module Bridgetown
17
17
  private
18
18
 
19
19
  def tabulate(data)
20
- require "terminal-table"
20
+ unless defined?(Terminal::Table)
21
+ Bridgetown::Utils::RequireGems.require_with_graceful_fail "terminal-table"
22
+ end
21
23
 
22
24
  header = data.shift
23
25
  footer = data.pop
@@ -7,9 +7,9 @@ module Bridgetown
7
7
  include Bridgetown::Utils::RubyFrontMatterDSL
8
8
 
9
9
  YAML_FRONT_MATTER_REGEXP = %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m.freeze
10
- RUBY_FRONT_MATTER_HEADER = %r!\A[~`#\-]{3,}(?:ruby|<%|{%)\s*\n!.freeze
10
+ RUBY_FRONT_MATTER_HEADER = %r!\A[~`#-]{3,}(?:ruby|<%|{%)\s*\n!.freeze
11
11
  RUBY_FRONT_MATTER_REGEXP =
12
- %r!#{RUBY_FRONT_MATTER_HEADER.source}(.*?\n?)^((?:%>|%})?[~`#\-]{3,}\s*$\n?)!m.freeze
12
+ %r!#{RUBY_FRONT_MATTER_HEADER.source}(.*?\n?)^((?:%>|%})?[~`#-]{3,}\s*$\n?)!m.freeze
13
13
 
14
14
  # @return [String]
15
15
  attr_accessor :content
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "1.2.0.beta5"
4
+ VERSION = "1.2.0"
5
5
  CODE_NAME = "Bonny Slope"
6
6
  end
@@ -136,6 +136,8 @@ module Bridgetown
136
136
  end
137
137
  alias_method :env, :environment
138
138
 
139
+ # Set up the Bridgetown execution environment before attempting to load any
140
+ # plugins or gems prior to a site build
139
141
  def begin!
140
142
  ENV["RACK_ENV"] ||= environment
141
143
 
@@ -178,6 +180,38 @@ module Bridgetown
178
180
  end
179
181
  end
180
182
 
183
+ # Initialize a preflight configuration object, copying initializers and
184
+ # source manifests from a previous standard configuration if necessary.
185
+ # Typically only needed in test suites to reset before a new test.
186
+ #
187
+ # @return [Bridgetown::Configuration::Preflight]
188
+ def reset_configuration! # rubocop:disable Metrics/AbcSize
189
+ if Bridgetown::Current.preloaded_configuration.nil?
190
+ return Bridgetown::Current.preloaded_configuration =
191
+ Bridgetown::Configuration::Preflight.new
192
+ end
193
+
194
+ return unless Bridgetown::Current.preloaded_configuration.is_a?(Bridgetown::Configuration)
195
+
196
+ previous_config = Bridgetown::Current.preloaded_configuration
197
+ new_config = Bridgetown::Configuration::Preflight.new
198
+ new_config.initializers = previous_config.initializers
199
+ new_config.source_manifests = previous_config.source_manifests
200
+ if new_config.initializers
201
+ new_config.initializers.delete(:init)
202
+ new_config.initializers.select! do |_k, initializer|
203
+ next false if initializer.block.source_location[0].start_with?(
204
+ File.join(previous_config.root_dir, "config")
205
+ )
206
+
207
+ initializer.completed = false
208
+ true
209
+ end
210
+ end
211
+
212
+ Bridgetown::Current.preloaded_configuration = new_config
213
+ end
214
+
181
215
  def initializer(name, prepend: false, replace: false, &block) # rubocop:todo Metrics
182
216
  unless Bridgetown::Current.preloaded_configuration
183
217
  raise "The `#{name}' initializer in #{block.source_location[0]} was called " \
@@ -276,6 +310,14 @@ module Bridgetown
276
310
  def set_timezone(timezone)
277
311
  ENV["TZ"] = timezone
278
312
  end
313
+
314
+ # Get the current TZ environment variable
315
+ #
316
+ # @return [String]
317
+ def timezone
318
+ ENV["TZ"]
319
+ end
320
+
279
321
  # rubocop:enable Naming/AccessorMethodName
280
322
 
281
323
  # Fetch the logger instance for this Bridgetown process.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.beta5
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-02 00:00:00.000000000 Z
11
+ date: 2023-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -274,20 +274,6 @@ dependencies:
274
274
  - - "~>"
275
275
  - !ruby/object:Gem::Version
276
276
  version: '1.0'
277
- - !ruby/object:Gem::Dependency
278
- name: terminal-table
279
- requirement: !ruby/object:Gem::Requirement
280
- requirements:
281
- - - "~>"
282
- - !ruby/object:Gem::Version
283
- version: '1.8'
284
- type: :runtime
285
- prerelease: false
286
- version_requirements: !ruby/object:Gem::Requirement
287
- requirements:
288
- - - "~>"
289
- - !ruby/object:Gem::Version
290
- version: '1.8'
291
277
  - !ruby/object:Gem::Dependency
292
278
  name: thor
293
279
  requirement: !ruby/object:Gem::Requirement
@@ -615,9 +601,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
615
601
  version: 2.7.0
616
602
  required_rubygems_version: !ruby/object:Gem::Requirement
617
603
  requirements:
618
- - - ">"
604
+ - - ">="
619
605
  - !ruby/object:Gem::Version
620
- version: 1.3.1
606
+ version: '0'
621
607
  requirements: []
622
608
  rubygems_version: 3.1.4
623
609
  signing_key: