nanoc 3.6.8 → 3.6.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- Y2RmYzljOTcyNWE2NzhmYTEzZWI3MDhlNDAzNTQ2ZGZhMzhhYTliMg==
5
- data.tar.gz: !binary |-
6
- YWYzNTkyNDZmYWU0ZjdiMWE0NWIwNDZiMmEzMDhjYmRhMTc5NDZmZg==
2
+ SHA1:
3
+ metadata.gz: e57a92e04d4e25dba882d2e0953820b5ea5cc713
4
+ data.tar.gz: 9046eec0428c852a64c41199cdb3582c828a9420
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZWQ1N2I4MDVhOWJhMTYzNzI3Mjg5MmIwYWVlZmE0MzViMDk4NmI3ZDA3MTUx
10
- MzJmNjhhMjFjNTdhZTMzZDBjMzIyODhhNzYxYTVlOTVhNDM2MzYwNWMyOTAx
11
- ZTQyMTk2M2RmMGE1Nzg2NDhiOTVlZmEzNWUyMWZlZjhjZjAzZjA=
12
- data.tar.gz: !binary |-
13
- NjQxYTNjMmZlYmQ0OTRlNWYzYjE4MWNiNDYyYjQ5MjI1N2U1ZjNjZDY4OWY0
14
- YjU3Mjk2NjlkMTgxZTQ3YmE2OWRiMGY4MThiMzU5Mjc2MjFjMTc1MzI2YWY5
15
- YWM5MzM3MzczZGMwMzI4ZDdiNjRjMDAyOWRlMWJjNTMyYjE2MmE=
6
+ metadata.gz: d81d19a33e83db6c091062d3df87e9f2393f8363049f255ee8fd08c51b5835f204aeb03bb2bfec71d9c97649313196415af378860b3fadfbbb0524fc0c9a0328
7
+ data.tar.gz: 49b337ebf2aaf1a1fb745a82ff3d0af62a87d074620b89b2b5017e8b679e42825cb8d5aa32d4a7ebf2b496b2e9126a25d8d88b34f345e830b871be1737f9fcc8
data/Gemfile CHANGED
@@ -24,19 +24,18 @@ gem 'mustache'
24
24
  gem 'nokogiri', '~> 1.5.5'
25
25
  gem 'pandoc-ruby'
26
26
  gem 'pry'
27
- gem 'pygments.rb'
27
+ gem 'pygments.rb', :platforms => [:ruby, :mswin]
28
28
  gem 'rack'
29
29
  gem 'rake'
30
30
  gem 'rainpress'
31
- gem 'rdiscount'
31
+ gem 'rdiscount', :platforms => [:ruby, :mswin]
32
32
  gem 'rdoc'
33
- gem 'redcarpet'
33
+ gem 'redcarpet', :platforms => [:ruby, :mswin]
34
34
  gem 'RedCloth'
35
35
  gem 'rubocop'
36
36
  gem 'rubypants'
37
37
  gem 'sass', '~> 3.2.2'
38
38
  gem 'slim'
39
- gem 'systemu'
40
39
  gem 'typogruby'
41
40
  gem 'uglifier'
