yaml-front-matter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +16 -0
- data/LICENSE +19 -0
- data/README.md +24 -0
- data/Rakefile +10 -0
- data/lib/yaml/front-matter.rb +17 -0
- data/yaml-front-matter.gemspec +20 -0
- metadata +63 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8d106a62bec3d77d43e3bdd521f38ccb61d39e3f
|
4
|
+
data.tar.gz: afec1c13fee767715358dd031562d1f95cdc62f6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f6b73fbe7e9973281ae09aaeab83b2347624bc5fe40648a23a3fcf757ec84606a1c30c69c423ddebe02158860ae1e4591b9c866fcda6699654eeb9341cdfd898
|
7
|
+
data.tar.gz: bd52d85a7ff1967e4591ed4e4a97165d98af4fa5288cb8d070cb19d16fe8783af643b00f9ca6d4f55917fa1174e8e7f36670c297c0d971a045b45c1e2ed596bf
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2015 Mattt Thompson (http://mattt.me/)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# YAML Front Matter
|
2
|
+
**Extract YAML Front Matter from Content**
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
|
6
|
+
```ruby
|
7
|
+
require 'yaml/front-matter'
|
8
|
+
|
9
|
+
content = <<-EOF
|
10
|
+
---
|
11
|
+
title: "Lorem Ipsum Dolor Sit Amet"
|
12
|
+
excerpt: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
|
13
|
+
published_at: "2015-03-29 12:00:00 -0700"
|
14
|
+
---
|
15
|
+
|
16
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
17
|
+
EOF
|
18
|
+
|
19
|
+
front_matter, content = YAML::FrontMatter.extract(content)
|
20
|
+
```
|
21
|
+
|
22
|
+
## License
|
23
|
+
|
24
|
+
YAML Front Matter is released under an MIT license. See LICENSE for more information.
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "bundler"
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
gemspec = eval(File.read("yaml-front-matter.gemspec"))
|
5
|
+
|
6
|
+
task :build => "#{gemspec.full_name}.gem"
|
7
|
+
|
8
|
+
file "#{gemspec.full_name}.gem" => gemspec.files + ["yaml-front-matter.gemspec"] do
|
9
|
+
system "gem build yaml-front-matter.gemspec"
|
10
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module YAML
|
4
|
+
module FrontMatter
|
5
|
+
PATTERN = /\A(---\r?\n(.*?)\n?^---\s*$\n?)/m
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def extract(content)
|
9
|
+
if content =~ PATTERN
|
10
|
+
return [YAML.load($2), content.sub($1, "")]
|
11
|
+
else
|
12
|
+
return [{}, content]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "yaml-front-matter"
|
6
|
+
s.authors = ["Mattt Thompson"]
|
7
|
+
s.email = "m@mattt.me"
|
8
|
+
s.homepage = "http://mattt.me"
|
9
|
+
s.version = '0.0.1'
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.summary = "YAML Front Matter"
|
12
|
+
s.description = "Extract YAML Front Matter from Content"
|
13
|
+
|
14
|
+
s.add_development_dependency "rake"
|
15
|
+
|
16
|
+
s.files = Dir["./**/*"].reject { |file| file =~ /\.\/(bin|log|pkg|script|spec|test|vendor)/ }
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yaml-front-matter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mattt Thompson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Extract YAML Front Matter from Content
|
28
|
+
email: m@mattt.me
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- ./Gemfile
|
34
|
+
- ./Gemfile.lock
|
35
|
+
- ./lib/yaml/front-matter.rb
|
36
|
+
- ./LICENSE
|
37
|
+
- ./Rakefile
|
38
|
+
- ./README.md
|
39
|
+
- ./yaml-front-matter.gemspec
|
40
|
+
homepage: http://mattt.me
|
41
|
+
licenses: []
|
42
|
+
metadata: {}
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 2.1.11
|
60
|
+
signing_key:
|
61
|
+
specification_version: 4
|
62
|
+
summary: YAML Front Matter
|
63
|
+
test_files: []
|