sitepress-core 3.1.1 → 3.1.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: 6ad9a21fa1a354e2eabcb89204e9f1354ff2bb8ab7524bd7780eda5cded7128e
4
- data.tar.gz: 4f5cbc634f083cdde337df3e3eb18157d71ea4a6edf1d99268ccdbb360fc5312
3
+ metadata.gz: 12e94c474979815414339a9638d49b53dc95d62a2f9c5ff07b4bdec027adbacd
4
+ data.tar.gz: 01ad13713950b093bb163a3e5f092386c9ca9b5e37ce16b271cfb58f5ceca91c
5
5
  SHA512:
6
- metadata.gz: e5219d991f63759a404201a1dfd45ba83d50b68c3d5d8098a770eb17b7fb15b857b2507cb8a3257c376f74a9e30fe32118708f26a4e011880a1fcfc8a45916e5
7
- data.tar.gz: 10cbe5ea7ee97079bf58f987885026852fdfccd9472178f62165484382ca46ad5c40a93ec2cf015dc630e17ec6472eb7f4038e9a65ce2b4c39f5ef9575059977
6
+ metadata.gz: 602e0d16c5ea01e1ba567f00ed99f72609b17e536b9815d3d92ff45286f7f37f3f48215867dd8dab7667b4bab9e37a7a84324cb9f13f38ebd7d74fa6495a8df8
7
+ data.tar.gz: '029d87510096eda957801410bf6c237a072f62dbb35b6552a176c06dfbda10482e6b42d809e28f52031627dd1565235fd419b5ad1a990f588eedff7bf4f4594e'
@@ -1,6 +1,5 @@
1
1
  require "mime/types"
2
2
  require "forwardable"
3
- require "pathname"
4
3
 
5
4
  module Sitepress
6
5
  # Represents a file on a web server that may be parsed to extract
@@ -13,13 +12,17 @@ module Sitepress
13
12
  # the resource and figure out what to do with it.
14
13
  DEFAULT_MIME_TYPE = MIME::Types["application/octet-stream"].first
15
14
 
15
+ # Parsers can be swapped out to deal with different types of resources, like Notion
16
+ # documents, JSON, exif data on images, etc.
17
+ DEFAULT_PARSER = Parsers::Frontmatter
18
+
16
19
  attr_reader :path
17
20
 
18
21
  extend Forwardable
19
22
  def_delegators :parser, :data, :body
20
23
  def_delegators :path, :handler, :node_name, :format, :exists?
21
24
 
22
- def initialize(path:, mime_type: nil, parser: Parsers::Frontmatter)
25
+ def initialize(path:, mime_type: nil, parser: DEFAULT_PARSER)
23
26
  # The MIME::Types gem returns an array when types are looked up.
24
27
  # This grabs the first one, which is likely the intent on these lookups.
25
28
  @mime_type = Array(mime_type).first
@@ -1,3 +1,3 @@
1
1
  module Sitepress
2
- VERSION = "3.1.1".freeze
2
+ VERSION = "3.1.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitepress-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-05 00:00:00.000000000 Z
11
+ date: 2022-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,7 +80,6 @@ files:
80
80
  - lib/sitepress/extensions/layouts.rb
81
81
  - lib/sitepress/extensions/proc_manipulator.rb
82
82
  - lib/sitepress/formats.rb
83
- - lib/sitepress/frontmatter.rb
84
83
  - lib/sitepress/node.rb
85
84
  - lib/sitepress/parsers.rb
86
85
  - lib/sitepress/parsers/base.rb
@@ -1,23 +0,0 @@
1
- require "yaml"
2
-
3
- module Sitepress
4
- # Parses metadata from the header of the page.
5
-
6
- # TODO: Redo this to use File readline and pos to
7
- # perform faster
8
- class Parsers::Frontmatter
9
- DELIMITER = "---".freeze
10
- NEWLINE = /\r\n?|\n/.freeze
11
- PATTERN = /\A(#{DELIMITER}#{NEWLINE}(.+?)#{NEWLINE}#{DELIMITER}#{NEWLINE}*)?(.+)\Z/m
12
-
13
- attr_reader :body
14
-
15
- def initialize(content)
16
- _, @data, @body = content.match(PATTERN).captures
17
- end
18
-
19
- def data
20
- @data ? YAML.load(@data) : {}
21
- end
22
- end
23
- end