nanoc-external 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/NEWS.md +4 -0
- data/README.md +15 -16
- data/lib/nanoc-external.rb +1 -1
- data/lib/nanoc/external.rb +1 -1
- data/lib/nanoc/external/filter.rb +4 -41
- data/lib/nanoc/external/version.rb +2 -4
- metadata +12 -46
- data/Gemfile +0 -7
- data/Gemfile.lock +0 -65
- data/LICENSE +0 -19
- data/Rakefile +0 -10
- data/nanoc-external-1.0.0.gem +0 -0
- data/nanoc-external.gemspec +0 -29
- data/test/filters/test_external.rb +0 -16
- data/test/helper.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0e06ea835b1ad1ab34524b31c62a74842038125a56d3f11c740044572b059f86
|
4
|
+
data.tar.gz: af95f7457c1a766f40522d9823e59bfb73b48cd2408da305ee50726366a645c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50de96d91e8ea672376e1df8b3631077aa526837e1615a9abdf2f430572ac0e26a6afcacbfabd37e22734f3228eb613a3fa3b9058b2ed1904d31998d01475005
|
7
|
+
data.tar.gz: 35fa93d19f6b80ce215a594231c8386ed9fcb088eb70a75ad6f8c820d698a4ef9e228685d7b1c6f03faa938d7ee2995d3f5da202e0dbcf34cf8b6185ad5c25ed
|
data/NEWS.md
CHANGED
data/README.md
CHANGED
@@ -1,35 +1,34 @@
|
|
1
|
-
[![Build Status](https://travis-ci.org/nanoc/nanoc-external.png)](https://travis-ci.org/nanoc/nanoc-external)
|
2
|
-
[![Code Climate](https://codeclimate.com/github/nanoc/nanoc-external.png)](https://codeclimate.com/github/nanoc/nanoc-external)
|
3
|
-
[![Coverage Status](https://coveralls.io/repos/nanoc/nanoc-external/badge.png?branch=master)](https://coveralls.io/r/nanoc/nanoc-external)
|
4
|
-
|
5
1
|
# nanoc-external
|
6
2
|
|
7
|
-
This provides a filter that allows [
|
8
|
-
|
9
|
-
Maintained by [lifepillar](https://github.com/lifepillar).
|
3
|
+
This provides a filter that allows [Nanoc](http://nanoc.ws) to process content by executing an external program.
|
10
4
|
|
11
5
|
## Installation
|
12
6
|
|
13
|
-
`
|
7
|
+
Add `nanoc-external` to the `nanoc` group of your Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
group :nanoc do
|
11
|
+
gem 'nanoc-external'
|
12
|
+
end
|
13
|
+
```
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
+
Call the `:external` filter and pass the command to execute as the `:exec` argument. For example:
|
18
|
+
|
17
19
|
```ruby
|
18
|
-
filter :external, :
|
20
|
+
filter :external, exec: 'wc'
|
19
21
|
```
|
20
22
|
|
21
|
-
The
|
22
|
-
able to receive its input from STDIN and it must send its
|
23
|
-
output to STDOUT.
|
23
|
+
The external command must receive input from standard input (“stdin”) and must send its output to standard out (“stdout”).
|
24
24
|
|
25
|
-
Options passed to this filter will be passed on to the
|
26
|
-
external command. For example:
|
25
|
+
Options passed to this filter will be passed on to the external command. For example:
|
27
26
|
|
28
27
|
```ruby
|
29
|
-
filter :external, exec: 'multimarkdown', options:
|
28
|
+
filter :external, exec: 'multimarkdown', options: %w(--accept --mask --labels --smart)
|
30
29
|
```
|
31
30
|
|
32
|
-
|
31
|
+
You can also pass the full path of the executable:
|
33
32
|
|
34
33
|
```ruby
|
35
34
|
filter :external, exec: '/opt/local/bin/htmlcompressor'
|
data/lib/nanoc-external.rb
CHANGED
data/lib/nanoc/external.rb
CHANGED
@@ -1,55 +1,18 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Nanoc::External
|
4
|
-
|
5
|
-
# Pipes content through an external process.
|
6
|
-
#
|
7
|
-
# For this filter to work, the external program must be able to receive input
|
8
|
-
# from standard input and it must write its output to standard output.
|
9
4
|
class Filter < Nanoc::Filter
|
10
|
-
|
11
5
|
identifier :external
|
12
6
|
|
13
|
-
# Executes this filter. Parameters passed to this filter
|
14
|
-
# through `:options` will be passed to the specified command.
|
15
|
-
#
|
16
|
-
# @param [String] content The content to filter.
|
17
|
-
#
|
18
|
-
# @option params [Symbol] :options ([]) A list of options for the external command.
|
19
|
-
#
|
20
|
-
# @option params [Symbol] :exec ("") The name or the full path of the executable.
|
21
|
-
#
|
22
|
-
# @option params [Symbol] :debug (false) Set to true to enable debugging.
|
23
|
-
#
|
24
|
-
# @return [String] The filtered content
|
25
|
-
#
|
26
|
-
# @example
|
27
|
-
# filter :external, exec: 'multimarkdown', options: %w( --smart )
|
28
|
-
# filter :external, exec: '/usr/local/bin/htmlcompressor
|
29
7
|
def run(content, params = {})
|
30
|
-
|
31
|
-
cmd = params.fetch(:exec, nil)
|
8
|
+
cmd = params.fetch(:exec)
|
32
9
|
opts = params.fetch(:options, [])
|
33
10
|
|
34
|
-
|
35
|
-
raise Nanoc::Errors::GenericTrivial.new("nanoc-external: missing :exec argument")
|
36
|
-
end
|
37
|
-
|
38
|
-
cmd_with_opts = [ cmd ] + opts
|
39
|
-
odebug(cmd_with_opts.join(' ')) if debug
|
11
|
+
cmd_with_opts = [cmd] + opts
|
40
12
|
out = StringIO.new
|
41
|
-
piper = Nanoc::Extra::Piper.new(:
|
13
|
+
piper = Nanoc::Extra::Piper.new(stdout: out, stderr: $stderr)
|
42
14
|
piper.run(cmd_with_opts, content)
|
43
|
-
odebug(out.string) if debug
|
44
15
|
out.string
|
45
16
|
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def odebug(msg)
|
50
|
-
msg.each_line { |l| puts "\033[1;31mDEBUG:\033[0m #{l}" }
|
51
|
-
end
|
52
|
-
|
53
17
|
end
|
54
|
-
|
55
18
|
end
|
metadata
CHANGED
@@ -1,87 +1,54 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc-external
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Denis Defreyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nanoc
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 3.6.7
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 5.0.0
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 3.6.7
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 5.0.0
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: bundler
|
35
15
|
requirement: !ruby/object:Gem::Requirement
|
36
16
|
requirements:
|
37
17
|
- - "~>"
|
38
18
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
40
|
-
type: :
|
19
|
+
version: '4.8'
|
20
|
+
type: :runtime
|
41
21
|
prerelease: false
|
42
22
|
version_requirements: !ruby/object:Gem::Requirement
|
43
23
|
requirements:
|
44
24
|
- - "~>"
|
45
25
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
26
|
+
version: '4.8'
|
47
27
|
description: Provides an :external filter for nanoc
|
48
|
-
email:
|
28
|
+
email: denis+rubygems@denis.ws
|
49
29
|
executables: []
|
50
30
|
extensions: []
|
51
|
-
extra_rdoc_files:
|
52
|
-
- LICENSE
|
53
|
-
- README.md
|
54
|
-
- NEWS.md
|
31
|
+
extra_rdoc_files: []
|
55
32
|
files:
|
56
|
-
- Gemfile
|
57
|
-
- Gemfile.lock
|
58
|
-
- LICENSE
|
59
33
|
- NEWS.md
|
60
34
|
- README.md
|
61
|
-
- Rakefile
|
62
35
|
- lib/nanoc-external.rb
|
63
36
|
- lib/nanoc/external.rb
|
64
37
|
- lib/nanoc/external/filter.rb
|
65
38
|
- lib/nanoc/external/version.rb
|
66
|
-
- nanoc-external-1.0.0.gem
|
67
|
-
- nanoc-external.gemspec
|
68
|
-
- test/filters/test_external.rb
|
69
|
-
- test/helper.rb
|
70
39
|
homepage: http://nanoc.ws/
|
71
40
|
licenses:
|
72
41
|
- MIT
|
73
42
|
metadata: {}
|
74
43
|
post_install_message:
|
75
|
-
rdoc_options:
|
76
|
-
- "--main"
|
77
|
-
- README.md
|
44
|
+
rdoc_options: []
|
78
45
|
require_paths:
|
79
46
|
- lib
|
80
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
81
48
|
requirements:
|
82
|
-
- - "
|
49
|
+
- - "~>"
|
83
50
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
51
|
+
version: '2.3'
|
85
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
53
|
requirements:
|
87
54
|
- - ">="
|
@@ -89,9 +56,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
56
|
version: '0'
|
90
57
|
requirements: []
|
91
58
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.
|
59
|
+
rubygems_version: 2.7.3
|
93
60
|
signing_key:
|
94
61
|
specification_version: 4
|
95
62
|
summary: External filter for nanoc
|
96
63
|
test_files: []
|
97
|
-
has_rdoc:
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,65 +0,0 @@
|
|
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-external (1.0.1)
|
12
|
-
nanoc (>= 3.6.7, < 4.0.0)
|
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
|
-
http-cookie (1.0.2)
|
30
|
-
domain_name (~> 0.5)
|
31
|
-
json (1.8.3)
|
32
|
-
mime-types (2.6.2)
|
33
|
-
minitest (5.8.2)
|
34
|
-
netrc (0.11.0)
|
35
|
-
rake (10.4.2)
|
36
|
-
rest-client (1.8.0)
|
37
|
-
http-cookie (>= 1.0.2, < 2.0)
|
38
|
-
mime-types (>= 1.16, < 3.0)
|
39
|
-
netrc (~> 0.7)
|
40
|
-
simplecov (0.10.0)
|
41
|
-
docile (~> 1.1.0)
|
42
|
-
json (~> 1.8)
|
43
|
-
simplecov-html (~> 0.10.0)
|
44
|
-
simplecov-html (0.10.0)
|
45
|
-
term-ansicolor (1.3.2)
|
46
|
-
tins (~> 1.0)
|
47
|
-
thor (0.19.1)
|
48
|
-
tins (1.6.0)
|
49
|
-
unf (0.1.4)
|
50
|
-
unf_ext
|
51
|
-
unf_ext (0.0.7.1)
|
52
|
-
|
53
|
-
PLATFORMS
|
54
|
-
ruby
|
55
|
-
|
56
|
-
DEPENDENCIES
|
57
|
-
bundler (~> 1.5)
|
58
|
-
coveralls
|
59
|
-
minitest
|
60
|
-
nanoc!
|
61
|
-
nanoc-external!
|
62
|
-
rake
|
63
|
-
|
64
|
-
BUNDLED WITH
|
65
|
-
1.10.6
|
data/LICENSE
DELETED
@@ -1,19 +0,0 @@
|
|
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/Rakefile
DELETED
data/nanoc-external-1.0.0.gem
DELETED
Binary file
|
data/nanoc-external.gemspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift(File.expand_path('../lib/', __FILE__))
|
4
|
-
require 'nanoc/external/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = 'nanoc-external'
|
8
|
-
s.version = Nanoc::External::VERSION
|
9
|
-
s.homepage = 'http://nanoc.ws/'
|
10
|
-
s.summary = 'External filter for nanoc'
|
11
|
-
s.description = 'Provides an :external filter for nanoc'
|
12
|
-
|
13
|
-
s.author = 'Lifepillar'
|
14
|
-
s.email = 'github@lifepillar.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-external.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', '>= 3.6.7', '< 5.0.0')
|
28
|
-
s.add_development_dependency('bundler', '~> 1.5')
|
29
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
class Nanoc::External::FilterTest < Minitest::Test
|
6
|
-
|
7
|
-
def test_filter
|
8
|
-
filter = ::Nanoc::External::Filter.new({})
|
9
|
-
src = <<-SHAKESPEARE
|
10
|
-
Shall I compare thee to a Summer's day?
|
11
|
-
Thou art more lovely and more temperate
|
12
|
-
SHAKESPEARE
|
13
|
-
assert_match(/^\s*2\s*$/, filter.run(src, :exec => 'wc', :options => %w( -l ) ))
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|