nanoc-external 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e52bfe8f2eab2b27d2f4d3d5c2836dec17479c84
4
+ data.tar.gz: 45dc63c7ef389f0eeade105d573956ff505e707b
5
+ SHA512:
6
+ metadata.gz: 45f0d2bfb03731996479768de25226c0c959608cc12bb3dcb5c604ed1e702bf1c06a508378cc21fded3e463fb88c8636f6aa7dae2c2cf4d620153b45282e9d3f
7
+ data.tar.gz: 5077eb9cda044d6b98bc98726ad9550a3a554c3475515e375919ba34027499249109c9a46d668d5620ee0d53cbb742c09e6c45e845219d5a2b34a1b5fb0591f2
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'minitest'
6
+ gem 'rake'
7
+ gem 'coveralls', require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nanoc-external (1.0.0)
5
+ nanoc (>= 3.6.7, < 4.0.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ colored (1.2)
11
+ coveralls (0.7.11)
12
+ multi_json (~> 1.10)
13
+ rest-client (>= 1.6.8, < 2)
14
+ simplecov (~> 0.9.1)
15
+ term-ansicolor (~> 1.3)
16
+ thor (~> 0.19.1)
17
+ cri (2.6.1)
18
+ colored (~> 1.2)
19
+ docile (1.1.5)
20
+ mime-types (2.4.3)
21
+ minitest (5.5.1)
22
+ multi_json (1.11.0)
23
+ nanoc (3.7.5)
24
+ cri (~> 2.3)
25
+ netrc (0.10.3)
26
+ rake (10.4.2)
27
+ rest-client (1.7.3)
28
+ mime-types (>= 1.16, < 3.0)
29
+ netrc (~> 0.7)
30
+ simplecov (0.9.2)
31
+ docile (~> 1.1.0)
32
+ multi_json (~> 1.0)
33
+ simplecov-html (~> 0.9.0)
34
+ simplecov-html (0.9.0)
35
+ term-ansicolor (1.3.0)
36
+ tins (~> 1.0)
37
+ thor (0.19.1)
38
+ tins (1.3.5)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ bundler (~> 1.5)
45
+ coveralls
46
+ minitest
47
+ nanoc-external!
48
+ rake
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
@@ -0,0 +1,5 @@
1
+ # nanoc-external news
2
+
3
+ ## 1.0.0 (2015-03-07)
4
+
5
+ Initial release.
data/README.md ADDED
@@ -0,0 +1,36 @@
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
+ # nanoc-external
6
+
7
+ This provides a filter that allows [nanoc](http://nanoc.ws) to process content by executing an external program.
8
+
9
+ Maintained by [lifepillar](https://github.com/lifepillar).
10
+
11
+ ## Installation
12
+
13
+ `gem install nanoc-external`
14
+
15
+ ## Usage
16
+
17
+ ```ruby
18
+ filter :external, :exec => 'command-name'
19
+ ```
20
+
21
+ The only requirement is that the external command must be
22
+ able to receive its input from STDIN and it must send its
23
+ output to STDOUT.
24
+
25
+ Options passed to this filter will be passed on to the
26
+ external command. For example:
27
+
28
+ ```ruby
29
+ filter :external, exec: 'multimarkdown', options: => %w(--accept --mask --labels --smart)
30
+ ```
31
+
32
+ If the executable is not in your PATH, use its full path:
33
+
34
+ ```ruby
35
+ filter :external, exec: '/opt/local/bin/htmlcompressor'
36
+ ```
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs = %w( lib test )
7
+ t.test_files = FileList['test/**/test_*.rb', 'test/**/*_spec.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+
3
+ require 'nanoc/external'
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc
4
+ module External
5
+ end
6
+ end
7
+
8
+ require 'nanoc/external/version'
9
+ require 'nanoc/external/filter'
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
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
+ class Filter < Nanoc::Filter
10
+
11
+ identifier :external
12
+
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
+ def run(content, params = {})
30
+ debug = params.fetch(:debug, false)
31
+ cmd = params.fetch(:exec, nil)
32
+ opts = params.fetch(:options, [])
33
+
34
+ if cmd.nil?
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
40
+ out = StringIO.new
41
+ piper = Nanoc::Extra::Piper.new(:stdout => out, :stderr => $stderr)
42
+ piper.run(cmd_with_opts, content)
43
+ odebug(out.string) if debug
44
+ out.string
45
+ 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
+ end
54
+
55
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc
4
+ module External
5
+
6
+ VERSION = '1.0.0'
7
+
8
+ end
9
+ end
@@ -0,0 +1,29 @@
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', '< 4.0.0')
28
+ s.add_development_dependency('bundler', '~> 1.5')
29
+ end
@@ -0,0 +1,16 @@
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
data/test/helper.rb ADDED
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+
6
+ require 'minitest'
7
+ require 'minitest/autorun'
8
+ require 'nanoc'
9
+ require 'nanoc-external'
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nanoc-external
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Lifepillar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-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: 3.6.7
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 4.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: 4.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.5'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.5'
47
+ description: Provides an :external filter for nanoc
48
+ email: github@lifepillar.org
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files:
52
+ - LICENSE
53
+ - README.md
54
+ - NEWS.md
55
+ files:
56
+ - Gemfile
57
+ - Gemfile.lock
58
+ - LICENSE
59
+ - NEWS.md
60
+ - README.md
61
+ - Rakefile
62
+ - lib/nanoc-external.rb
63
+ - lib/nanoc/external.rb
64
+ - lib/nanoc/external/filter.rb
65
+ - lib/nanoc/external/version.rb
66
+ - nanoc-external.gemspec
67
+ - test/filters/test_external.rb
68
+ - test/helper.rb
69
+ homepage: http://nanoc.ws/
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options:
75
+ - "--main"
76
+ - README.md
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 1.9.3
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.4.5
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: External filter for nanoc
95
+ test_files: []
96
+ has_rdoc: