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 +4 -4
- data/lib/dimples/document.rb +5 -10
- data/lib/dimples/frontmatter.rb +18 -0
- data/lib/dimples/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3ea00fe31ee988acc15a95454594f0d63287ded91d987f0518dd4c3d92e63c4
|
4
|
+
data.tar.gz: d81b643d433efe3d6fdbd77c6150a936c53cc5f18c034c029aa03fb3b2ad3487
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f735e7a99b299949a0575f035153fe037fb9d05c987d2cec6d199814c55fdc076f5f20f6d6079d0ffb27a747c8c27b98207b706e3382a0fb24aab99a826a0da
|
7
|
+
data.tar.gz: '085264bed45ab98e9c932ba36e15136c06cf8d68fcde793761219fb662fb3f56f66e71bf1ae8d4dda45a99ac09a872c90f61091a2c55a7cb1273a842457a2c21'
|
data/lib/dimples/document.rb
CHANGED
@@ -1,22 +1,17 @@
|
|
1
|
-
|
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
|
-
|
17
|
-
|
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
|
data/lib/dimples/version.rb
CHANGED
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.
|
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
|