lv-jekyll-plugins 0.2.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 +7 -0
- data/.gitignore +23 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +68 -0
- data/Rakefile +2 -0
- data/lib/lv-jekyll-plugins.rb +4 -0
- data/lib/plugins/asset.rb +38 -0
- data/lib/plugins/common.rb +14 -0
- data/lib/plugins/download.rb +40 -0
- data/lib/plugins/preview.rb +45 -0
- data/lib/plugins/project.rb +17 -0
- data/lib/version.rb +5 -0
- data/lv-jekyll-plugins.gemspec +25 -0
- data/spec/plugins/asset_spec.rb +63 -0
- data/spec/plugins/download_spec.rb +62 -0
- data/spec/plugins/preview_spec.rb +96 -0
- data/spec/plugins/project_spec.rb +26 -0
- data/spec/spec_helper.rb +13 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8f5809794f8465003e32020daff9eb8f3fa7714a
|
4
|
+
data.tar.gz: f20d71eacdde5aef66645ec2b48b39a45793f9a6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0bce0815700972b6aaa90c27c307cc44a86853e4255bffc033844d7b6e9fe88ae2697a5d07b170b2c3c3fb2f1e42301f85f019ce20180e4410d55de541c9bfee
|
7
|
+
data.tar.gz: 07a0700d1de6f1cccd646c031417313a773da4f7d1adec0fc9e00eac45e35074d8c069f17117679f4c170823ef21fdf6764e6bffc9bdee8dd3ca81102bb39b03
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.DS_Store
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ryan LeFevre
|
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,68 @@
|
|
1
|
+
# LayerVault Jekyll Plugins
|
2
|
+
|
3
|
+
Plugins that add extra LayerVault-specfic functionality to our public pages.
|
4
|
+
|
5
|
+
## Available Plugins
|
6
|
+
|
7
|
+
All plugins return a URL. You must build the HTML element yourself.
|
8
|
+
|
9
|
+
### Assets
|
10
|
+
|
11
|
+
``` liquid
|
12
|
+
# Asset Group/Asset.png in latest revision of File.psd
|
13
|
+
{% lv_asset "File.psd" "Group/Asset.png" %}
|
14
|
+
{% lv_asset "File.psd" "-" "Group/Asset.png" %}
|
15
|
+
# => https://layervault.com/organization/project/File.psd/assets/Group/Asset.png?raw=1
|
16
|
+
|
17
|
+
# Asset Group/Asset.png in revision 12 of File.psd
|
18
|
+
{% lv_asset "File.psd" "12" "Group/Asset.png" %}
|
19
|
+
# => https://layervault.com/organization/project/File.psd/revisions/12/assets/Group/Asset.png?raw=1
|
20
|
+
```
|
21
|
+
|
22
|
+
### Previews
|
23
|
+
|
24
|
+
``` liquid
|
25
|
+
# First preview in latest revision of File.psd
|
26
|
+
{% lv_preview "File.psd" %}
|
27
|
+
# => https://layervault.com/organization/project/File.psd/previews/1?raw=1
|
28
|
+
|
29
|
+
# 2nd preview of latest revision of File.psd
|
30
|
+
{% lv_preview "File.psd" "-" "2" %}
|
31
|
+
# => https://layervault.com/organization/project/File.psd/previews/2?raw=1
|
32
|
+
|
33
|
+
# First preview of 2nd revision of File.psd
|
34
|
+
{% lv_preview "File.psd" "2" %}
|
35
|
+
# => https://layervault.com/organization/project/File.psd/revisions/2/previews/1?raw=1
|
36
|
+
|
37
|
+
# 2nd preview of 3rd revision of File.psd
|
38
|
+
{% lv_preview "File.psd" "3" "2" %}
|
39
|
+
# => https://layervault.com/organization/project/File.psd/revisions/3/previews/2?raw=1
|
40
|
+
```
|
41
|
+
|
42
|
+
### Project
|
43
|
+
|
44
|
+
``` liquid
|
45
|
+
{% lv_project %}
|
46
|
+
# => https://layervault.com/organization/project
|
47
|
+
```
|
48
|
+
|
49
|
+
### Download
|
50
|
+
|
51
|
+
``` liquid
|
52
|
+
# Latest revision of File.psd
|
53
|
+
{% lv_download "File.psd" %}
|
54
|
+
# => https://layervault.com/organization/project/File.psd?raw=1
|
55
|
+
|
56
|
+
# 2nd revision of File.psd
|
57
|
+
{% lv_download "File.psd" "2" %}
|
58
|
+
# => https://layervault.com/organization/project/File.psd/revisions/2?raw=1
|
59
|
+
```
|
60
|
+
|
61
|
+
## Self-Hosting
|
62
|
+
|
63
|
+
If you wish to use this plugin on your own self-hosted Jekyll site, the `_config.yml` must contain entries for your organization and a project:
|
64
|
+
|
65
|
+
``` yaml
|
66
|
+
organization: your-organization
|
67
|
+
project: your-project
|
68
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'liquid'
|
2
|
+
require 'plugins/common'
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
module LayerVault
|
6
|
+
class Asset < Liquid::Tag
|
7
|
+
include Common
|
8
|
+
|
9
|
+
def initialize(tag_name, text, tokens)
|
10
|
+
super
|
11
|
+
@text = text
|
12
|
+
end
|
13
|
+
|
14
|
+
def render(context)
|
15
|
+
return @text unless valid_parameters?
|
16
|
+
|
17
|
+
config = context.registers[:site].config
|
18
|
+
file, revision, asset = parse_parameters
|
19
|
+
|
20
|
+
url = File.join(URL_BASE, config['organization'], config['project'], file)
|
21
|
+
url = File.join(url, 'revisions', revision) unless revision.nil?
|
22
|
+
url = File.join(url, 'assets', asset)
|
23
|
+
url += "?raw=1"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def parse_parameters
|
29
|
+
@text.scan(PARAM_REGEX).
|
30
|
+
tap { |m| m.insert 1, [] if m.length == 2 }.
|
31
|
+
tap { |m| m[1] = [] if m[1][0] == '-' }.
|
32
|
+
map(&:first)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Liquid::Template.register_tag('lv_asset', Jekyll::LayerVault::Asset)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'liquid'
|
2
|
+
require 'plugins/common'
|
3
|
+
|
4
|
+
# {% lv_download "File.psd" %}
|
5
|
+
# {% lv_download "File.psd" "2" %}
|
6
|
+
|
7
|
+
module Jekyll
|
8
|
+
module LayerVault
|
9
|
+
class Download < Liquid::Tag
|
10
|
+
include Common
|
11
|
+
|
12
|
+
def initialize(tag_name, text, tokens)
|
13
|
+
super
|
14
|
+
@text = text
|
15
|
+
end
|
16
|
+
|
17
|
+
def render(context)
|
18
|
+
return @text unless valid_parameters?
|
19
|
+
|
20
|
+
config = context.registers[:site].config
|
21
|
+
file, revision = parse_parameters
|
22
|
+
|
23
|
+
url = File.join(URL_BASE, config['organization'], config['project'], file)
|
24
|
+
url = File.join(url, 'revisions', revision) unless revision.nil?
|
25
|
+
url += "?raw=1"
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def parse_parameters
|
31
|
+
@text.
|
32
|
+
scan(PARAM_REGEX).
|
33
|
+
flatten.
|
34
|
+
tap { |m| m[1] = nil if m[1] == '-' }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Liquid::Template.register_tag('lv_download', Jekyll::LayerVault::Download)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'liquid'
|
2
|
+
require 'plugins/common'
|
3
|
+
|
4
|
+
# {% lv_preview "File.psd" %}
|
5
|
+
# {% lv_preview "File.psd" "1" %}
|
6
|
+
# {% lv_preview "File.psd" "1" "2" %}
|
7
|
+
|
8
|
+
module Jekyll
|
9
|
+
module LayerVault
|
10
|
+
class Preview < Liquid::Tag
|
11
|
+
include Common
|
12
|
+
|
13
|
+
def initialize(tag_name, text, tokens)
|
14
|
+
super
|
15
|
+
@text = text
|
16
|
+
end
|
17
|
+
|
18
|
+
def render(context)
|
19
|
+
return @text unless valid_parameters?
|
20
|
+
|
21
|
+
config = context.registers[:site].config
|
22
|
+
file, revision, page = parse_parameters
|
23
|
+
|
24
|
+
url = File.join(URL_BASE, config['organization'], config['project'], file)
|
25
|
+
url = File.join(url, 'revisions', revision) unless revision.nil?
|
26
|
+
url = File.join(url, 'previews', page)
|
27
|
+
|
28
|
+
url += "?raw=1"
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def parse_parameters
|
34
|
+
@text.
|
35
|
+
scan(PARAM_REGEX).
|
36
|
+
flatten.
|
37
|
+
tap { |m| m.push nil if m.length == 1 }.
|
38
|
+
tap { |m| m.push '1' if m.length == 2 }.
|
39
|
+
tap { |m| m[1] = nil if m[1] == '-' }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
Liquid::Template.register_tag('lv_preview', Jekyll::LayerVault::Preview)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'liquid'
|
2
|
+
require 'plugins/common'
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
module LayerVault
|
6
|
+
class Project < Liquid::Tag
|
7
|
+
include Common
|
8
|
+
|
9
|
+
def render(context)
|
10
|
+
config = context.registers[:site].config
|
11
|
+
File.join(URL_BASE, config['organization'], config['project'])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
Liquid::Template.register_tag('lv_project', Jekyll::LayerVault::Project)
|
data/lib/version.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lv-jekyll-plugins"
|
8
|
+
spec.version = Jekyll::LayerVault::VERSION
|
9
|
+
spec.authors = ["Ryan LeFevre"]
|
10
|
+
spec.email = ["ryan@layervault.com"]
|
11
|
+
spec.summary = %q{Jekyll plugins for LayerVault public pages}
|
12
|
+
spec.homepage = ""
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency "liquid"
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rspec", "~> 2"
|
25
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
describe Jekyll::LayerVault::Asset do
|
2
|
+
let (:organization) { "layervault" }
|
3
|
+
let (:project) { "project" }
|
4
|
+
let (:file) { "folder/file.psd" }
|
5
|
+
let (:revision) { 2 }
|
6
|
+
let (:asset) { "Group/Asset.png" }
|
7
|
+
let (:jekyll_config) { Struct.new(:config) }
|
8
|
+
let (:template) { Liquid::Template.parse(source) }
|
9
|
+
let (:options) do
|
10
|
+
{
|
11
|
+
registers: {
|
12
|
+
site: jekyll_config.new({'organization' => organization, 'project' => project})
|
13
|
+
}
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
["\"", "'"].each do |q|
|
18
|
+
context "without revision number" do
|
19
|
+
let (:source) { "{% lv_asset #{q}#{file}#{q} #{q}#{asset}#{q} %}" }
|
20
|
+
let (:target) { "https://layervault.com/#{organization}/#{project}/#{file}/assets/#{asset}?raw=1" }
|
21
|
+
|
22
|
+
it "parses successfully" do
|
23
|
+
expect {
|
24
|
+
template.render nil, options
|
25
|
+
}.to_not raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
it "produces a valid URL" do
|
29
|
+
expect(template.render(nil, options)).to eq target
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "with revision number" do
|
34
|
+
let (:source) { "{% lv_asset #{q}#{file}#{q} #{q}#{revision}#{q} #{q}#{asset}#{q} %}" }
|
35
|
+
let (:target) { "https://layervault.com/#{organization}/#{project}/#{file}/revisions/#{revision}/assets/#{asset}?raw=1" }
|
36
|
+
|
37
|
+
it "parses successfully" do
|
38
|
+
expect {
|
39
|
+
template.render nil, options
|
40
|
+
}.to_not raise_error
|
41
|
+
end
|
42
|
+
|
43
|
+
it "produces a valid URL" do
|
44
|
+
expect(template.render(nil, options)).to eq target
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "with dash revision" do
|
49
|
+
let (:source) { "{% lv_asset #{q}#{file}#{q} #{q}-#{q} #{q}#{asset}#{q} %}" }
|
50
|
+
let (:target) { "https://layervault.com/#{organization}/#{project}/#{file}/assets/#{asset}?raw=1" }
|
51
|
+
|
52
|
+
it "parses successfully" do
|
53
|
+
expect {
|
54
|
+
template.render nil, options
|
55
|
+
}.to_not raise_error
|
56
|
+
end
|
57
|
+
|
58
|
+
it "produces a valid URL" do
|
59
|
+
expect(template.render(nil, options)).to eq target
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
describe Jekyll::LayerVault::Download do
|
2
|
+
let (:organization) { "layervault" }
|
3
|
+
let (:project) { "project" }
|
4
|
+
let (:file) { "folder/file.psd" }
|
5
|
+
let (:revision) { 2 }
|
6
|
+
let (:jekyll_config) { Struct.new(:config) }
|
7
|
+
let (:template) { Liquid::Template.parse(source) }
|
8
|
+
let (:options) do
|
9
|
+
{
|
10
|
+
registers: {
|
11
|
+
site: jekyll_config.new({'organization' => organization, 'project' => project})
|
12
|
+
}
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
["\"", "'"].each do |q|
|
17
|
+
context "without revision number" do
|
18
|
+
let (:source) { "{% lv_download #{q}#{file}#{q} %}" }
|
19
|
+
let (:target) { "https://layervault.com/#{organization}/#{project}/#{file}?raw=1" }
|
20
|
+
|
21
|
+
it "parses successfully" do
|
22
|
+
expect {
|
23
|
+
template.render nil, options
|
24
|
+
}.to_not raise_error
|
25
|
+
end
|
26
|
+
|
27
|
+
it "produces a valid URL" do
|
28
|
+
expect(template.render(nil, options)).to eq target
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "with revision number" do
|
33
|
+
let (:source) { "{% lv_download #{q}#{file}#{q} #{q}#{revision}#{q} %}" }
|
34
|
+
let (:target) { "https://layervault.com/#{organization}/#{project}/#{file}/revisions/#{revision}?raw=1" }
|
35
|
+
|
36
|
+
it "parses successfully" do
|
37
|
+
expect {
|
38
|
+
template.render nil, options
|
39
|
+
}.to_not raise_error
|
40
|
+
end
|
41
|
+
|
42
|
+
it "produces a valid URL" do
|
43
|
+
expect(template.render(nil, options)).to eq target
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "with dash revision" do
|
48
|
+
let (:source) { "{% lv_download #{q}#{file}#{q} #{q}-#{q} %}" }
|
49
|
+
let (:target) { "https://layervault.com/#{organization}/#{project}/#{file}?raw=1" }
|
50
|
+
|
51
|
+
it "parses successfully" do
|
52
|
+
expect {
|
53
|
+
template.render nil, options
|
54
|
+
}.to_not raise_error
|
55
|
+
end
|
56
|
+
|
57
|
+
it "produces a valid URL" do
|
58
|
+
expect(template.render(nil, options)).to eq target
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
describe Jekyll::LayerVault::Preview do
|
2
|
+
let (:organization) { "layervault" }
|
3
|
+
let (:project) { "project" }
|
4
|
+
let (:file) { "folder/file.psd" }
|
5
|
+
let (:revision) { 2 }
|
6
|
+
let (:preview) { 3 }
|
7
|
+
let (:jekyll_config) { Struct.new(:config) }
|
8
|
+
let (:template) { Liquid::Template.parse(source) }
|
9
|
+
let (:options) do
|
10
|
+
{
|
11
|
+
registers: {
|
12
|
+
site: jekyll_config.new({'organization' => organization, 'project' => project})
|
13
|
+
}
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
["\"", "'"].each do |q|
|
18
|
+
context "without revision number" do
|
19
|
+
let (:source) { "{% lv_preview #{q}#{file}#{q} %}" }
|
20
|
+
let (:target) { "https://layervault.com/#{organization}/#{project}/#{file}/previews/1?raw=1" }
|
21
|
+
|
22
|
+
it "parses successfully" do
|
23
|
+
expect {
|
24
|
+
template.render nil, options
|
25
|
+
}.to_not raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
it "produces a valid URL" do
|
29
|
+
expect(template.render(nil, options)).to eq target
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "with revision number" do
|
34
|
+
let (:source) { "{% lv_preview #{q}#{file}#{q} #{q}#{revision}#{q} %}" }
|
35
|
+
let (:target) { "https://layervault.com/#{organization}/#{project}/#{file}/revisions/#{revision}/previews/1?raw=1" }
|
36
|
+
|
37
|
+
it "parses successfully" do
|
38
|
+
expect {
|
39
|
+
template.render nil, options
|
40
|
+
}.to_not raise_error
|
41
|
+
end
|
42
|
+
|
43
|
+
it "produces a valid URL" do
|
44
|
+
expect(template.render(nil, options)).to eq target
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "with dash revision" do
|
49
|
+
let (:source) { "{% lv_preview #{q}#{file}#{q} #{q}-#{q} %}" }
|
50
|
+
let (:target) { "https://layervault.com/#{organization}/#{project}/#{file}/previews/1?raw=1" }
|
51
|
+
|
52
|
+
it "parses successfully" do
|
53
|
+
expect {
|
54
|
+
template.render nil, options
|
55
|
+
}.to_not raise_error
|
56
|
+
end
|
57
|
+
|
58
|
+
it "produces a valid URL" do
|
59
|
+
expect(template.render(nil, options)).to eq target
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "with page number" do
|
64
|
+
|
65
|
+
context "with dash revision" do
|
66
|
+
let (:source) { "{% lv_preview #{q}#{file}#{q} #{q}-#{q} #{q}#{preview}#{q} %}" }
|
67
|
+
let (:target) { "https://layervault.com/#{organization}/#{project}/#{file}/previews/#{preview}?raw=1" }
|
68
|
+
|
69
|
+
it "parses successfully" do
|
70
|
+
expect {
|
71
|
+
template.render nil, options
|
72
|
+
}.to_not raise_error
|
73
|
+
end
|
74
|
+
|
75
|
+
it "produces a valid URL" do
|
76
|
+
expect(template.render(nil, options)).to eq target
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "with revision number" do
|
81
|
+
let (:source) { "{% lv_preview #{q}#{file}#{q} #{q}#{revision}#{q} #{q}#{preview}#{q} %}" }
|
82
|
+
let (:target) { "https://layervault.com/#{organization}/#{project}/#{file}/revisions/#{revision}/previews/#{preview}?raw=1" }
|
83
|
+
|
84
|
+
it "parses successfully" do
|
85
|
+
expect {
|
86
|
+
template.render nil, options
|
87
|
+
}.to_not raise_error
|
88
|
+
end
|
89
|
+
|
90
|
+
it "produces a valid URL" do
|
91
|
+
expect(template.render(nil, options)).to eq target
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
describe Jekyll::LayerVault::Project do
|
2
|
+
let (:organization) { "layervault" }
|
3
|
+
let (:project) { "project" }
|
4
|
+
let (:jekyll_config) { Struct.new(:config) }
|
5
|
+
let (:template) { Liquid::Template.parse(source) }
|
6
|
+
let (:options) do
|
7
|
+
{
|
8
|
+
registers: {
|
9
|
+
site: jekyll_config.new({'organization' => organization, 'project' => project})
|
10
|
+
}
|
11
|
+
}
|
12
|
+
end
|
13
|
+
let (:source) { "{% lv_project %}" }
|
14
|
+
let (:template) { Liquid::Template.parse(source) }
|
15
|
+
let (:target) { "https://layervault.com/#{organization}/#{project}" }
|
16
|
+
|
17
|
+
it "parses successfully" do
|
18
|
+
expect {
|
19
|
+
template.render nil, options
|
20
|
+
}.to_not raise_error
|
21
|
+
end
|
22
|
+
|
23
|
+
it "produces a valid URL" do
|
24
|
+
expect(template.render(nil, options)).to eq target
|
25
|
+
end
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'lv-jekyll-plugins'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
5
|
+
config.run_all_when_everything_filtered = true
|
6
|
+
config.filter_run :focus
|
7
|
+
|
8
|
+
# Run specs in random order to surface order dependencies. If you find an
|
9
|
+
# order dependency and want to debug it, you can fix the order by providing
|
10
|
+
# the seed, which is printed after each run.
|
11
|
+
# --seed 1234
|
12
|
+
config.order = 'random'
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lv-jekyll-plugins
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan LeFevre
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: liquid
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- ryan@layervault.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/lv-jekyll-plugins.rb
|
83
|
+
- lib/plugins/asset.rb
|
84
|
+
- lib/plugins/common.rb
|
85
|
+
- lib/plugins/download.rb
|
86
|
+
- lib/plugins/preview.rb
|
87
|
+
- lib/plugins/project.rb
|
88
|
+
- lib/version.rb
|
89
|
+
- lv-jekyll-plugins.gemspec
|
90
|
+
- spec/plugins/asset_spec.rb
|
91
|
+
- spec/plugins/download_spec.rb
|
92
|
+
- spec/plugins/preview_spec.rb
|
93
|
+
- spec/plugins/project_spec.rb
|
94
|
+
- spec/spec_helper.rb
|
95
|
+
homepage: ''
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.2.2
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Jekyll plugins for LayerVault public pages
|
119
|
+
test_files:
|
120
|
+
- spec/plugins/asset_spec.rb
|
121
|
+
- spec/plugins/download_spec.rb
|
122
|
+
- spec/plugins/preview_spec.rb
|
123
|
+
- spec/plugins/project_spec.rb
|
124
|
+
- spec/spec_helper.rb
|