nanoc-erector 1.0.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.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +70 -0
- data/LICENSE +19 -0
- data/NEWS.md +5 -0
- data/README.md +21 -0
- data/Rakefile +10 -0
- data/lib/nanoc-erector.rb +3 -0
- data/lib/nanoc/erector.rb +9 -0
- data/lib/nanoc/erector/filter.rb +39 -0
- data/lib/nanoc/erector/version.rb +9 -0
- data/nanoc-erector.gemspec +30 -0
- data/test/filters/test_erector.rb +68 -0
- data/test/helper.rb +9 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 177e6ac755dbfe28c093c5a8ee7fcfac8ef22ef9
|
4
|
+
data.tar.gz: 618fe881e67523ee36727e6cf0c84959f18dad8f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80ee9560e51438824fb34918d37ec85199598ef0ab17701865ba236468fe9281ab77e0783cb0529bce67f1bfbaf02414f198dfc0f96d28d35e0a1206db7c38a2
|
7
|
+
data.tar.gz: a43d791968dc76f76235cc3dc8639ab9ea296bb00d20a0bbc46ee51a870e5ee0c9e79588527e5476928a9578db4ef8a95f996a9c56132d004411e696566d4d32
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/nanoc/nanoc.git
|
3
|
+
revision: bf13d9cc634faba39ceeaaa87b9ad6a9b2d45830
|
4
|
+
specs:
|
5
|
+
nanoc (4.0.0rc3)
|
6
|
+
cri (~> 2.3)
|
7
|
+
|
8
|
+
PATH
|
9
|
+
remote: .
|
10
|
+
specs:
|
11
|
+
nanoc-erector (1.0.0)
|
12
|
+
erector (~> 0.9)
|
13
|
+
|
14
|
+
GEM
|
15
|
+
remote: https://rubygems.org/
|
16
|
+
specs:
|
17
|
+
colored (1.2)
|
18
|
+
coveralls (0.8.3)
|
19
|
+
json (~> 1.8)
|
20
|
+
rest-client (>= 1.6.8, < 2)
|
21
|
+
simplecov (~> 0.10.0)
|
22
|
+
term-ansicolor (~> 1.3)
|
23
|
+
thor (~> 0.19.1)
|
24
|
+
cri (2.7.0)
|
25
|
+
colored (~> 1.2)
|
26
|
+
docile (1.1.5)
|
27
|
+
domain_name (0.5.25)
|
28
|
+
unf (>= 0.0.5, < 1.0.0)
|
29
|
+
erector (0.10.0)
|
30
|
+
treetop (>= 1.2.3)
|
31
|
+
http-cookie (1.0.2)
|
32
|
+
domain_name (~> 0.5)
|
33
|
+
json (1.8.3)
|
34
|
+
mime-types (2.6.2)
|
35
|
+
minitest (5.8.2)
|
36
|
+
netrc (0.11.0)
|
37
|
+
polyglot (0.3.5)
|
38
|
+
rake (10.4.2)
|
39
|
+
rest-client (1.8.0)
|
40
|
+
http-cookie (>= 1.0.2, < 2.0)
|
41
|
+
mime-types (>= 1.16, < 3.0)
|
42
|
+
netrc (~> 0.7)
|
43
|
+
simplecov (0.10.0)
|
44
|
+
docile (~> 1.1.0)
|
45
|
+
json (~> 1.8)
|
46
|
+
simplecov-html (~> 0.10.0)
|
47
|
+
simplecov-html (0.10.0)
|
48
|
+
term-ansicolor (1.3.2)
|
49
|
+
tins (~> 1.0)
|
50
|
+
thor (0.19.1)
|
51
|
+
tins (1.6.0)
|
52
|
+
treetop (1.6.3)
|
53
|
+
polyglot (~> 0.3)
|
54
|
+
unf (0.1.4)
|
55
|
+
unf_ext
|
56
|
+
unf_ext (0.0.7.1)
|
57
|
+
|
58
|
+
PLATFORMS
|
59
|
+
ruby
|
60
|
+
|
61
|
+
DEPENDENCIES
|
62
|
+
bundler (~> 1.5)
|
63
|
+
coveralls
|
64
|
+
minitest
|
65
|
+
nanoc!
|
66
|
+
nanoc-erector!
|
67
|
+
rake
|
68
|
+
|
69
|
+
BUNDLED WITH
|
70
|
+
1.10.6
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2014 Denis Defreyne and contributors
|
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 all
|
11
|
+
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 THE
|
19
|
+
SOFTWARE.
|
data/NEWS.md
ADDED
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
[](https://travis-ci.org/nanoc/nanoc-erector)
|
2
|
+
[](https://codeclimate.com/github/nanoc/nanoc-erector)
|
3
|
+
[](https://coveralls.io/r/nanoc/nanoc-erector)
|
4
|
+
|
5
|
+
# nanoc-erector
|
6
|
+
|
7
|
+
This provides a filter for [Erector](http://erector.rubyforge.org/).
|
8
|
+
|
9
|
+
Works with nanoc 3.x.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
`gem install nanoc-erector`
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
filter :erector
|
19
|
+
```
|
20
|
+
|
21
|
+
Options passed to this filter will be passed on to `Erector.render`.
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'erector'
|
4
|
+
|
5
|
+
module Nanoc::Erector
|
6
|
+
|
7
|
+
class Filter < Nanoc::Filter
|
8
|
+
|
9
|
+
class OutsideLayoutError < ::StandardError
|
10
|
+
|
11
|
+
def message
|
12
|
+
'The erector filter can only be used as a layout filter.'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
identifier :erector
|
18
|
+
|
19
|
+
def run(content, params={})
|
20
|
+
if @assigns[:layout].nil?
|
21
|
+
raise OutsideLayoutError
|
22
|
+
end
|
23
|
+
|
24
|
+
class_name = params.fetch(:class, 'ErectorTemplate').to_sym
|
25
|
+
options = params.fetch(:erector, {})
|
26
|
+
|
27
|
+
begin
|
28
|
+
klass = Object.const_get(class_name)
|
29
|
+
Object.send(:remove_const, class_name)
|
30
|
+
rescue NameError
|
31
|
+
end
|
32
|
+
|
33
|
+
eval(@assigns[:layout].content.string, TOPLEVEL_BINDING, filename)
|
34
|
+
Object.const_get(class_name).new(assigns).to_html(options)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.expand_path('../lib/', __FILE__))
|
4
|
+
require 'nanoc/erector/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'nanoc-erector'
|
8
|
+
s.version = Nanoc::Erector::VERSION
|
9
|
+
s.homepage = 'http://nanoc.ws/'
|
10
|
+
s.summary = 'Erector filter for nanoc'
|
11
|
+
s.description = 'Provides an :erector filter for nanoc'
|
12
|
+
|
13
|
+
s.author = 'Denis Defreyne'
|
14
|
+
s.email = 'denis.defreyne@stoneship.org'
|
15
|
+
s.license = 'MIT'
|
16
|
+
|
17
|
+
s.required_ruby_version = '>= 1.9.3'
|
18
|
+
|
19
|
+
s.files = Dir['[A-Z]*'] +
|
20
|
+
Dir['{lib,test}/**/*'] +
|
21
|
+
[ 'nanoc-erector.gemspec' ]
|
22
|
+
s.require_paths = [ 'lib' ]
|
23
|
+
|
24
|
+
s.rdoc_options = [ '--main', 'README.md' ]
|
25
|
+
s.extra_rdoc_files = [ 'LICENSE', 'README.md', 'NEWS.md' ]
|
26
|
+
|
27
|
+
s.add_runtime_dependency('nanoc', '~> 4.0')
|
28
|
+
s.add_runtime_dependency('erector', '~> 0.9')
|
29
|
+
s.add_development_dependency('bundler', '~> 1.5')
|
30
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'helper'
|
4
|
+
|
5
|
+
class Nanoc::Erector::FilterTest < Minitest::Test
|
6
|
+
|
7
|
+
TEMPLATE = <<-EOF
|
8
|
+
class ErectorTemplate < Erector::Widget
|
9
|
+
def content
|
10
|
+
html {
|
11
|
+
head {
|
12
|
+
title "My Page"
|
13
|
+
}
|
14
|
+
body {
|
15
|
+
h1 "Hi, \#{@content}!"
|
16
|
+
}
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
EOF
|
21
|
+
|
22
|
+
def test_filter
|
23
|
+
# Create filter
|
24
|
+
layout = Nanoc::Int::Layout.new(TEMPLATE, {}, '/default/')
|
25
|
+
assigns = { :layout => layout, :content => 'Mr. Payne' }
|
26
|
+
filter = ::Nanoc::Erector::Filter.new(assigns)
|
27
|
+
|
28
|
+
# Run filter
|
29
|
+
result = filter.setup_and_run("Mr. Payne")
|
30
|
+
assert_equal '<html><head><title>My Page</title></head><body><h1>Hi, Mr. Payne!</h1></body></html>', result
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_filter_outside_layout
|
34
|
+
layout = Nanoc::Int::Layout.new('dontcare', {}, '/default/')
|
35
|
+
filter = ::Nanoc::Erector::Filter.new
|
36
|
+
|
37
|
+
# Run filter
|
38
|
+
assert_raises(Nanoc::Erector::Filter::OutsideLayoutError) do
|
39
|
+
filter.setup_and_run("Mr. Payne")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_filter_undefined_second_time
|
44
|
+
# Run once
|
45
|
+
layout = Nanoc::Int::Layout.new(TEMPLATE, {}, '/default/')
|
46
|
+
assigns = { :layout => layout, :content => 'Mr. Payne' }
|
47
|
+
filter = ::Nanoc::Erector::Filter.new(assigns)
|
48
|
+
filter.setup_and_run("Mr. Payne")
|
49
|
+
|
50
|
+
# Run again, but fail this time
|
51
|
+
layout = Nanoc::Int::Layout.new('$fun = :friday', {}, '/default/')
|
52
|
+
assigns = { :layout => layout, :content => 'Mr. Payne' }
|
53
|
+
filter = ::Nanoc::Erector::Filter.new(assigns)
|
54
|
+
assert_raises(NameError) do
|
55
|
+
filter.setup_and_run("Mr. Payne")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_filter_with_undefined_custom_name
|
60
|
+
layout = Nanoc::Int::Layout.new(TEMPLATE.sub('ErectorTemplate', 'Foo'), {}, '/default/')
|
61
|
+
assigns = { :layout => layout, :content => 'Mr. Payne' }
|
62
|
+
filter = ::Nanoc::Erector::Filter.new(assigns)
|
63
|
+
assert_raises(NameError) do
|
64
|
+
filter.setup_and_run("Mr. Payne")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nanoc-erector
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Denis Defreyne
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nanoc
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: erector
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.9'
|
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'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
description: Provides an :erector filter for nanoc
|
56
|
+
email: denis.defreyne@stoneship.org
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files:
|
60
|
+
- LICENSE
|
61
|
+
- README.md
|
62
|
+
- NEWS.md
|
63
|
+
files:
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- LICENSE
|
67
|
+
- NEWS.md
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- lib/nanoc-erector.rb
|
71
|
+
- lib/nanoc/erector.rb
|
72
|
+
- lib/nanoc/erector/filter.rb
|
73
|
+
- lib/nanoc/erector/version.rb
|
74
|
+
- nanoc-erector.gemspec
|
75
|
+
- test/filters/test_erector.rb
|
76
|
+
- test/helper.rb
|
77
|
+
homepage: http://nanoc.ws/
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options:
|
83
|
+
- "--main"
|
84
|
+
- README.md
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 1.9.3
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.4.7
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Erector filter for nanoc
|
103
|
+
test_files: []
|
104
|
+
has_rdoc:
|