nesta-plugin-jekyll-metadata 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b3a7f78f8ecf7a6f4967af0451991640dfeff46a
4
+ data.tar.gz: 9bf312b0df9c168e849ce3a05e870ceb40f8a85c
5
+ SHA512:
6
+ metadata.gz: 7ed609c54d19431623d135ee5db72e4601f21227efc816f321a43336f4e05501c47c47cd45e30657c9bbb312473955cb9a71ba470df50d2cf83e30d4913b86f8
7
+ data.tar.gz: 17f6d40620126b20ccfed2366ecb885113226ae2f31a80bc47913952048c43291e98ebbc23b352ce1752e25f21488b4636036322bf50b989237035654dea0c0c
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .ruby-version
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nesta-plugin-jekyll-metadata.gemspec
4
+ gemspec
5
+
6
+ gem 'byebug'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Braden
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Nesta::Plugin::Jekyll::Metadata
2
+
3
+ Plugin for the great [Nesta CMS][1] which makes moving from Jekyll to Nesta
4
+ an absolute breeze. Nesta's expected frontmatter does not include the [dashes that Jekyll does][3].
5
+ In addition, many writing platforms for the web like [Prose.io][2] format
6
+ their data in the same fashion as Jekyll. This formatter will ignore all dashes at the
7
+ beginning and end of the first paragraph (where the metadata belongs) and processes everything
8
+ inbetween.
9
+
10
+ Requires Nesta 0.9.12 or greater
11
+
12
+ ##Build Status
13
+
14
+ [![wercker status](https://app.wercker.com/status/fba96ed2fa7d97805b7ee8fd15f91acc/m "wercker status")](https://app.wercker.com/project/bykey/fba96ed2fa7d97805b7ee8fd15f91acc)
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'nesta-plugin-jekyll-metadata'
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install nesta-plugin-jekyll-metadata
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it ( https://github.com/[my-github-username]/nesta-plugin-jekyll-metadata/fork )
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create a new Pull Request
39
+
40
+ [1]: http://nestacms.com/
41
+ [2]: http://prose.io/#about
42
+ [3]: http://jekyllrb.com/docs/frontmatter/
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,11 @@
1
+ require "nesta/plugin/jekyll/metadata/version"
2
+
3
+ module Nesta
4
+ module Plugin
5
+ module Jekyll
6
+ module Metadata
7
+ VERSION = '0.0.1'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ module Nesta
2
+ class FileModel
3
+ def parse_metadata(first_paragraph)
4
+ is_metadata = first_paragraph.split("\n").first =~ /-$/ ||
5
+ first_paragraph.split("\n").first =~ /^[\w ]+:/
6
+ raise Nesta::MetadataParseError unless is_metadata
7
+ CaseInsensitiveHash.new.tap do |data|
8
+ first_paragraph.split("\n").each do |line|
9
+ next if line =~ /-$/
10
+ key, val = line.split(/\s*:\s*/, 2)
11
+ next if val.nil?
12
+ data[key.downcase.strip] = val.chomp
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ module Nesta
2
+ module Plugin
3
+ module Jekyll
4
+ module Metadata
5
+ VERSION = "0.0.1"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nesta/plugin/jekyll/metadata/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nesta-plugin-jekyll-metadata"
8
+ spec.version = Nesta::Plugin::Jekyll::Metadata::VERSION
9
+ spec.authors = ["Braden"]
10
+ spec.email = ["me@braidn.com"]
11
+ spec.homepage = ""
12
+ spec.summary = %q{Allow Author To Use Jekyll Style Frontmatter/Metadata}
13
+ spec.description = <<-DES
14
+ Plugin for using blog posts written for Jekyll or with a Jekyll style editor
15
+ where the frontmatter is a little different from what is expected in Nesta.
16
+ This style of frontmatter is encapsulated with dashes at both the first and
17
+ last line. This plugin will allow a writer to simply move their content over
18
+ to Nesta without having to modify each post.
19
+ DES
20
+
21
+ spec.files = `git ls-files -z`.split("\x0")
22
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_dependency "nesta", ">= 0.9.12"
28
+ end
@@ -0,0 +1,71 @@
1
+ require 'minitest/autorun'
2
+ require 'fileutils'
3
+ require 'tilt'
4
+ require 'nesta/models'
5
+
6
+ require_relative '../lib/nesta/plugin/jekyll/metadata/init'
7
+
8
+ describe Nesta::FileModel do
9
+
10
+ before do
11
+ build_jekyll_data
12
+ build_normal_data
13
+ end
14
+
15
+ after do
16
+ FileUtils.rm(fixture) if File.exists?(fixture)
17
+ FileUtils.rm(fixture('jekyll')) if File.exists?(fixture('jekyll'))
18
+ end
19
+
20
+ describe 'with Jekyll metadata' do
21
+ subject { Nesta::Page.new(fixture('jekyll')) }
22
+
23
+ it 'will parse metadata ignoring --(dashes)' do
24
+ subject.title.must_include 'take one down'
25
+ subject.summary.must_include 'oh yeah'
26
+ end
27
+ end
28
+
29
+ describe 'with Normal metadata' do
30
+ subject { Nesta::Page.new(fixture) }
31
+
32
+ it 'will parse metadata if there are no dashes' do
33
+ subject.title.must_include 'take one down'
34
+ subject.summary.must_include 'oh yeah'
35
+ end
36
+ end
37
+
38
+ def build_jekyll_data
39
+ generate_fixture(fixture('jekyll')) do
40
+ <<-DATA
41
+ -------
42
+ link text: take one down
43
+ date: Monday, October 13, 2014
44
+ summary: oh yeah
45
+ -------
46
+
47
+ more to come...
48
+ DATA
49
+ end
50
+ end
51
+
52
+ def build_normal_data
53
+ generate_fixture(fixture) do
54
+ <<-DATA
55
+ link text: take one down
56
+ date: Monday, October 13, 2014
57
+ summary: oh yeah
58
+
59
+ more to come...
60
+ DATA
61
+ end
62
+ end
63
+
64
+ def fixture(type='normal')
65
+ File.join(File.dirname(__FILE__), "test-#{type}.mdown")
66
+ end
67
+
68
+ def generate_fixture(filename)
69
+ File.open(filename, 'w') { |f| f.write yield }
70
+ end
71
+ end
data/wercker.yml ADDED
@@ -0,0 +1,26 @@
1
+ box: wercker/rvm
2
+ # Build definition
3
+ build:
4
+ # The steps that will be executed on build
5
+ # See the Ruby section on the wercker devcenter:
6
+ # http://devcenter.wercker.com/articles/languages/ruby.html
7
+ steps:
8
+ # Uncomment this to force RVM to use a specific Ruby version
9
+ # - rvm-use:
10
+ # version: 2.1.3
11
+
12
+ # A step that executes `bundle install` command
13
+ - bundle-install
14
+
15
+ # A custom script step, name value is used in the UI
16
+ # and the code value contains the command that get executed
17
+ - script:
18
+ name: echo ruby information
19
+ code: |
20
+ echo "ruby version $(ruby --version) running"
21
+ echo "from location $(which ruby)"
22
+ echo -p "gem list: $(gem list)"
23
+
24
+ - script:
25
+ name: minitest
26
+ code: bundle exec ruby test/plugin_test.rb
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nesta-plugin-jekyll-metadata
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Braden
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-21 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: '10.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '10.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nesta
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.12
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.12
41
+ description: |2
42
+ Plugin for using blog posts written for Jekyll or with a Jekyll style editor
43
+ where the frontmatter is a little different from what is expected in Nesta.
44
+ This style of frontmatter is encapsulated with dashes at both the first and
45
+ last line. This plugin will allow a writer to simply move their content over
46
+ to Nesta without having to modify each post.
47
+ email:
48
+ - me@braidn.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - lib/nesta/plugin/jekyll/metadata.rb
59
+ - lib/nesta/plugin/jekyll/metadata/init.rb
60
+ - lib/nesta/plugin/jekyll/metadata/version.rb
61
+ - nesta-plugin-jekyll-metadata.gemspec
62
+ - test/plugin_test.rb
63
+ - wercker.yml
64
+ homepage: ''
65
+ licenses: []
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.0.14
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Allow Author To Use Jekyll Style Frontmatter/Metadata
87
+ test_files:
88
+ - test/plugin_test.rb