bridgetown-core 1.0.0.alpha1 → 1.0.0.alpha2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +35 -0
  3. data/Rakefile +5 -5
  4. data/lib/bridgetown-core/cache.rb +3 -5
  5. data/lib/bridgetown-core/cleaner.rb +2 -2
  6. data/lib/bridgetown-core/collection.rb +4 -6
  7. data/lib/bridgetown-core/commands/base.rb +4 -3
  8. data/lib/bridgetown-core/commands/build.rb +20 -19
  9. data/lib/bridgetown-core/commands/concerns/actions.rb +2 -2
  10. data/lib/bridgetown-core/commands/console.rb +3 -3
  11. data/lib/bridgetown-core/commands/doctor.rb +10 -8
  12. data/lib/bridgetown-core/commands/new.rb +5 -3
  13. data/lib/bridgetown-core/commands/plugins.rb +7 -9
  14. data/lib/bridgetown-core/commands/serve/servlet.rb +4 -4
  15. data/lib/bridgetown-core/commands/serve.rb +25 -27
  16. data/lib/bridgetown-core/commands/webpack.rb +1 -1
  17. data/lib/bridgetown-core/component.rb +1 -5
  18. data/lib/bridgetown-core/concerns/site/configurable.rb +1 -1
  19. data/lib/bridgetown-core/concerns/site/content.rb +2 -2
  20. data/lib/bridgetown-core/concerns/site/extensible.rb +3 -4
  21. data/lib/bridgetown-core/concerns/site/localizable.rb +1 -1
  22. data/lib/bridgetown-core/concerns/site/ssr.rb +1 -1
  23. data/lib/bridgetown-core/concerns/site/writable.rb +1 -1
  24. data/lib/bridgetown-core/configuration.rb +1 -1
  25. data/lib/bridgetown-core/converter.rb +1 -0
  26. data/lib/bridgetown-core/converters/erb_templates.rb +1 -1
  27. data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +1 -1
  28. data/lib/bridgetown-core/converters/smartypants.rb +1 -0
  29. data/lib/bridgetown-core/drops/drop.rb +4 -4
  30. data/lib/bridgetown-core/entry_filter.rb +1 -0
  31. data/lib/bridgetown-core/filters/url_filters.rb +1 -1
  32. data/lib/bridgetown-core/filters.rb +11 -12
  33. data/lib/bridgetown-core/frontmatter_defaults.rb +5 -7
  34. data/lib/bridgetown-core/generated_page.rb +1 -3
  35. data/lib/bridgetown-core/generators/prototype_generator.rb +36 -37
  36. data/lib/bridgetown-core/helpers.rb +1 -1
  37. data/lib/bridgetown-core/hooks.rb +2 -2
  38. data/lib/bridgetown-core/liquid_renderer.rb +1 -3
  39. data/lib/bridgetown-core/log_adapter.rb +1 -1
  40. data/lib/bridgetown-core/log_writer.rb +1 -1
  41. data/lib/bridgetown-core/model/base.rb +2 -2
  42. data/lib/bridgetown-core/model/builder_origin.rb +1 -1
  43. data/lib/bridgetown-core/model/plugin_origin.rb +1 -1
  44. data/lib/bridgetown-core/plugin_manager.rb +2 -2
  45. data/lib/bridgetown-core/publisher.rb +1 -1
  46. data/lib/bridgetown-core/rack/routes.rb +1 -5
  47. data/lib/bridgetown-core/rack/static_indexes.rb +2 -2
  48. data/lib/bridgetown-core/readers/layout_reader.rb +2 -2
  49. data/lib/bridgetown-core/renderer.rb +1 -1
  50. data/lib/bridgetown-core/resource/base.rb +7 -7
  51. data/lib/bridgetown-core/resource/permalink_processor.rb +3 -2
  52. data/lib/bridgetown-core/resource/taxonomy_term.rb +1 -5
  53. data/lib/bridgetown-core/resource/transformer.rb +7 -5
  54. data/lib/bridgetown-core/ruby_template_view.rb +1 -3
  55. data/lib/bridgetown-core/static_file.rb +5 -7
  56. data/lib/bridgetown-core/tags/find.rb +6 -6
  57. data/lib/bridgetown-core/tags/highlight.rb +5 -5
  58. data/lib/bridgetown-core/tags/include.rb +22 -19
  59. data/lib/bridgetown-core/tags/post_url.rb +6 -6
  60. data/lib/bridgetown-core/tags/render_content.rb +2 -2
  61. data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +1 -1
  62. data/lib/bridgetown-core/url.rb +3 -3
  63. data/lib/bridgetown-core/utils.rb +7 -9
  64. data/lib/bridgetown-core/version.rb +1 -1
  65. data/lib/bridgetown-core/watcher.rb +2 -2
  66. data/lib/bridgetown-core.rb +2 -1
  67. metadata +2 -1
