dimples 7.0.1 → 7.0.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: 4d875122c066481143980525752a32a86d661a4b9d5042db8ab124f316d46f0b
4
- data.tar.gz: ffa868119e0af8edfd87d5fa8a2e87d03f35e9e01e30c2751278848afa9b50e5
3
+ metadata.gz: d3ea00fe31ee988acc15a95454594f0d63287ded91d987f0518dd4c3d92e63c4
4
+ data.tar.gz: d81b643d433efe3d6fdbd77c6150a936c53cc5f18c034c029aa03fb3b2ad3487
5
5
  SHA512:
6
- metadata.gz: 29d0a8ccfd39cf3ba89b0d9a47ea099e902dca582c23aa1fe47c54a94888f421c2d8722375a3c0a626ac5fd38830a086bab8a2321d37171e5ec7c4e6d863c05d
7
- data.tar.gz: b4c18c20446327db58bdb7eacf4b01855d389dbf4c2b274cc3ddd96fbb3e11cc6d06e576c847b9f7fc92c7e8311efbf2cb4f08366f64bdc3e48ffad4835cb482
6
+ metadata.gz: 0f735e7a99b299949a0575f035153fe037fb9d05c987d2cec6d199814c55fdc076f5f20f6d6079d0ffb27a747c8c27b98207b706e3382a0fb24aab99a826a0da
7
+ data.tar.gz: '085264bed45ab98e9c932ba36e15136c06cf8d68fcde793761219fb662fb3f56f66e71bf1ae8d4dda45a99ac09a872c90f61091a2c55a7cb1273a842457a2c21'
@@ -1,22 +1,17 @@
1
- require 'yaml'
1
+ require_relative 'frontmatter'
2
2
 
3
3
  module Dimples
4
4
  class Document
5
- FRONT_MATTER_PATTERN = /^(-{3}\n.*?\n?)^(-{3}*$\n?)/m.freeze
6
-
7
5
  attr_accessor :metadata, :contents, :path, :rendered_contents
8
6
 
9
7
  def initialize(path = nil)
10
8
  @path = path
11
- @metadata = {}
12
9
 
13
10
  if @path
14
- @contents = File.read(path)
15
-
16
- if matches = contents.match(FRONT_MATTER_PATTERN)
17
- @metadata = YAML.load(matches[1], symbolize_names: true)
18
- @contents = matches.post_match.strip
19
- end
11
+ @metadata, @contents = Dimples::FrontMatter.parse(File.read(path))
12
+ else
13
+ @metadata = {}
14
+ @contents = ''
20
15
  end
21
16
  end
22
17
 
@@ -0,0 +1,18 @@
1
+ require 'yaml'
2
+
3
+ module Dimples
4
+ module FrontMatter
5
+ PATTERN = /^(-{3}\n.*?\n?)^(-{3}*$\n?)/m.freeze
6
+
7
+ def self.parse(contents)
8
+ metadata = {}
9
+
10
+ if matches = contents.match(PATTERN)
11
+ metadata = YAML.load(matches[1], symbolize_names: true)
12
+ contents = matches.post_match.strip
13
+ end
14
+
15
+ [metadata, contents]
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- VERSION = '7.0.1'
4
+ VERSION = '7.0.2'
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: 7.0.1
4
+ version: 7.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bogan
@@ -91,6 +91,7 @@ files:
91
91
  - bin/dimples
92
92
  - lib/dimples.rb
93
93
  - lib/dimples/document.rb
94
+ - lib/dimples/frontmatter.rb
94
95
  - lib/dimples/page.rb
95
96
  - lib/dimples/pager.rb
96
97
  - lib/dimples/post.rb