42
41
  gem 'w3c_validators'
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nanoc (3.6.7)
4
+ nanoc (3.6.9)
5
5
  cri (~> 2.3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  RedCloth (4.2.9)
11
+ RedCloth (4.2.9-java)
11
12
  adsf (1.2.0)
12
13
  rack (>= 1.0.0)
13
14
  ast (1.1.0)
@@ -26,22 +27,23 @@ GEM
26
27
  coffee-script-source (1.7.0)
27
28
  colored (1.2)
28
29
  commonjs (0.2.7)
29
- compass (0.12.4)
30
+ compass (0.12.5)
30
31
  chunky_png (~> 1.2)
31
32
  fssm (>= 0.2.7)
32
- sass (~> 3.2.17)
33
- cri (2.5.0)
34
- colored (>= 1.2)
33
+ sass (~> 3.2.19)
34
+ cri (2.6.0)
35
+ colored (~> 1.2)
35
36
  erubis (2.7.0)
36
37
  excon (0.32.1)
37
38
  execjs (2.0.2)
38
39
  ffi (1.9.3)
40
+ ffi (1.9.3-java)
39
41
  fog (1.21.0)
40
42
  fog-brightbox
41
43
  fog-core (~> 1.21, >= 1.21.1)
42
44
  fog-json
43
45
  nokogiri (~> 1.5, >= 1.5.11)
44
- fog-brightbox (0.0.1)
46
+ fog-brightbox (0.0.2)
45
47
  fog-core
46
48
  fog-json
47
49
  fog-core (1.21.1)
@@ -62,6 +64,7 @@ GEM
62
64
  therubyracer (~> 0.12.0)
63
65
  handlebars-source (1.3.0)
64
66
  json (1.8.1)
67
+ json (1.8.1-java)
65
68
  kramdown (1.3.3)
66
69
  less (2.5.0)
67
70
  commonjs (~> 0.2.7)
@@ -82,11 +85,13 @@ GEM
82
85
  metaclass (~> 0.0.1)
83
86
  multi_json (1.9.2)
84
87
  mustache (0.99.5)
85
- net-scp (1.1.2)
88
+ net-scp (1.2.0)
86
89
  net-ssh (>= 2.6.5)
87
90
  net-ssh (2.8.0)
88
91
  nio4r (1.0.0)
92
+ nio4r (1.0.0-java)
89
93
  nokogiri (1.5.11)
94
+ nokogiri (1.5.11-java)
90
95
  pandoc-ruby (0.7.5)
91
96
  parser (2.1.7)
92
97
  ast (~> 1.1)
@@ -97,22 +102,27 @@ GEM
97
102
  coderay (~> 1.0)
98
103
  method_source (~> 0.8)
99
104
  slop (~> 3.4)
105
+ pry (0.9.12.6-java)
106
+ coderay (~> 1.0)
107
+ method_source (~> 0.8)
108
+ slop (~> 3.4)
109
+ spoon (~> 0.0)
100
110
  pygments.rb (0.5.4)
101
111
  posix-spawn (~> 0.3.6)
102
112
  yajl-ruby (~> 1.1.0)
103
113
  rack (1.5.2)
104
114
  rainbow (2.0.0)
105
115
  rainpress (1.0)
106
- rake (10.1.1)
116
+ rake (10.2.2)
107
117
  rb-fsevent (0.9.4)
108
118
  rb-inotify (0.9.3)
109
119
  ffi (>= 0.5.0)
110
- rdiscount (2.1.7)
120
+ rdiscount (2.1.7.1)
111
121
  rdoc (4.1.1)
112
122
  json (~> 1.4)
113
123
  redcarpet (3.1.1)
114
124
  ref (1.0.5)
115
- rubocop (0.19.1)
125
+ rubocop (0.20.1)
116
126
  json (>= 1.7.7, < 2)
117
127
  parser (~> 2.1.7)
118
128
  powerpack (~> 0.0.6)
@@ -120,12 +130,13 @@ GEM
120
130
  ruby-progressbar (~> 1.4)
121
131
  ruby-progressbar (1.4.2)
122
132
  rubypants (0.2.0)
123
- sass (3.2.17)
133
+ sass (3.2.19)
124
134
  slim (2.0.2)
125
135
  temple (~> 0.6.6)
126
136
  tilt (>= 1.3.3, < 2.1)
127
137
  slop (3.5.0)
128
- systemu (2.6.4)
138
+ spoon (0.0.4)
139
+ ffi
129
140
  temple (0.6.7)
130
141
  therubyracer (0.12.1)
131
142
  libv8 (~> 3.16.14.0)
@@ -141,10 +152,11 @@ GEM
141
152
  json
142
153
  nokogiri
143
154
  yajl-ruby (1.1.0)
144
- yard (0.8.7.3)
155
+ yard (0.8.7.4)
145
156
  yuicompressor (1.3.3)
146
157
 
147
158
  PLATFORMS
159
+ java
148
160
  ruby
149
161
 
150
162
  DEPENDENCIES
@@ -184,7 +196,6 @@ DEPENDENCIES
184
196
  rubypants
185
197
  sass (~> 3.2.2)
186
198
  slim
187
- systemu
188
199
  typogruby
189
200
  uglifier
190
201
  w3c_validators
data/NEWS.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # nanoc news
2
2
 
3
+ ## 3.6.9 (2014-04-15)
4
+
5
+ Fixes:
6
+
7
+ * Fixed path to default stylesheet (#410, #411)
8
+ * Improved reliability of piping from/to external processes in JRuby (#417)
9
+ * Added workaround for “cannot modify” errors when using Nokogiri on JRuby (#416)
10
+ * Made corrupted cached data auto-repair itself if possible (#409, #418)
11
+
3
12
  ## 3.6.8 (2014-03-22)
4
13
 
5
14
  Fixes:
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
- [![Build Status](https://travis-ci.org/nanoc/nanoc.png)](https://travis-ci.org/nanoc/nanoc)
2
- [![Code Climate](https://codeclimate.com/github/nanoc/nanoc.png)](https://codeclimate.com/github/nanoc/nanoc)
3
- [![Coverage Status](https://coveralls.io/repos/nanoc/nanoc/badge.png?branch=master)](https://coveralls.io/r/nanoc/nanoc)
4
- [![Gem Version](https://badge.fury.io/rb/nanoc.png)](http://badge.fury.io/rb/nanoc)
1
+ [![Gem version](http://img.shields.io/gem/v/nanoc.svg)](http://rubygems.org/gems/nanoc)
2
+ [![Build status](http://img.shields.io/travis/nanoc/nanoc.svg)](https://travis-ci.org/nanoc/nanoc)
3
+ [![Code Climate](http://img.shields.io/codeclimate/github/nanoc/nanoc.svg)](https://codeclimate.com/github/nanoc/nanoc)
4
+ [![Code Coverage](http://img.shields.io/coveralls/nanoc/nanoc.svg)](https://coveralls.io/r/nanoc/nanoc)
5
+ [![Documentation Coverage](http://inch-pages.github.io/github/nanoc/nanoc.svg)](http://inch-pages.github.io/github/nanoc/nanoc/)
5
6
 
6
7
  ![nanoc logo](https://avatars1.githubusercontent.com/u/3260163?s=140)
7
8
 
@@ -73,17 +73,22 @@ module Nanoc
73
73
  return
74
74
  end
75
75
 
76
- pstore.transaction do
77
- # Check version
78
- if pstore[:version] != version
79
- version_mismatch_detected
76
+ begin
77
+ pstore.transaction do
78
+ # Check version
79
+ if pstore[:version] != version
80
+ version_mismatch_detected
81
+ @loaded = true
82
+ return
83
+ end
84
+
85
+ # Load
86
+ self.data = pstore[:data]
80
87
  @loaded = true
81
- return
82
88
  end
83
-
84
- # Load
85
- self.data = pstore[:data]
86
- @loaded = true
89
+ rescue
90
+ FileUtils.rm_f(filename)
91
+ load
87
92
  end
88
93
  end
89
94
 
@@ -252,7 +252,7 @@ EOS
252
252
  <head>
253
253
  <meta charset="utf-8">
254
254
  <title>A Brand New nanoc Site - <%= @item[:title] %></title>
255
- <link rel="stylesheet" href="/style.css">
255
+ <link rel="stylesheet" href="<%= @items['/stylesheet/'].path %>">
256
256
 
257
257
  <!-- you don't need to keep this, but it's cool for stats! -->
258
258
  <meta name="generator" content="nanoc <%= Nanoc::VERSION %>">
@@ -217,7 +217,6 @@ module Nanoc::CLI
217
217
  'redcloth' => 'RedCloth',
218
218
  'rubypants' => 'rubypants',
219
219
  'sass' => 'sass',
220
- 'systemu' => 'systemu',
221
220
  'w3c_validators' => 'w3c_validators'
222
221
  }
223
222
 
@@ -9,6 +9,7 @@ module Nanoc::Extra
9
9
  autoload 'LinkCollector', 'nanoc/extra/link_collector.rb'
10
10
  autoload 'Pruner', 'nanoc/extra/pruner'
11
11
  autoload 'Validators', 'nanoc/extra/validators'
12
+ autoload 'Piper', 'nanoc/extra/piper'
12
13
 
13
14
  # Deprecated; use {Nanoc::Context} instead
14
15
  # TODO [in nanoc 4.0] remove me
@@ -31,8 +31,6 @@ module Nanoc::Extra::Deployers
31
31
 
32
32
  # @see Nanoc::Extra::Deployer#run
33
33
  def run
34
- require 'systemu'
35
-
36
34
  # Get params
37
35
  src = source_path + '/'
38
36
  dst = config[:dst]
@@ -53,11 +51,9 @@ module Nanoc::Extra::Deployers
53
51
 
54
52
  private
55
53
 
56
- # Runs the given shell command. It will raise an error if execution fails
57
- # (results in a nonzero exit code).
58
- def run_shell_cmd(args)
59
- status = systemu(args, 'stdout' => $stdout, 'stderr' => $stderr)
60
- raise "command exited with a nonzero status code #{$CHILD_STATUS.exitstatus} (command: #{args.join(' ')})" if !status.success?
54
+ def run_shell_cmd(cmd)
55
+ piper = Nanoc::Extra::Piper.new(:stdout => $stdout, :stderr => $stderr)
56
+ piper.run(cmd, nil)
61
57
  end
62
58
 
63
59
  end
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ require 'open3'
4
+
5
+ module Nanoc::Extra
6
+
7
+ class Piper
8
+
9
+ class Error < ::Nanoc::Errors::Generic
10
+
11
+ def initialize(command, exit_code)
12
+ @command = command
13
+ @exit_code = exit_code
14
+ end
15
+
16
+ def message
17
+ "command exited with a nonzero status code #{@exit_code} (command: #{@command.join(' ')})"
18
+ end
19
+
20
+ end
21
+
22
+ # @option [IO] :stdout ($stdout)
23
+ # @option [IO] :stderr ($stderr)
24
+ def initialize(params={})
25
+ @stdout = params.fetch(:stdout, $stdout)
26
+ @stderr = params.fetch(:stderr, $stderr)
27
+ end
28
+
29
+ # @param [Array<String>] cmd
30
+ #
31
+ # @param [String, nil] input
32
+ def run(cmd, input)
33
+ Open3.popen3(*cmd) do |stdin, stdout, stderr, wait_thr|
34
+ stdout_thread = Thread.new { @stdout << stdout.read }
35
+ stderr_thread = Thread.new { @stderr << stderr.read }
36
+
37
+ if input
38
+ stdin << input
39
+ end
40
+ stdin.close
41
+
42
+ stdout_thread.join
43
+ stderr_thread.join
44
+
45
+ exit_status = wait_thr.value
46
+ if !exit_status.success?
47
+ raise Error.new(exit_status.to_i, cmd)
48
+ end
49
+ end
50
+ end
51
+
52
+ end
53
+
54
+ end
@@ -5,8 +5,6 @@ module Nanoc::Filters
5
5
  # @since 3.2.0
6
6
  class AsciiDoc < Nanoc::Filter
7
7
 
8
- requires 'systemu'
9
-
10
8
  # Runs the content through [AsciiDoc](http://www.methods.co.nz/asciidoc/).
11
9
  # This method takes no options.
12
10
  #
@@ -14,23 +12,11 @@ module Nanoc::Filters
14
12
  #
15
13
  # @return [String] The filtered content
16
14
  def run(content, params = {})
17
- # Run command
18
- stdout = ''
19
- stderr = ''
20
- status = systemu(
21
- %w( asciidoc -o - - ),
22
- 'stdin' => content,
23
- 'stdout' => stdout,
24
- 'stderr' => stderr)
25
-
26
- # Show errors
27
- unless status.success?
28
- $stderr.puts stderr
29
- raise "AsciiDoc filter failed with status #{status}"
30
- end
31
-
32
- # Get result
33
- stdout
15
+ stdout = StringIO.new
16
+ stderr = $stderr
17
+ piper = Nanoc::Extra::Piper.new(:stdout => stdout, :stderr => stderr)
18
+ piper.run(%w( asciidoc -o - - ), content)
19
+ stdout.string
34
20
  end
35
21
 
36
22
  end
@@ -101,8 +101,7 @@ module Nanoc::Filters
101
101
  end
102
102
 
103
103
  # Colorize
104
- is_fullpage = params.fetch(:is_fullpage) { false }
105
- doc = is_fullpage ? klass.parse(content, nil, 'UTF-8') : klass.fragment(content)
104
+ doc = parse(content, klass, params.fetch(:is_fullpage, false))
106
105
  selector = params[:outside_pre] ? 'code' : 'pre > code'
107
106
  doc.css(selector).each do |element|
108
107
  # Get language
@@ -143,6 +142,35 @@ module Nanoc::Filters
143
142
  doc.send(method, :encoding => 'UTF-8')
144
143
  end
145
144
 
145
+ # Parses the given content using the given class. This method also handles
146
+ # an issue with Nokogiri on JRuby causing “cannot modify frozen string”
147
+ # errors.
148
+ #
149
+ # @param [String] content The content to parse
150
+ #
151
+ # @param [Class] klass The Nokogiri parser class (either Nokogiri::HTML
152
+ # or Nokogiri::XML)
153
+ #
154
+ # @param [Boolean] is_fullpage true if the given content is a full page,
155
+ # false if it is a fragment
156
+ #
157
+ # @api private
158
+ def parse(content, klass, is_fullpage)
159
+ begin
160
+ if is_fullpage
161
+ klass.parse(content, nil, 'UTF-8')
162
+ else
163
+ klass.fragment(content)
164
+ end
165
+ rescue => e
166
+ if e.message =~ /can't modify frozen string/
167
+ parse(content.dup, klass, is_fullpage)
168
+ else
169
+ raise e
170
+ end
171
+ end
172
+ end
173
+
146
174
  # Runs the code through [CodeRay](http://coderay.rubychan.de/).
147
175
  #
148
176
  # @api private
@@ -185,23 +213,20 @@ module Nanoc::Filters
185
213
  #
186
214
  # @return [String] The colorized output
187
215
  def pygmentize(code, language, params = {})
188
- require 'systemu'
189
216
  check_availability('pygmentize', '-V')
190
217
 
191
218
  params[:encoding] ||= 'utf-8'
192
219
  params[:nowrap] ||= 'True'
193
220
 
194
- # Build command
195
221
  cmd = [ 'pygmentize', '-l', language, '-f', 'html' ]
196
222
  cmd << '-O' << params.map { |k, v| "#{k}=#{v}" }.join(',') unless params.empty?
197
223
 
198
- # Run command
199
224
  stdout = StringIO.new
200
- systemu cmd, 'stdin' => code, 'stdout' => stdout
225
+ stderr = $stderr
226
+ piper = Nanoc::Extra::Piper.new(:stdout => stdout, :stderr => stderr)
227
+ piper.run(cmd, code)
201
228
 
202
- # Get result
203
- stdout.rewind
204
- stdout.read
229
+ stdout.string
205
230
  end
206
231
 
207
232
  # Runs the content through [Pygments](http://pygments.org/) via
@@ -246,11 +271,8 @@ module Nanoc::Filters
246
271
  #
247
272
  # @return [String] The colorized output
248
273
  def simon_highlight(code, language, params = {})
249
- require 'systemu'
250
-
251
274
  check_availability('highlight', '--version')
252
275
 
253
- # Build command
254
276
  cmd = [ 'highlight', '--syntax', language, '--fragment' ]
255
277
  params.each do |key, value|
256
278
  if SIMON_HIGHLIGHT_OPT_MAP[key]
@@ -264,13 +286,12 @@ module Nanoc::Filters
264
286
  end
265
287
  end
266
288
 
267
- # Run command
268
289
  stdout = StringIO.new
269
- systemu cmd, 'stdin' => code, 'stdout' => stdout
290
+ stderr = $stderr
291
+ piper = Nanoc::Extra::Piper.new(:stdout => stdout, :stderr => stderr)
292
+ piper.run(cmd, code)
270
293
 
271
- # Get result
272
- stdout.rewind
273
- stdout.read
294
+ stdout.string
274
295
  end
275
296
 
276
297
  # Wraps the element in <div class="CodeRay"><div class="code">
@@ -323,8 +344,8 @@ module Nanoc::Filters
323
344
  end
324
345
 
325
346
  def check_availability(*cmd)
326
- systemu cmd
327
- raise "Could not spawn #{cmd.join(' ')}" if $CHILD_STATUS.exitstatus != 0
347
+ piper = Nanoc::Extra::Piper.new(:stdout => StringIO.new, :stderr => StringIO.new)
348
+ piper.run(cmd, nil)
328
349
  end
329
350
 
330
351
  end
@@ -3,6 +3,6 @@
3
3
  module Nanoc
4
4
 
5
5
  # The current nanoc version.
6
- VERSION = '3.6.8'
6
+ VERSION = '3.6.9'
7
7
 
8
8
  end
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ class Nanoc::StoreTest < Nanoc::TestCase
4
+
5
+ class TestStore < Nanoc::Store
6
+
7
+ def data
8
+ @data
9
+ end
10
+
11
+ def data=(new_data)
12
+ @data = new_data
13
+ end
14
+
15
+ end
16
+
17
+ def test_delete_and_reload_on_error
18
+ store = TestStore.new('test.db', 1)
19
+
20
+ # Create
21
+ store.load
22
+ store.data = { :fun => 'sure' }
23
+ store.store
24
+
25
+ # Test stored values
26
+ store = TestStore.new('test.db', 1)
27
+ store.load
28
+ assert_equal({ :fun => 'sure' }, store.data)
29
+
30
+ # Mess up
31
+ File.open('test.db', 'w') do |io|
32
+ io << 'Damn {}#}%@}$^)@&$&*^#@ broken stores!!!'
33
+ end
34
+
35
+ # Reload
36
+ store = TestStore.new('test.db', 1)
37
+ store.load
38
+ assert_equal(nil, store.data)
39
+ end
40
+
41
+ end
@@ -19,4 +19,14 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
19
19
  end
20
20
  end
21
21
 
22
+ def test_new_site_has_correct_stylesheets
23
+ Nanoc::CLI.run %w( create_site foo )
24
+ FileUtils.cd('foo') do
25
+ Nanoc::CLI.run %w( compile )
26
+
27
+ assert File.file?('content/stylesheet.css')
28
+ assert_match(/\/stylesheet.css/, File.read('output/index.html'))
29
+ end
30
+ end
31
+
22
32
  end
@@ -4,182 +4,166 @@ class Nanoc::CLI::Commands::DeployTest < Nanoc::TestCase
4
4
 
5
5
  def test_deploy
6
6
  skip_unless_have_command "rsync"
7
- if_have 'systemu' do
8
- with_site do |site|
9
- File.open('nanoc.yaml', 'w') do |io|
10
- io.write "deploy:\n"
11
- io.write " public:\n"
12
- io.write " kind: rsync\n"
13
- io.write " dst: mydestination"
14
- end
7
+ with_site do |site|
8
+ File.open('nanoc.yaml', 'w') do |io|
9
+ io.write "deploy:\n"
10
+ io.write " public:\n"
11
+ io.write " kind: rsync\n"
12
+ io.write " dst: mydestination"
13
+ end
15
14
 
16
- FileUtils.mkdir_p('output')
17
- File.open('output/blah.html', 'w') { |io| io.write 'moo' }
15
+ FileUtils.mkdir_p('output')
16
+ File.open('output/blah.html', 'w') { |io| io.write 'moo' }
18
17
 
19
- Nanoc::CLI.run %w( deploy -t public )
18
+ Nanoc::CLI.run %w( deploy -t public )
20
19
 
21
- assert File.directory?('mydestination')
22
- assert File.file?('mydestination/blah.html')
23
- end
20
+ assert File.directory?('mydestination')
21
+ assert File.file?('mydestination/blah.html')
24
22
  end
25
23
  end
26
24
 
27
25
  def test_deploy_with_dry_run
28
- if_have 'systemu' do
29
- with_site do |site|
30
- File.open('nanoc.yaml', 'w') do |io|
31
- io.write "deploy:\n"
32
- io.write " public:\n"
33
- io.write " kind: rsync\n"
34
- io.write " dst: mydestination"
35
- end
26
+ with_site do |site|
27
+ File.open('nanoc.yaml', 'w') do |io|
28
+ io.write "deploy:\n"
29
+ io.write " public:\n"
30
+ io.write " kind: rsync\n"
31
+ io.write " dst: mydestination"
32
+ end
36
33
 
37
- FileUtils.mkdir_p('output')
38
- File.open('output/blah.html', 'w') { |io| io.write 'moo' }
34
+ FileUtils.mkdir_p('output')
35
+ File.open('output/blah.html', 'w') { |io| io.write 'moo' }
39
36
 
40
- Nanoc::CLI.run %w( deploy -t public -n )
37
+ Nanoc::CLI.run %w( deploy -t public -n )
41
38
 
42
- refute File.directory?('mydestination')
43
- refute File.file?('mydestination/blah.html')
44
- end
39
+ refute File.directory?('mydestination')
40
+ refute File.file?('mydestination/blah.html')
45
41
  end
46
42
  end
47
43
 
48
44
  def test_deploy_with_list_without_config
49
- if_have 'systemu' do
50
- with_site do |site|
51
- FileUtils.mkdir_p('output')
52
- File.open('output/blah.html', 'w') { |io| io.write 'moo' }
45
+ with_site do |site|
46
+ FileUtils.mkdir_p('output')
47
+ File.open('output/blah.html', 'w') { |io| io.write 'moo' }
53
48
 
54
- ios = capturing_stdio do
55
- Nanoc::CLI.run %w( deploy -L )
56
- end
49
+ ios = capturing_stdio do
50
+ Nanoc::CLI.run %w( deploy -L )
51
+ end
57
52
 
58
- assert ios[:stdout].include?('No deployment configurations.')
53
+ assert ios[:stdout].include?('No deployment configurations.')
59
54
 
60
- refute File.directory?('mydestination')
61
- refute File.file?('mydestination/blah.html')
62
- end
55
+ refute File.directory?('mydestination')
56
+ refute File.file?('mydestination/blah.html')
63
57
  end
64
58
  end
65
59
 
66
60
  def test_deploy_with_list
67
- if_have 'systemu' do
68
- with_site do |site|
69
- File.open('nanoc.yaml', 'w') do |io|
70
- io.write "deploy:\n"
71
- io.write " public:\n"
72
- io.write " kind: rsync\n"
73
- io.write " dst: mydestination"
74
- end
61
+ with_site do |site|
62
+ File.open('nanoc.yaml', 'w') do |io|
63
+ io.write "deploy:\n"
64
+ io.write " public:\n"
65
+ io.write " kind: rsync\n"
66
+ io.write " dst: mydestination"
67
+ end
75
68
 
76
- FileUtils.mkdir_p('output')
77
- File.open('output/blah.html', 'w') { |io| io.write 'moo' }
69
+ FileUtils.mkdir_p('output')
70
+ File.open('output/blah.html', 'w') { |io| io.write 'moo' }
78
71
 
79
- ios = capturing_stdio do
80
- Nanoc::CLI.run %w( deploy -L )
81
- end
72
+ ios = capturing_stdio do
73
+ Nanoc::CLI.run %w( deploy -L )
74
+ end
82
75
 
83
- assert ios[:stdout].include?('Available deployment configurations:')
76
+ assert ios[:stdout].include?('Available deployment configurations:')
84
77
 
85
- refute File.directory?('mydestination')
86
- refute File.file?('mydestination/blah.html')
87
- end
78
+ refute File.directory?('mydestination')
79
+ refute File.file?('mydestination/blah.html')
88
80
  end
89
81
  end
90
82
 
91
83
  def test_deploy_with_list_deployers
92
- if_have 'systemu' do
93
- with_site do |site|
94
- File.open('nanoc.yaml', 'w') do |io|
95
- io.write "deploy:\n"
96
- io.write " public:\n"
97
- io.write " kind: rsync\n"
98
- io.write " dst: mydestination"
99
- end
84
+ with_site do |site|
85
+ File.open('nanoc.yaml', 'w') do |io|
86
+ io.write "deploy:\n"
87
+ io.write " public:\n"
88
+ io.write " kind: rsync\n"
89
+ io.write " dst: mydestination"
90
+ end
100
91
 
101
- FileUtils.mkdir_p('output')
102
- File.open('output/blah.html', 'w') { |io| io.write 'moo' }
92
+ FileUtils.mkdir_p('output')
93
+ File.open('output/blah.html', 'w') { |io| io.write 'moo' }
103
94
 
104
- ios = capturing_stdio do
105
- Nanoc::CLI.run %w( deploy -D )
106
- end
95
+ ios = capturing_stdio do
96
+ Nanoc::CLI.run %w( deploy -D )
97
+ end
107
98
 
108
- assert ios[:stdout].include?('Available deployers:')
99
+ assert ios[:stdout].include?('Available deployers:')
109
100
 
110
- refute File.directory?('mydestination')
111
- refute File.file?('mydestination/blah.html')
112
- end
101
+ refute File.directory?('mydestination')
102
+ refute File.file?('mydestination/blah.html')
113
103
  end
114
104
  end
115
105
 
116
106
  def test_deploy_without_kind
117
107
  skip_unless_have_command "rsync"
118
- if_have 'systemu' do
119
- with_site do |site|
120
- File.open('nanoc.yaml', 'w') do |io|
121
- io.write "deploy:\n"
122
- io.write " public:\n"
123
- io.write " dst: mydestination"
124
- end
108
+ with_site do |site|
109
+ File.open('nanoc.yaml', 'w') do |io|
110
+ io.write "deploy:\n"
111
+ io.write " public:\n"
112
+ io.write " dst: mydestination"
113
+ end
125
114
 
126
- FileUtils.mkdir_p('output')
127
- File.open('output/blah.html', 'w') { |io| io.write 'moo' }
115
+ FileUtils.mkdir_p('output')
116
+ File.open('output/blah.html', 'w') { |io| io.write 'moo' }
128
117
 
129
- ios = capturing_stdio do
130
- Nanoc::CLI.run %w( deploy -t public )
131
- end
118
+ ios = capturing_stdio do
119
+ Nanoc::CLI.run %w( deploy -t public )
120
+ end
132
121
 
133
- assert ios[:stderr].include?('Warning: The specified deploy target does not have a kind attribute. Assuming rsync.')
122
+ assert ios[:stderr].include?('Warning: The specified deploy target does not have a kind attribute. Assuming rsync.')
134
123
 
135
- assert File.directory?('mydestination')
136
- assert File.file?('mydestination/blah.html')
137
- end
124
+ assert File.directory?('mydestination')
125
+ assert File.file?('mydestination/blah.html')
138
126
  end
139
127
  end
140
128
 
141
129
  def test_deploy_without_target_without_default
142
- if_have 'systemu' do
143
- with_site do |site|
144
- File.open('nanoc.yaml', 'w') do |io|
145
- io.write "deploy:\n"
146
- io.write " public:\n"
147
- io.write " dst: mydestination"
148
- end
130
+ with_site do |site|
131
+ File.open('nanoc.yaml', 'w') do |io|
132
+ io.write "deploy:\n"
133
+ io.write " public:\n"
134
+ io.write " dst: mydestination"
135
+ end
149
136
 
150
- FileUtils.mkdir_p('output')
151
- File.open('output/blah.html', 'w') { |io| io.write 'moo' }
137
+ FileUtils.mkdir_p('output')
138
+ File.open('output/blah.html', 'w') { |io| io.write 'moo' }
152
139
 
153
- capturing_stdio do
154
- err = assert_raises Nanoc::Errors::GenericTrivial do
155
- Nanoc::CLI.run %w( deploy )
156
- end
157
- assert_equal 'The site has no deployment configuration for default.', err.message
140
+ capturing_stdio do
141
+ err = assert_raises Nanoc::Errors::GenericTrivial do
142
+ Nanoc::CLI.run %w( deploy )
158
143
  end
144
+ assert_equal 'The site has no deployment configuration for default.', err.message
159
145
  end
160
146
  end
161
147
  end
162
148
 
163
149
  def test_deploy_without_target_with_default
164
150
  skip_unless_have_command "rsync"
165
- if_have 'systemu' do
166
- with_site do |site|
167
- File.open('nanoc.yaml', 'w') do |io|
168
- io.write "deploy:\n"
169
- io.write " default:\n"
170
- io.write " dst: mydestination"
171
- end
172
-
173
- FileUtils.mkdir_p('output')
174
- File.open('output/blah.html', 'w') { |io| io.write 'moo' }
151
+ with_site do |site|
152
+ File.open('nanoc.yaml', 'w') do |io|
153
+ io.write "deploy:\n"
154
+ io.write " default:\n"
155
+ io.write " dst: mydestination"
156
+ end
175
157
 
176
- capturing_stdio do
177
- Nanoc::CLI.run %w( deploy )
178
- end
158
+ FileUtils.mkdir_p('output')
159
+ File.open('output/blah.html', 'w') { |io| io.write 'moo' }
179
160
 
180
- assert File.directory?('mydestination')
181
- assert File.file?('mydestination/blah.html')
161
+ capturing_stdio do
162
+ Nanoc::CLI.run %w( deploy )
182
163
  end
164
+
165
+ assert File.directory?('mydestination')
166
+ assert File.file?('mydestination/blah.html')
183
167
  end
184
168
  end
185
169
 
@@ -3,96 +3,88 @@
3
3
  class Nanoc::Extra::Deployers::RsyncTest < Nanoc::TestCase
4
4
 
5
5
  def test_run_without_dst
6
- if_have 'systemu' do
7
- # Create deployer
8
- rsync = Nanoc::Extra::Deployers::Rsync.new(
9
- 'output/',
10
- {})
11
-
12
- # Mock run_shell_cmd
13
- def rsync.run_shell_cmd(args)
14
- @shell_cms_args = args
15
- end
16
-
17
- # Try running
18
- error = assert_raises(RuntimeError) do
19
- rsync.run
20
- end
21
-
22
- # Check error message
23
- assert_equal 'No dst found in deployment configuration', error.message
6
+ # Create deployer
7
+ rsync = Nanoc::Extra::Deployers::Rsync.new(
8
+ 'output/',
9
+ {})
10
+
11
+ # Mock run_shell_cmd
12
+ def rsync.run_shell_cmd(args)
13
+ @shell_cms_args = args
24
14
  end
15
+
16
+ # Try running
17
+ error = assert_raises(RuntimeError) do
18
+ rsync.run
19
+ end
20
+
21
+ # Check error message
22
+ assert_equal 'No dst found in deployment configuration', error.message
25
23
  end
26
24
 
27
25
  def test_run_with_erroneous_dst
28
- if_have 'systemu' do
29
- # Create deployer
30
- rsync = Nanoc::Extra::Deployers::Rsync.new(
31
- 'output/',
32
- { :dst => 'asdf/' })
33
-
34
- # Mock run_shell_cmd
35
- def rsync.run_shell_cmd(args)
36
- @shell_cms_args = args
37
- end
38
-
39
- # Try running
40
- error = assert_raises(RuntimeError) do
41
- rsync.run
42
- end
43
-
44
- # Check error message
45
- assert_equal 'dst requires no trailing slash', error.message
26
+ # Create deployer
27
+ rsync = Nanoc::Extra::Deployers::Rsync.new(
28
+ 'output/',
29
+ { :dst => 'asdf/' })
30
+
31
+ # Mock run_shell_cmd
32
+ def rsync.run_shell_cmd(args)
33
+ @shell_cms_args = args
46
34
  end
47
- end
48
35
 
49
- def test_run_everything_okay
50
- if_have 'systemu' do
51
- # Create deployer
52
- rsync = Nanoc::Extra::Deployers::Rsync.new(
53
- 'output',
54
- { :dst => 'asdf' })
55
-
56
- # Mock run_shell_cmd
57
- def rsync.run_shell_cmd(args)
58
- @shell_cms_args = args
59
- end
60
-
61
- # Run
36
+ # Try running
37
+ error = assert_raises(RuntimeError) do
62
38
  rsync.run
39
+ end
40
+
41
+ # Check error message
42
+ assert_equal 'dst requires no trailing slash', error.message
43
+ end
63
44
 
64
- # Check args
65
- opts = Nanoc::Extra::Deployers::Rsync::DEFAULT_OPTIONS
66
- assert_equal(
67
- [ 'rsync', opts, 'output/', 'asdf' ].flatten,
68
- rsync.instance_eval { @shell_cms_args }
69
- )
45
+ def test_run_everything_okay
46
+ # Create deployer
47
+ rsync = Nanoc::Extra::Deployers::Rsync.new(
48
+ 'output',
49
+ { :dst => 'asdf' })
50
+
51
+ # Mock run_shell_cmd
52
+ def rsync.run_shell_cmd(args)
53
+ @shell_cms_args = args
70
54
  end
55
+
56
+ # Run
57
+ rsync.run
58
+
59
+ # Check args
60
+ opts = Nanoc::Extra::Deployers::Rsync::DEFAULT_OPTIONS
61
+ assert_equal(
62
+ [ 'rsync', opts, 'output/', 'asdf' ].flatten,
63
+ rsync.instance_eval { @shell_cms_args }
64
+ )
71
65
  end
72
66
 
73
67
  def test_run_everything_okay_dry
74
- if_have 'systemu' do
75
- # Create deployer
76
- rsync = Nanoc::Extra::Deployers::Rsync.new(
77
- 'output',
78
- { :dst => 'asdf' },
79
- :dry_run => true)
80
-
81
- # Mock run_shell_cmd
82
- def rsync.run_shell_cmd(args)
83
- @shell_cms_args = args
84
- end
85
-
86
- # Run
87
- rsync.run
88
-
89
- # Check args
90
- opts = Nanoc::Extra::Deployers::Rsync::DEFAULT_OPTIONS
91
- assert_equal(
92
- [ 'echo', 'rsync', opts, 'output/', 'asdf' ].flatten,
93
- rsync.instance_eval { @shell_cms_args }
94
- )
68
+ # Create deployer
69
+ rsync = Nanoc::Extra::Deployers::Rsync.new(
70
+ 'output',
71
+ { :dst => 'asdf' },
72
+ :dry_run => true)
73
+
74
+ # Mock run_shell_cmd
75
+ def rsync.run_shell_cmd(args)
76
+ @shell_cms_args = args
95
77
  end
78
+
79
+ # Run
80
+ rsync.run
81
+
82
+ # Check args
83
+ opts = Nanoc::Extra::Deployers::Rsync::DEFAULT_OPTIONS
84
+ assert_equal(
85
+ [ 'echo', 'rsync', opts, 'output/', 'asdf' ].flatten,
86
+ rsync.instance_eval { @shell_cms_args }
87
+ )
96
88
  end
97
89
 
98
90
  end
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ class Nanoc::Extra::PiperTest < Nanoc::TestCase
4
+
5
+ def test_basic
6
+ stdout = StringIO.new
7
+ stderr = StringIO.new
8
+
9
+ cmd = %w( ls -l )
10
+
11
+ File.open('foo.txt', 'w') { |io| io.write('hi') }
12
+ File.open('bar.txt', 'w') { |io| io.write('ho') }
13
+
14
+ piper = Nanoc::Extra::Piper.new(:stdout => stdout, :stderr => stderr)
15
+ piper.run(cmd, nil)
16
+
17
+ assert_match(/foo\.txt/, stdout.string)
18
+ assert_match(/bar\.txt/, stdout.string)
19
+ assert stderr.string.empty?
20
+ end
21
+
22
+ def test_stdin
23
+ stdout = StringIO.new
24
+ stderr = StringIO.new
25
+
26
+ input = 'Hello World!'
27
+ cmd = %w( cat )
28
+
29
+ piper = Nanoc::Extra::Piper.new(:stdout => stdout, :stderr => stderr)
30
+ piper.run(cmd, input)
31
+
32
+ assert_equal(input, stdout.string)
33
+ assert_equal('', stderr.string)
34
+ end
35
+
36
+ end
@@ -3,16 +3,14 @@
3
3
  class Nanoc::Filters::AsciiDocTest < Nanoc::TestCase
4
4
 
5
5
  def test_filter
6
- if_have 'systemu' do
7
- skip_unless_have_command "asciidoc"
6
+ skip_unless_have_command "asciidoc"
8
7
 
9
- # Create filter
10
- filter = ::Nanoc::Filters::AsciiDoc.new
8
+ # Create filter
9
+ filter = ::Nanoc::Filters::AsciiDoc.new
11
10
 
12
- # Run filter
13
- result = filter.setup_and_run("== Blah blah")
14
- assert_match %r{<h2 id="_blah_blah">Blah blah</h2>}, result
15
- end
11
+ # Run filter
12
+ result = filter.setup_and_run("== Blah blah")
13
+ assert_match %r{<h2 id="_blah_blah">Blah blah</h2>}, result
16
14
  end
17
15
 
18
16
  end
@@ -35,6 +35,16 @@ class Nanoc::Filters::ColorizeSyntaxTest < Nanoc::TestCase
35
35
  end
36
36
  end
37
37
 
38
+ def test_with_frozen_input
39
+ if_have 'nokogiri' do
40
+ input = '<pre title="moo"><code class="language-ruby"># comment</code></pre>'.freeze
41
+ input.freeze
42
+
43
+ filter = ::Nanoc::Filters::ColorizeSyntax.new
44
+ filter.setup_and_run(input, :default_colorizer => :dummy)
45
+ end
46
+ end
47
+
38
48
  def test_full_page
39
49
  if_have 'nokogiri' do
40
50
  # Create filter
@@ -121,7 +131,7 @@ EOS
121
131
  end
122
132
 
123
133
  def test_pygmentize
124
- if_have 'nokogiri', 'systemu' do
134
+ if_have 'nokogiri' do
125
135
  skip_unless_have_command "pygmentize"
126
136
 
127
137
  # Create filter
@@ -154,7 +164,7 @@ EOS
154
164
  end
155
165
 
156
166
  def test_simon_highlight
157
- if_have 'nokogiri', 'systemu' do
167
+ if_have 'nokogiri' do
158
168
  skip_unless_have_command "highlight"
159
169
 
160
170
  # Create filter
@@ -215,7 +225,7 @@ EOS
215
225
  def test_colorize_syntax_with_default_colorizer
216
226
  skip_unless_have_command "pygmentize"
217
227
 
218
- if_have 'nokogiri', 'systemu' do
228
+ if_have 'nokogiri' do
219
229
  # Create filter
220
230
  filter = ::Nanoc::Filters::ColorizeSyntax.new
221
231
 
@@ -230,7 +240,7 @@ EOS
230
240
  end
231
241
 
232
242
  def test_colorize_syntax_with_missing_executables
233
- if_have 'nokogiri', 'systemu' do
243
+ if_have 'nokogiri' do
234
244
  begin
235
245
  original_path = ENV['PATH']
236
246
  ENV['PATH'] = './blooblooblah'
@@ -8,21 +8,15 @@ class Nanoc::GemTest < Nanoc::TestCase
8
8
  end
9
9
 
10
10
  def test_build
11
- require 'systemu'
12
-
13
11
  # Require clean environment
14
12
  Dir['nanoc-*.gem'].each { |f| FileUtils.rm(f) }
15
13
 
16
14
  # Build
17
15
  files_before = Set.new Dir['**/*']
18
- stdout = ''
19
- stderr = ''
20
- status = systemu(
21
- [ 'gem', 'build', 'nanoc.gemspec' ],
22
- 'stdin' => '',
23
- 'stdout' => stdout,
24
- 'stderr' => stderr)
25
- assert status.success?
16
+ stdout = StringIO.new
17
+ stderr = StringIO.new
18
+ piper = Nanoc::Extra::Piper.new(:stdout => stdout, :stderr => stderr)
19
+ piper.run(%w( gem build nanoc.gemspec ), nil)
26
20
  files_after = Set.new Dir['**/*']
27
21
 
28
22
  # Check new files
@@ -31,8 +25,8 @@ class Nanoc::GemTest < Nanoc::TestCase
31
25
  assert_match(/^nanoc-.*\.gem$/, diff.to_a[0])
32
26
 
33
27
  # Check output
34
- assert_match(/Successfully built RubyGem\s+Name: nanoc\s+Version: .*\s+File: nanoc-.*\.gem\s+/, stdout)
35
- assert_equal '', stderr
28
+ assert_match(/Successfully built RubyGem\s+Name: nanoc\s+Version: .*\s+File: nanoc-.*\.gem\s+/, stdout.string)
29
+ assert_equal '', stderr.string
36
30
  ensure
37
31
  Dir['nanoc-*.gem'].each { |f| FileUtils.rm(f) }
38
32
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.8
4
+ version: 3.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-22 00:00:00.000000000 Z
11
+ date: 2014-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.5'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.5'
41
41
  description: nanoc is a simple but very flexible static site generator written in
@@ -165,6 +165,7 @@ files:
165
165
  - lib/nanoc/extra/file_proxy.rb
166
166
  - lib/nanoc/extra/filesystem_tools.rb
167
167
  - lib/nanoc/extra/link_collector.rb
168
+ - lib/nanoc/extra/piper.rb
168
169
  - lib/nanoc/extra/pruner.rb
169
170
  - lib/nanoc/extra/validators.rb
170
171
  - lib/nanoc/extra/validators/links.rb
@@ -255,6 +256,7 @@ files:
255
256
  - test/base/test_rule.rb
256
257
  - test/base/test_rule_context.rb
257
258
  - test/base/test_site.rb
259
+ - test/base/test_store.rb
258
260
  - test/cli/commands/test_check.rb
259
261
  - test/cli/commands/test_compile.rb
260
262
  - test/cli/commands/test_create_item.rb
@@ -292,6 +294,7 @@ files:
292
294
  - test/extra/test_file_proxy.rb
293
295
  - test/extra/test_filesystem_tools.rb
294
296
  - test/extra/test_link_collector.rb
297
+ - test/extra/test_piper.rb
295
298
  - test/extra/test_vcs.rb
296
299
  - test/extra/validators/test_links.rb
297
300
  - test/extra/validators/test_w3c.rb
@@ -343,18 +346,18 @@ licenses:
343
346
  metadata: {}
344
347
  post_install_message:
345
348
  rdoc_options:
346
- - --main
349
+ - "--main"
347
350
  - README.md
348
351
  require_paths:
349
352
  - lib
350
353
  required_ruby_version: !ruby/object:Gem::Requirement
351
354
  requirements:
352
- - - ! '>='
355
+ - - ">="
353
356
  - !ruby/object:Gem::Version
354
357
  version: '0'
355
358
  required_rubygems_version: !ruby/object:Gem::Requirement
356
359
  requirements:
357
- - - ! '>='
360
+ - - ">="
358
361
  - !ruby/object:Gem::Version
359
362
  version: '0'
360
363
  requirements: []