@@ -11,12 +11,7 @@ module Bridgetown
11
11
 
12
12
  def initialize(tag_name, markup, tokens)
13
13
  super
14
- if markup.strip =~ SYNTAX
15
- @new_var_name = Regexp.last_match(1).strip
16
- @single_or_group = Regexp.last_match(2)
17
- @arr_name = Regexp.last_match(3).strip
18
- @conditions = process_conditions(Regexp.last_match(4).strip)
19
- else
14
+ unless markup.strip =~ SYNTAX
20
15
  raise SyntaxError, <<~MSG
21
16
  Syntax Error in tag 'find' while parsing the following markup:
22
17
 
@@ -25,6 +20,11 @@ module Bridgetown
25
20
  Valid syntax: find <varname> where|in <array>, <condition(s)>
26
21
  MSG
27
22
  end
23
+
24
+ @new_var_name = Regexp.last_match(1).strip
25
+ @single_or_group = Regexp.last_match(2)
26
+ @arr_name = Regexp.last_match(3).strip
27
+ @conditions = process_conditions(Regexp.last_match(4).strip)
28
28
  end
29
29
 
30
30
  def render(context)
@@ -14,10 +14,7 @@ module Bridgetown
14
14
 
15
15
  def initialize(tag_name, markup, tokens)
16
16
  super
17
- if markup.strip =~ SYNTAX
18
- @lang = Regexp.last_match(1).downcase
19
- @highlight_options = parse_options(Regexp.last_match(2))
20
- else
17
+ unless markup.strip =~ SYNTAX
21
18
  raise SyntaxError, <<~MSG
22
19
  Syntax Error in tag 'highlight' while parsing the following markup:
23
20
 
@@ -26,6 +23,9 @@ module Bridgetown
26
23
  Valid syntax: highlight <lang> [linenos]
27
24
  MSG
28
25
  end
26
+
27
+ @lang = Regexp.last_match(1).downcase
28
+ @highlight_options = parse_options(Regexp.last_match(2))
29
29
  end
30
30
 
31
31
  LEADING_OR_TRAILING_LINE_TERMINATORS = %r!\A(\n|\r)+|(\n|\r)+\z!.freeze
@@ -89,7 +89,7 @@ module Bridgetown
89
89
  "data-lang=\"#{@lang}\"",
90
90
  ].join(" ")
91
91
  "<figure class=\"highlight\"><pre><code #{code_attributes}>"\
92
- "#{code.chomp}</code></pre></figure>"
92
+ "#{code.chomp}</code></pre></figure>"
93
93
  end
94
94
  end
95
95
  end
@@ -9,15 +9,18 @@ module Bridgetown
9
9
 
10
10
  VALID_SYNTAX = %r!
11
11
  ([\w-]+)\s*=\s*
12
- (?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+))
12
+ (?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w.-]+))
13
13
  !x.freeze
14
+
15
+ # rubocop:disable Lint/MixedRegexpCaptureTypes
14
16
  VARIABLE_SYNTAX = %r!
