dimples 6.2.4 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0ea0c6cc23d5e09079f09828f159d8cda5e0de7
4
- data.tar.gz: 7fc9338112314af6481c33eb21237a51443c4893
3
+ metadata.gz: 4b448da242a2f100c9494e264a5db74cd4776788
4
+ data.tar.gz: 63d845f81419f62019d05cd982b03ddb51ec58d1
5
5
  SHA512:
6
- metadata.gz: e5fe5e465843b2a68cd2d2e814cfa1021f369bbf6b9a0ad54f040018dfad87470f6d68725a2e1e8acf87c098b7fc4334f01fb7cba66591c0e32eb8f8c59d712f
7
- data.tar.gz: aae17af68dbe6069021d9b50c380fafdbea2a071deeec780d93d166604af386e620e674b6961be28b561b014f858da5ebc146e8605e29659b414c030cb6c5eaa
6
+ metadata.gz: 42bb20b085f8a65ccc5c0f5d9603d1bdc8d4acea4f668483c7378f9ef4980ce7cb772f80eade7c402999dfd7bc1a4256f8e74bf2435acd2053c95a6fa39676cf
7
+ data.tar.gz: 2d1cb6681366972afd89b229eaa47f835323a9831fa282cce151ac445d442186193fb41ebf7037745f336f79d8f669a28cc15453ed20623dbd87708429c80510
@@ -7,12 +7,11 @@ require 'hashie'
7
7
  require 'tilt'
8
8
  require 'yaml'
9
9
 
10
- require 'dimples/frontable'
11
-
12
10
  require 'dimples/archive'
13
11
  require 'dimples/category'
14
12
  require 'dimples/configuration'
15
13
  require 'dimples/errors'
14
+ require 'dimples/frontmatter'
16
15
  require 'dimples/pager'
17
16
  require 'dimples/renderer'
18
17
 
@@ -1,13 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- # Adds the ability to read frontmatter from a file.
5
- module Frontable
4
+ # Adds the ability to parse front matter from a file.
5
+ class FrontMatter
6
6
  FRONT_MATTER_PATTERN = /^(-{3}\n.*?\n?)^(-{3}*$\n?)/m.freeze
7
7
 
8
- def read_with_front_matter(path)
9
- contents = File.read(path)
10
-
8
+ def self.parse(contents)
11
9
  if (matches = contents.match(FRONT_MATTER_PATTERN))
12
10
  metadata = Hashie.symbolize_keys(YAML.safe_load(matches[1]))
13
11
  contents = matches.post_match.strip
@@ -3,8 +3,6 @@
3
3
  module Dimples
4
4
  # A single page on a site.
5
5
  class Page
6
- include Frontable
7
-
8
6
  attr_accessor :contents
9
7
  attr_accessor :metadata
10
8
  attr_accessor :path
@@ -14,7 +12,8 @@ module Dimples
14
12
  @path = path
15
13
 
16
14
  if @path
17
- @contents, @metadata = read_with_front_matter(@path)
15
+ data = File.read(@path)
16
+ @contents, @metadata = FrontMatter.parse(data)
18
17
  else
19
18
  @contents = ''
20
19
  @metadata = {}
@@ -3,8 +3,6 @@
3
3
  module Dimples
4
4
  # A single template used when rendering pages, posts and other templates.
5
5
  class Template
6
- include Frontable
7
-
8
6
  attr_accessor :path
9
7
  attr_accessor :contents
10
8
  attr_accessor :metadata
@@ -12,7 +10,9 @@ module Dimples
12
10
  def initialize(site, path)
13
11
  @site = site
14
12
  @path = path
15
- @contents, @metadata = read_with_front_matter(path)
13
+
14
+ data = File.read(path)
15
+ @contents, @metadata = FrontMatter.parse(data)
16
16
  end
17
17
 
18
18
  def render(context = {}, body = nil)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- VERSION = '6.2.4'
4
+ VERSION = '6.3.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dimples
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.4
4
+ version: 6.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bogan
@@ -183,7 +183,7 @@ files:
183
183
  - lib/dimples/configuration.rb
184
184
  - lib/dimples/errors.rb
185
185
  - lib/dimples/feed.rb
186
- - lib/dimples/frontable.rb
186
+ - lib/dimples/frontmatter.rb
187
187
  - lib/dimples/page.rb
188
188
  - lib/dimples/pager.rb
189
189
  - lib/dimples/post.rb