front-matter 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -3
- data/lib/front_matter.rb +6 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6208f7995bb901ffe4a941e3b097844779d7d1da
|
4
|
+
data.tar.gz: 45c54c2850af9382dd138d8ada7a4fb1ffaee6ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aeb5a98fe8c53237e89bc8c290435b783e340645002c8fc0e3637cb42f4d8ab74bca4965d73769ae187298398693570c4a27fcafdc1adca7c3aa2bc6860e0310
|
7
|
+
data.tar.gz: 9229878cf7449ed1cdf2674c2cda34ea77633546f8d31ef13e84c48f88a197b21cdc8802dbde9c996c13559a44d6c71c25c5558aca0a5a428fed1a1a0dba5340
|
data/README.md
CHANGED
@@ -53,14 +53,13 @@ require "yaml"
|
|
53
53
|
fm = FrontMatter.new(:unindent => true, :as_yaml => true)
|
54
54
|
file = "README.md"
|
55
55
|
|
56
|
-
|
57
|
-
ap YAML.load(
|
56
|
+
front_matters = fm.extract_file(file)
|
57
|
+
ap YAML.load(front_matters[0])
|
58
58
|
|
59
59
|
# {
|
60
60
|
# "Gem" => "front_matter",
|
61
61
|
# "Author" => "Zhao Cai",
|
62
62
|
# "Email" => "caizhaoff@gmail.com",
|
63
|
-
# "Homepage" => "https://github.com/zhaocai/",
|
64
63
|
# "Tag" => [
|
65
64
|
# "ruby",
|
66
65
|
# "yaml",
|
data/lib/front_matter.rb
CHANGED
@@ -15,7 +15,7 @@ require 'facets/string'
|
|
15
15
|
require 'front_matter/core/array'
|
16
16
|
|
17
17
|
class FrontMatter
|
18
|
-
VERSION = '1.2.
|
18
|
+
VERSION = '1.2.1'
|
19
19
|
attr_accessor :setting
|
20
20
|
def initialize( opts={} )
|
21
21
|
comment_marker = %r{(?<comment> ^\s* \W{1,2} )}x
|
@@ -71,7 +71,7 @@ class FrontMatter
|
|
71
71
|
if opts[:firstline] || opts[:lastline]
|
72
72
|
firstline = opts[:firstline] ? opts[:firstline] - 1 : 0
|
73
73
|
lastline = opts[:lastline] ? opts[:lastline] -1 : -1
|
74
|
-
return extract(File.readlines(path)[firstline..lastline].join
|
74
|
+
return extract(File.readlines(path)[firstline..lastline].join, filetype)
|
75
75
|
else
|
76
76
|
return extract(File.read(path), filetype)
|
77
77
|
end
|
@@ -81,4 +81,7 @@ class FrontMatter
|
|
81
81
|
end
|
82
82
|
|
83
83
|
|
84
|
-
|
84
|
+
if __FILE__ == $0
|
85
|
+
fm = FrontMatter.new(:unindent => true, :as_yaml => true)
|
86
|
+
puts fm.extract_file(__FILE__, :firstline => 1, :lastline => 15)
|
87
|
+
end
|