15
- (?<variable>[^{]*(\{\{\s*[\w\-\.]+\s*(\|.*)?\}\}[^\s{}]*)+)
17
+ (?<variable>[^{]*(\{\{\s*[\w\-.]+\s*(\|.*)?\}\}[^\s{}]*)+)
16
18
  (?<params>.*)
17
19
  !mx.freeze
20
+ # rubocop:enable Lint/MixedRegexpCaptureTypes
18
21
 
19
22
  FULL_VALID_SYNTAX = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z!.freeze
20
- VALID_FILENAME_CHARS = %r!^[\w/\.-]+$!.freeze
23
+ VALID_FILENAME_CHARS = %r!^[\w/.-]+$!.freeze
21
24
  INVALID_SEQUENCES = %r![./]{2,}!.freeze
22
25
 
23
26
  def initialize(tag_name, markup, tokens)
@@ -66,33 +69,33 @@ module Bridgetown
66
69
  end
67
70
 
68
71
  def validate_file_name(file)
69
- if INVALID_SEQUENCES.match?(file) || !VALID_FILENAME_CHARS.match?(file)
70
- raise ArgumentError, <<~MSG
71
- Invalid syntax for include tag. File contains invalid characters or sequences:
72
+ return unless INVALID_SEQUENCES.match?(file) || !VALID_FILENAME_CHARS.match?(file)
72
73
 
73
- #{file}
74
+ raise ArgumentError, <<~MSG
75
+ Invalid syntax for include tag. File contains invalid characters or sequences:
74
76
 
75
- Valid syntax:
77
+ #{file}
76
78
 
77
- #{syntax_example}
79
+ Valid syntax:
78
80
 
79
- MSG
80
- end
81
+ #{syntax_example}
82
+
83
+ MSG
81
84
  end
82
85
 
83
86
  def validate_params
84
- unless FULL_VALID_SYNTAX.match?(@params)
85
- raise ArgumentError, <<~MSG
86
- Invalid syntax for include tag:
87
+ return if FULL_VALID_SYNTAX.match?(@params)
87
88
 
88
- #{@params}
89
+ raise ArgumentError, <<~MSG
90
+ Invalid syntax for include tag:
89
91
 
90
- Valid syntax:
92
+ #{@params}
91
93
 
92
- #{syntax_example}
94
+ Valid syntax:
93
95
 
94
- MSG
95
- end
96
+ #{syntax_example}
97
+
98
+ MSG
96
99
  end
97
100
 
98
101
  # Grab file read opts in the context
@@ -74,19 +74,19 @@ module Bridgetown
74
74
 
75
75
  site.collections.posts.resources.each do |document|
76
76
  return relative_url(document) if @post == document
77
- end
78
-
79
- # New matching method did not match, fall back to old method
80
- # with deprecation warning if this matches
81
77
 
82
- site.collections.posts.resources.each do |document|
78
+ # New matching method did not match, fall back to old method
79
+ # with deprecation warning if this matches
83
80
  next unless @post.deprecated_equality document
84
81
 
85
- Bridgetown::Deprecator.deprecation_message "A call to "\
82
+ Bridgetown::Deprecator.deprecation_message(
83
+ "A call to "\
86
84
  "'{% post_url #{@post.name} %}' did not match " \
87
85
  "a post using the new matching method of checking name " \
88
86
  "(path-date-slug) equality. Please make sure that you " \
89
87
  "change this tag to match the post's name exactly."
88
+ )
89
+
90
90
  return relative_url(document)
91
91
  end
92
92
 
@@ -3,7 +3,7 @@
3
3
  module Bridgetown
4
4
  module Tags
5
5
  class BlockRenderTag < Liquid::Block
6
- # rubocop:disable Metrics/MethodLength
6
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
7
7
  def render(context)
8
8
  context.stack({}) do
9
9
  # unindent the incoming text
@@ -37,7 +37,7 @@ module Bridgetown
37
37
  .render_tag(context, +"")
38
38
  end
39
39
  end
40
- # rubocop:enable Metrics/MethodLength
40
+ # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
41
41
 
42
42
  private
43
43
 
@@ -23,7 +23,7 @@ end
23
23
 
24
24
  desc "Prerequisite task which loads site and provides automation"
25
25
  task :environment do
26
- class HammerActions < Thor
26
+ class HammerActions < Thor # rubocop:disable Lint/ConstantDefinitionInBlock
27
27
  include Thor::Actions
28
28
  include Bridgetown::Commands::Actions
29
29
 
@@ -28,9 +28,9 @@ module Bridgetown
28
28
  @placeholders = options[:placeholders] || {}
29
29
  @permalink = options[:permalink]
30
30
 
31
- if (@template || @permalink).nil?
32
- raise ArgumentError, "One of :template or :permalink must be supplied."
33
- end
31
+ return unless (@template || @permalink).nil?
32
+
33
+ raise ArgumentError, "One of :template or :permalink must be supplied."
34
34
  end
35
35
 
36
36
  # The generated relative URL of the resource
@@ -12,7 +12,7 @@ module Bridgetown
12
12
 
13
13
  # Constants for use in #slugify
14
14
  SLUGIFY_MODES = %w(raw default pretty simple ascii latin).freeze
15
- SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze
15
+ SLUGIFY_RAW_REGEXP = Regexp.new("\\s+").freeze
16
16
  SLUGIFY_DEFAULT_REGEXP = Regexp.new("[^\\p{M}\\p{L}\\p{Nd}]+").freeze
17
17
  SLUGIFY_PRETTY_REGEXP = Regexp.new("[^\\p{M}\\p{L}\\p{Nd}._~!$&'()+,;=@]+").freeze
18
18
  SLUGIFY_ASCII_REGEXP = Regexp.new("[^[A-Za-z0-9]]+").freeze
@@ -203,7 +203,7 @@ module Bridgetown
203
203
  slug = replace_character_sequence_with_hyphen(string, mode: mode)
204
204
 
205
205
  # Remove leading/trailing hyphen
206
- slug.gsub!(%r!^\-|\-$!i, "")
206
+ slug.gsub!(%r!^-|-$!i, "")
207
207
 
208
208
  slug.downcase! unless cased
209
209
 
@@ -316,9 +316,7 @@ module Bridgetown
316
316
  lines.map do |line|
317
317
  continue_processing = !skip_pre_lines
318
318
 
319
- if skip_pre_lines
320
- skip_pre_lines = false if line.include?("</pre>")
321
- end
319
+ skip_pre_lines = false if skip_pre_lines && line.include?("</pre>")
322
320
  if line.include?("<pre")
323
321
  skip_pre_lines = true
324
322
  continue_processing = false
@@ -340,7 +338,7 @@ module Bridgetown
340
338
  else
341
339
  line
342
340
  end
343
- end.join("")
341
+ end.join
344
342
  end
345
343
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
346
344
 
@@ -448,9 +446,9 @@ module Bridgetown
448
446
  end
449
447
 
450
448
  def merge_default_proc(target, overwrite)
451
- if target.is_a?(Hash) && overwrite.is_a?(Hash) && target.default_proc.nil?
452
- target.default_proc = overwrite.default_proc
453
- end
449
+ return unless target.is_a?(Hash) && overwrite.is_a?(Hash) && target.default_proc.nil?
450
+
451
+ target.default_proc = overwrite.default_proc
454
452
  end
455
453
 
456
454
  def duplicate_frozen_values(target)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "1.0.0.alpha1"
4
+ VERSION = "1.0.0.alpha2"
5
5
  CODE_NAME = "Pearl"
6
6
  end
@@ -116,7 +116,7 @@ module Bridgetown
116
116
  rescue ArgumentError
117
117
  # Could not find a relative path
118
118
  end
119
- end.compact + [%r!^\.bridgetown\-metadata!]
119
+ end.compact + [%r!^\.bridgetown-metadata!]
120
120
  end
121
121
 
122
122
  def sleep_forever
@@ -132,7 +132,7 @@ module Bridgetown
132
132
  site.plugin_manager.reload_component_loaders
133
133
  site.process
134
134
  Bridgetown.logger.info "Done! 🎉", "#{"Completed".green} in less than" \
135
- " #{(Time.now - time).ceil(2)} seconds."
135
+ " #{(Time.now - time).ceil(2)} seconds."
136
136
  rescue Exception => e
137
137
  Bridgetown.logger.error "Error:", e.message
138
138
 
@@ -249,12 +249,13 @@ end
249
249
 
250
250
  module Bridgetown
251
251
  module Model; end
252
+
252
253
  module Resource
253
254
  def self.register_extension(mod)
254
255
  if mod.const_defined?(:LiquidResource)
255
256
  Bridgetown::Drops::ResourceDrop.include mod.const_get(:LiquidResource)
256
257
  end
257
- if mod.const_defined?(:RubyResource)
258
+ if mod.const_defined?(:RubyResource) # rubocop:disable Style/GuardClause
258
259
  Bridgetown::Resource::Base.include mod.const_get(:RubyResource)
259
260
  end
260
261
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha1
4
+ version: 1.0.0.alpha2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
@@ -340,6 +340,7 @@ executables:
340
340
  extensions: []
341
341
  extra_rdoc_files: []
342
342
  files:
343
+ - ".rubocop.yml"
343
344
  - ".yardopts"
344
345
  - Rakefile
345
346
  - bin/bridgetown