sinatra-jekyll 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5245d51a80c4b6689f76e550c4e82beab44015ce
4
+ data.tar.gz: 837b2b12939a62f5af2b2f2cb999fd49127e24aa
5
+ SHA512:
6
+ metadata.gz: e705d5d3f7fea1135bfb03b42cb0f1eb365c0f392ce5170c9dfcdf35ba87cf45f5b886895b84a09b34b3b9432fa88ac380ecd261ebb65e1b88af3b33b97188f0
7
+ data.tar.gz: d7bef533d26ae4a4e293085508d07eaae850a7ec64204ac09146d28095353d746ad561411858a68ee6898651810b92f6f8869ee70b6620920bd6fd48b2e41d9c
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.1.8
5
+ - 2.2.4
6
+ - 2.3.0
7
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sinatra-jekyll.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Chris Mytton
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,71 @@
1
+ # Sinatra::Jekyll [![Build Status](https://travis-ci.org/theyworkforyou/sinatra-jekyll.svg?branch=master)](https://travis-ci.org/theyworkforyou/sinatra-jekyll)
2
+
3
+ Use Jekyll to render layouts in Sinatra.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'sinatra-jekyll'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install sinatra-jekyll
20
+
21
+ ## Usage
22
+
23
+ This module provides a single `render_into_jekyll_layout` method which renders the given content into a Jekyll site layout.
24
+
25
+ Using this extension in classic style Sinatra apps is as simple as requiring the extension, defining `jekyll_site_path` and using the `render_into_jekyll_layout` method:
26
+
27
+ ```ruby
28
+ require 'sinatra'
29
+ require 'sinatra/jekyll'
30
+
31
+ configure do
32
+ set :jekyll_site_path, './my_jekyll_site'
33
+ end
34
+
35
+ get '/' do
36
+ render_into_jekyll_layout '<p class="example">Hello world!</p>'
37
+ end
38
+ ```
39
+
40
+ Sinatra::Base subclasses need to require and register the module explicitly using the `register` method:
41
+
42
+ ```ruby
43
+ require 'sinatra/base'
44
+ require 'sinatra/jekyll'
45
+
46
+ class MyApp < Sinatra::Base
47
+ register Sinatra::JekyllExtension
48
+
49
+ configure do
50
+ set :jekyll_site_path, './my_jekyll_site'
51
+ end
52
+
53
+ get '/' do
54
+ render_into_jekyll_layout '<p class="example">Hello world!</p>'
55
+ end
56
+ end
57
+ ```
58
+
59
+ ## Development
60
+
61
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
62
+
63
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
64
+
65
+ ## Contributing
66
+
67
+ Bug reports and pull requests are welcome on GitHub at https://github.com/theyworkforyou/sinatra-jekyll.
68
+
69
+ ## License
70
+
71
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'sinatra/jekyll'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require 'pry'
10
+ Pry.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,66 @@
1
+ require 'sinatra/jekyll/version'
2
+ require 'sinatra/base'
3
+ require 'jekyll'
4
+
5
+ module Sinatra
6
+ module JekyllExtension
7
+ class Error < StandardError; end
8
+
9
+ module Helpers
10
+ def render_into_jekyll_layout(content, options = {})
11
+ page = Page.new(
12
+ jekyll_site,
13
+ jekyll_site.source,
14
+ 'sinatra',
15
+ 'index.html',
16
+ content,
17
+ options
18
+ )
19
+ Jekyll::Renderer.new(jekyll_site, page, jekyll_payload).run
20
+ end
21
+
22
+ def jekyll_payload
23
+ @jekyll_payload ||= jekyll_site.site_payload
24
+ end
25
+
26
+ def jekyll_site
27
+ settings.jekyll_site
28
+ end
29
+ end
30
+
31
+ class Page < Jekyll::Page
32
+ def initialize(site, base, dir, name, content, options = {})
33
+ @site = site
34
+ @base = base
35
+ @dir = dir
36
+ @name = name
37
+
38
+ process(name)
39
+ self.content = content
40
+ self.data = { 'layout' => 'default' }.merge(options)
41
+
42
+ data.default_proc = proc do |_, key|
43
+ site.frontmatter_defaults.find(File.join(dir, name), type, key)
44
+ end
45
+
46
+ Jekyll::Hooks.trigger :pages, :post_init, self
47
+ end
48
+ end
49
+
50
+ def jekyll_site
51
+ @jekyll_site ||= Jekyll::Site.new(Jekyll.configuration(source: jekyll_site_path)).tap do |s|
52
+ s.reset
53
+ s.read
54
+ end
55
+ end
56
+
57
+ def self.registered(app)
58
+ # Setup Jekyll and create a site object for rendering purposes
59
+ Jekyll::PluginManager.require_from_bundler
60
+ app.helpers Helpers
61
+ app.set :jekyll_site_path, ->{ raise Error, "Please set :jekyll_site_path to point to your Jekyll site source" }
62
+ end
63
+ end
64
+
65
+ register JekyllExtension
66
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ module Sinatra
3
+ module JekyllExtension
4
+ VERSION = '0.1.0'.freeze
5
+ end
6
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sinatra/jekyll/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'sinatra-jekyll'
8
+ spec.version = Sinatra::JekyllExtension::VERSION
9
+ spec.authors = ['Chris Mytton']
10
+ spec.email = ['chrismytton@gmail.com']
11
+
12
+ spec.summary = 'Use Jekyll layouts from Sinatra.'
13
+ spec.homepage = 'https://github.com/theyworkforyou/sinatra-jekyll'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'sinatra', '>= 1', '< 2'
22
+ spec.add_runtime_dependency 'jekyll', '>= 3', '< 4'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.11'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'minitest', '~> 5.0'
27
+ spec.add_development_dependency 'pry', '~> 0.10'
28
+ spec.add_development_dependency 'rack-test', '~> 0.6'
29
+ end
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra-jekyll
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Mytton
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-02-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2'
33
+ - !ruby/object:Gem::Dependency
34
+ name: jekyll
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '3'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '4'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '3'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '4'
53
+ - !ruby/object:Gem::Dependency
54
+ name: bundler
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '1.11'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '1.11'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rake
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '10.0'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '10.0'
81
+ - !ruby/object:Gem::Dependency
82
+ name: minitest
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '5.0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '5.0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: pry
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '0.10'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '0.10'
109
+ - !ruby/object:Gem::Dependency
110
+ name: rack-test
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '0.6'
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '0.6'
123
+ description:
124
+ email:
125
+ - chrismytton@gmail.com
126
+ executables: []
127
+ extensions: []
128
+ extra_rdoc_files: []
129
+ files:
130
+ - ".gitignore"
131
+ - ".travis.yml"
132
+ - Gemfile
133
+ - LICENSE.txt
134
+ - README.md
135
+ - Rakefile
136
+ - bin/console
137
+ - bin/setup
138
+ - lib/sinatra/jekyll.rb
139
+ - lib/sinatra/jekyll/version.rb
140
+ - sinatra-jekyll.gemspec
141
+ homepage: https://github.com/theyworkforyou/sinatra-jekyll
142
+ licenses:
143
+ - MIT
144
+ metadata: {}
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ requirements: []
160
+ rubyforge_project:
161
+ rubygems_version: 2.5.1
162
+ signing_key:
163
+ specification_version: 4
164
+ summary: Use Jekyll layouts from Sinatra.
165
+ test_files: []