nanoc 4.7.8 → 4.7.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd1bb8411c769f4fece915bf9569b5af2a1a1424
4
- data.tar.gz: 23b8e4dfd52b52fc012c2ea22d528d294c3971bd
3
+ metadata.gz: ecb0f82b4846a49ddfdb86ced975609223aeb598
4
+ data.tar.gz: b9554789ff878f63f7b42fe9d42576c105d93c95
5
5
  SHA512:
6
- metadata.gz: 862cb54cefa14a2312bfd417f3d3d744afe2b27740ed57bfb1c2b51c5eaabbe66cdb3130b5b10ea758dea3045a2ac7a6d3fa6caff10c358a76e9af2c1189a8aa
7
- data.tar.gz: d33204921451b9e6cffa130bbc30fe02e6f1ea88d01854d8c6910d4e07e85fddea6a25448ff84c05bbd6b6407cae2eb7c4a8adbac3c7e4b19a1490a795c12e69
6
+ metadata.gz: 6ef8450a139b74d4eb3cfe84f5444c568d49e18046eddb5412f6c687a7aa22f64049d023a4da5b9406f677095e5d9fd0c94c700679ff9337cfdc1a24846f480d
7
+ data.tar.gz: 68b1f8b2fc52b50f2074b21271c45539b16f4db46b35c5fdf2bbee28dd0ae57ed31a975314fe2d48427eb8f2b815bb16eb4422b335a9397e68b41ed4e29394c1
data/Gemfile CHANGED
@@ -59,7 +59,7 @@ group :plugins do
59
59
  gem 'rouge'
60
60
  gem 'rubypants'
61
61
  gem 'sass'
62
- gem 'slim'
62
+ gem 'slim', '~> 3.0'
63
63
  gem 'therubyracer', '~> 0.12'
64
64
  gem 'typogruby'
65
65
  gem 'uglifier'
data/Gemfile.lock CHANGED
@@ -1,6 +1,6 @@
1
1
  GIT
2
2
  remote: https://github.com/bbatsov/rubocop.git
3
- revision: 9168e82c449bf275b4ce587ac01efff25bf80cc2
3
+ revision: cc04647e2b786ab5ef8337206f3dd71c0d843354
4
4
  specs:
5
5
  rubocop (0.48.1)
6
6
  parallel (~> 1.10)
@@ -13,7 +13,7 @@ GIT
13
13
  PATH
14
14
  remote: .
15
15
  specs:
16
- nanoc (4.7.7)
16
+ nanoc (4.7.9)
17
17
  cri (~> 2.8)
18
18
  ddplugin (~> 1.0)
19
19
  hamster (~> 3.0)
@@ -60,8 +60,8 @@ GEM
60
60
  compass-import-once (1.0.5)
61
61
  sass (>= 3.2, < 3.5)
62
62
  concurrent-ruby (1.0.5)
63
- contracts (0.15.0)
64
- coveralls (0.8.20)
63
+ contracts (0.16.0)
64
+ coveralls (0.8.21)
65
65
  json (>= 1.8, < 3)
66
66
  simplecov (~> 0.14.1)
67
67
  term-ansicolor (~> 1.3)
@@ -132,10 +132,11 @@ GEM
132
132
  fog-json (~> 1.0)
133
133
  fog-xml (~> 0.1)
134
134
  ipaddress (~> 0.8)
135
- fog-core (1.43.0)
135
+ fog-core (1.44.0)
136
136
  builder
137
137
  excon (~> 0.49)
138
138
  formatador (~> 0.2)
139
+ xmlrpc
139
140
  fog-dynect (0.0.3)
140
141
  fog-core
141
142
  fog-json
@@ -229,8 +230,8 @@ GEM
229
230
  handlebars (0.8.0)
230
231
  handlebars-source (~> 4.0.5)
231
232
  therubyracer (~> 0.12.1)
232
- handlebars-source (4.0.6)
233
- hashdiff (0.3.2)
233
+ handlebars-source (4.0.7)
234
+ hashdiff (0.3.4)
234
235
  inflecto (0.0.2)
235
236
  ipaddress (0.8.3)
236
237
  json (2.1.0)
@@ -288,7 +289,7 @@ GEM
288
289
  rb-fsevent (0.9.8)
289
290
  rb-inotify (0.9.8)
290
291
  ffi (>= 0.5.0)
291
- rbvmomi (1.11.0)
292
+ rbvmomi (1.11.2)
292
293
  builder (~> 3.0)
293
294
  json (>= 1.8)
294
295
  nokogiri (~> 1.5)
@@ -355,7 +356,8 @@ GEM
355
356
  crack (>= 0.3.2)
356
357
  hashdiff
357
358
  xml-simple (1.1.5)
358
- yard (0.9.8)
359
+ xmlrpc (0.3.0)
360
+ yard (0.9.9)
359
361
  yard-contracts (0.1.5)
360
362
  contracts (~> 0.7)
361
363
  yard (~> 0.8)
@@ -416,7 +418,7 @@ DEPENDENCIES
416
418
  rubypants
417
419
  sass
418
420
  simplecov
419
- slim
421
+ slim (~> 3.0)
420
422
  therubyracer (~> 0.12)
421
423
  timecop
422
424
  typogruby
data/NEWS.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.7.9 (2017-05-01)
4
+
5
+ Fixes:
6
+
7
+ * Fixed character set handling of code snippets (#1171, #1174)
8
+
9
+ Enhancements:
10
+
11
+ * Added `xml:base` support (#1172, #1173) [Chris Burkhardt]
12
+
13
+ This release drops support for Ruby 2.2, as it is no longer maintained.
14
+
3
15
  ## 4.7.8 (2017-04-22)
4
16
 
5
17
  Fixes:
data/README.md CHANGED
@@ -19,4 +19,4 @@ Contributions are greatly appreciated! Consult the [Development guidelines](http
19
19
 
20
20
  Many thanks to everyone who has contributed to Nanoc in one way or another:
21
21
 
22
- Ale Muñoz, Alexander Mankuta, Andy Drop, Arnau Siches, Ben Armston, Bil Bas, Brian Candler, Bruno Dufour, Cédric Boutillier, Chris Chapman, Chris Eppstein, Christian Plessl, Colin Barrett, Colin Seymour, Croath Liu, Damien Pollet, Dan Callahan, Daniel Hofstetter, Daniel Mendler, Daniel Wollschlaeger, David Alexander, David Everitt, Denis Defreyne, Dennis Sutch, Devon Luke Buchanan, Dmitry Bilunov, Eric Sunshine, Erik Hollensbe, Fabian Buch, Felix Hanley, Garen Torikian, Go Maeda, Grégory Karékinian, Gregory Pakosz, Guilherme Garnier, Hugo Peixoto, Jack Chu, Jake Benilov, Jan M. Faber, Jasper Van der Jeugt, Jeff Forcier, Jim Mendenhall, John Nishinaga, Justin Clift, Justin Hileman, Kevin Lynagh, Lorin Werthen, Louis T., Lucas Vuotto, Mathias Bynens, Matt Keveney, Matthew Frazier, Matthias Beyer, Matthias Reitinger, Matthias Vallentin, Micha Rosenbaum, Michal Cichra, Michal Papis, Mike Pennisi, Nelson Chen, Nicky Peeters, Nikhil Marathe, Oliver Byford, Paul Boone, Peter Aronoff, Raphael von der Grün, Rémi Barraquand, Remko Tronçon, Riley Goodside, Ruben Verborgh, Scott Vokes, Šime Ramov, Simon South, Spencer Whitt, Stanley Rost, Starr Horne, Stefan Bühler, Stuart Montgomery, Takashi Uchibe, Toon Willems, Tuomas Kareinen, Ursula Kallio, Vincent Driessen, Vlatko Kosturjak, whitequark, Xavier Shay, Yannick Ihmels, Zaiste de Grengolada
22
+ Ale Muñoz, Alexander Mankuta, Andy Drop, Arnau Siches, Ben Armston, Bil Bas, Brian Candler, Bruno Dufour, Cédric Boutillier, Chris Burkhardt, Chris Chapman, Chris Eppstein, Christian Plessl, Colin Barrett, Colin Seymour, Croath Liu, Damien Pollet, Dan Callahan, Daniel Hofstetter, Daniel Mendler, Daniel Wollschlaeger, David Alexander, David Everitt, Denis Defreyne, Dennis Sutch, Devon Luke Buchanan, Dmitry Bilunov, Eric Sunshine, Erik Hollensbe, Fabian Buch, Felix Hanley, Garen Torikian, Go Maeda, Grégory Karékinian, Gregory Pakosz, Guilherme Garnier, Hugo Peixoto, Jack Chu, Jake Benilov, Jan M. Faber, Jasper Van der Jeugt, Jeff Forcier, Jim Mendenhall, John Nishinaga, Justin Clift, Justin Hileman, Kevin Lynagh, Lorin Werthen, Louis T., Lucas Vuotto, Mathias Bynens, Matt Keveney, Matthew Frazier, Matthias Beyer, Matthias Reitinger, Matthias Vallentin, Micha Rosenbaum, Michal Cichra, Michal Papis, Mike Pennisi, Nelson Chen, Nicky Peeters, Nikhil Marathe, Oliver Byford, Paul Boone, Peter Aronoff, Raphael von der Grün, Rémi Barraquand, Remko Tronçon, Riley Goodside, Ruben Verborgh, Scott Vokes, Šime Ramov, Simon South, Spencer Whitt, Stanley Rost, Starr Horne, Stefan Bühler, Stuart Montgomery, Takashi Uchibe, Toon Willems, Tuomas Kareinen, Ursula Kallio, Vincent Driessen, Vlatko Kosturjak, whitequark, Xavier Shay, Yannick Ihmels, Zaiste de Grengolada
@@ -1,11 +1,6 @@
1
1
  module Nanoc::Int
2
2
  # @api private
3
3
  class Item < ::Nanoc::Int::Document
4
- # Returns an object that can be used for uniquely identifying objects.
5
- #
6
- # @api private
7
- #
8
- # @return [Object] An unique reference to this object
9
4
  def reference
10
5
  [:item, identifier.to_s]
11
6
  end
@@ -72,11 +72,31 @@ module Nanoc::Int
72
72
  config[:lib_dirs].flat_map do |lib|
73
73
  Dir["#{lib}/**/*.rb"].sort.map do |filename|
74
74
  Nanoc::Int::CodeSnippet.new(
75
- File.read(filename),
75
+ read_code_snippet_contents(filename),
76
76
  filename,
77
77
  )
78
78
  end
79
79
  end
80
80
  end
81
+
82
+ ENCODING_REGEX = /\A#\s+(-\*-\s+)?(en)?coding: (?<encoding>[^\s]+)(\s+-\*-\s*)?\n{0,2}/
83
+
84
+ def encoding_from_magic_comment(raw)
85
+ match = ENCODING_REGEX.match(raw)
86
+ match ? match['encoding'] : nil
87
+ end
88
+
89
+ def read_code_snippet_contents(filename)
90
+ raw = File.read(filename, encoding: 'ASCII-8BIT')
91
+
92
+ enc = encoding_from_magic_comment(raw)
93
+ if enc
94
+ raw = raw.force_encoding(enc).encode('UTF-8').sub(ENCODING_REGEX, '')
95
+ else
96
+ raw.force_encoding('UTF-8')
97
+ end
98
+
99
+ raw
100
+ end
81
101
  end
82
102
  end
@@ -1,17 +1,19 @@
1
1
  module Nanoc::Int::OutdatednessRules
2
2
  class AttributesModified < Nanoc::Int::OutdatednessRule
3
- extend Nanoc::Int::Memoization
4
-
5
3
  include Nanoc::Int::ContractsSupport
6
4
 
7
5
  affects_props :attributes, :compiled_content
8
6
 
9
7
  contract C::Or[Nanoc::Int::ItemRep, Nanoc::Int::Item, Nanoc::Int::Layout], C::Named['Nanoc::Int::OutdatednessChecker'] => C::Maybe[Nanoc::Int::OutdatednessReasons::Generic]
10
- memoized def apply(obj, outdatedness_checker)
8
+ def apply(obj, outdatedness_checker)
11
9
  case obj
12
10
  when Nanoc::Int::ItemRep
13
11
  apply(obj.item, outdatedness_checker)
14
12
  when Nanoc::Int::Item, Nanoc::Int::Layout
13
+ if outdatedness_checker.checksum_store[obj] == outdatedness_checker.checksums.checksum_for(obj)
14
+ return nil
15
+ end
16
+
15
17
  old_checksums = outdatedness_checker.checksum_store.attributes_checksum_for(obj)
16
18
  unless old_checksums
17
19
  return Nanoc::Int::OutdatednessReasons::AttributesModified.new(true)
@@ -431,24 +431,24 @@ module Nanoc::DataSources
431
431
  raise Errors::FileUnreadable.new(filename, e)
432
432
  end
433
433
 
434
- # Fix
435
- if data.respond_to?(:encode!)
436
- if @config && @config[:encoding]
437
- original_encoding = Encoding.find(@config[:encoding])
438
- data.force_encoding(@config[:encoding])
439
- else
440
- original_encoding = data.encoding
441
- end
434
+ # Set original encoding, if any
435
+ if @config && @config[:encoding]
436
+ original_encoding = Encoding.find(@config[:encoding])
437
+ data.force_encoding(@config[:encoding])
438
+ else
439
+ original_encoding = data.encoding
440
+ end
442
441
 
443
- begin
444
- data.encode!('UTF-8')
445
- rescue
446
- raise Errors::InvalidEncoding.new(filename, original_encoding)
447
- end
442
+ # Set encoding to UTF-8
443
+ begin
444
+ data.encode!('UTF-8')
445
+ rescue
446
+ raise Errors::InvalidEncoding.new(filename, original_encoding)
447
+ end
448
448
 
449
- unless data.valid_encoding?
450
- raise Errors::InvalidEncoding.new(filename, original_encoding)
451
- end
449
+ # Verify
450
+ unless data.valid_encoding?
451
+ raise Errors::InvalidEncoding.new(filename, original_encoding)
452
452
  end
453
453
 
454
454
  # Remove UTF-8 BOM (ugly)
@@ -104,10 +104,9 @@ module Nanoc::Helpers
104
104
  end
105
105
 
106
106
  def build_for_feed(xml)
107
+ root_url = @config[:base_url] + '/'
107
108
  xml.instruct!
108
- xml.feed(xmlns: 'http://www.w3.org/2005/Atom') do
109
- root_url = @config[:base_url] + '/'
110
-
109
+ xml.feed(xmlns: 'http://www.w3.org/2005/Atom', 'xml:base' => root_url) do
111
110
  # Add primary attributes
112
111
  xml.id root_url
113
112
  xml.title title
data/lib/nanoc/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Nanoc
2
2
  # The current Nanoc version.
3
- VERSION = '4.7.8'.freeze
3
+ VERSION = '4.7.9'.freeze
4
4
  end
data/nanoc.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.rdoc_options = ['--main', 'README.md']
23
23
  s.extra_rdoc_files = ['LICENSE', 'README.md', 'NEWS.md']
24
24
 
25
- s.required_ruby_version = '>= 2.1.0'
25
+ s.required_ruby_version = '>= 2.3.0'
26
26
 
27
27
  s.add_runtime_dependency('cri', '~> 2.8')
28
28
  s.add_runtime_dependency('hamster', '~> 3.0')
@@ -211,4 +211,52 @@ describe Nanoc::Int::SiteLoader do
211
211
  end
212
212
  end
213
213
  end
214
+
215
+ describe '#code_snippets_from_config' do
216
+ subject { loader.send(:code_snippets_from_config, config) }
217
+
218
+ let(:config) { Nanoc::Int::Configuration.new.with_defaults }
219
+
220
+ before { FileUtils.mkdir_p('lib') }
221
+
222
+ context 'no explicit encoding specified' do
223
+ example do
224
+ File.write('lib/asdf.rb', 'hi 🔥', encoding: 'utf-8')
225
+ expect(subject.size).to eq(1)
226
+ expect(subject.first.data).to eq('hi 🔥')
227
+ end
228
+ end
229
+
230
+ context '# encoding: x specified' do
231
+ example do
232
+ File.write('lib/asdf.rb', "# encoding: iso-8859-1\n\nBRØKEN", encoding: 'iso-8859-1')
233
+ expect(subject.size).to eq(1)
234
+ expect(subject.first.data).to eq('BRØKEN')
235
+ end
236
+ end
237
+
238
+ context '# coding: x specified' do
239
+ example do
240
+ File.write('lib/asdf.rb', "# coding: iso-8859-1\n\nBRØKEN", encoding: 'iso-8859-1')
241
+ expect(subject.size).to eq(1)
242
+ expect(subject.first.data).to eq('BRØKEN')
243
+ end
244
+ end
245
+
246
+ context '# -*- encoding: x -*- specified' do
247
+ example do
248
+ File.write('lib/asdf.rb', "# -*- encoding: iso-8859-1 -*-\n\nBRØKEN", encoding: 'iso-8859-1')
249
+ expect(subject.size).to eq(1)
250
+ expect(subject.first.data).to eq('BRØKEN')
251
+ end
252
+ end
253
+
254
+ context '# -*- coding: x -*- specified' do
255
+ example do
256
+ File.write('lib/asdf.rb', "# -*- coding: iso-8859-1 -*-\n\nBRØKEN", encoding: 'iso-8859-1')
257
+ expect(subject.size).to eq(1)
258
+ expect(subject.first.data).to eq('BRØKEN')
259
+ end
260
+ end
261
+ end
214
262
  end
@@ -0,0 +1,55 @@
1
+ describe 'GH-1171', site: true, stdio: true do
2
+ before do
3
+ File.write('nanoc.yaml', <<EOS)
4
+ data_sources:
5
+ -
6
+ type: filesystem
7
+ encoding: utf-8
8
+ EOS
9
+ end
10
+
11
+ context 'UTF-8 code in ASCII env' do
12
+ before do
13
+ File.write('content/hi.md', '<%= ::EMOJI_🔥 %>', encoding: 'utf-8')
14
+ File.write('lib/asdf.rb', 'EMOJI_🔥 = "hot"', encoding: 'utf-8')
15
+
16
+ File.write('Rules', <<EOS)
17
+ compile '/**/*' do
18
+ filter :erb
19
+ write '/last.html'
20
+ end
21
+ EOS
22
+ end
23
+
24
+ around do |ex|
25
+ orig_encoding = Encoding.default_external
26
+ Encoding.default_external = 'ASCII'
27
+ ex.run
28
+ Encoding.default_external = orig_encoding
29
+ end
30
+
31
+ it 'does not crash' do
32
+ Nanoc::CLI.run(%w[compile])
33
+ expect(File.read('output/last.html')).to eql('hot')
34
+ end
35
+ end
36
+
37
+ context 'ISO 8859-1 code UTF-8 env' do
38
+ before do
39
+ File.write('content/hi.md', '<%= ::BRØKEN %>')
40
+ File.write('lib/asdf.rb', "# encoding: iso-8859-1\n\nBRØKEN = 1", encoding: 'ISO-8859-1')
41
+
42
+ File.write('Rules', <<EOS)
43
+ compile '/**/*' do
44
+ filter :erb
45
+ write '/last.html'
46
+ end
47
+ EOS
48
+ end
49
+
50
+ it 'detects manually specified encodings' do
51
+ Nanoc::CLI.run(%w[compile])
52
+ expect(File.read('output/last.html')).to eql('1')
53
+ end
54
+ end
55
+ end
@@ -486,12 +486,6 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
486
486
  end
487
487
 
488
488
  def test_compile_iso_8859_1_site
489
- # Check encoding
490
- unless ''.respond_to?(:encode)
491
- skip 'Test only works on 1.9.x'
492
- return
493
- end
494
-
495
489
  # Create data source
496
490
  data_source = new_data_source
497
491
 
@@ -514,12 +508,6 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
514
508
  end
515
509
 
516
510
  def test_compile_iso_8859_1_site_with_explicit_encoding
517
- # Check encoding
518
- unless ''.respond_to?(:encode)
519
- skip 'Test only works on 1.9.x'
520
- return
521
- end
522
-
523
511
  # Create data source
524
512
  data_source = new_data_source({})
525
513
  data_source.config[:encoding] = 'ISO-8859-1'
@@ -608,6 +608,27 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
608
608
  end
609
609
  end
610
610
 
611
+ def test_atom_feed_with_xml_base
612
+ if_have 'builder' do
613
+ # Mock article
614
+ @items = [mock_article]
615
+
616
+ # Mock site
617
+ @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
618
+
619
+ # Create feed item
620
+ @item = mock
621
+ @item.stubs(:[]).with(:title).returns('My Blog Or Something')
622
+ @item.stubs(:[]).with(:author_name).returns('J. Doe')
623
+ @item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
624
+ @item.stubs(:[]).with(:feed_url).returns('http://example.com/feed')
625
+
626
+ # Check
627
+ result = atom_feed
628
+ assert_match 'xml:base="http://example.com/"', result
629
+ end
630
+ end
631
+
611
632
  def test_atom_feed_with_item_without_path
612
633
  if_have 'builder' do
613
634
  # Create items
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.8
4
+ version: 4.7.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: 2017-04-22 00:00:00.000000000 Z
11
+ date: 2017-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -491,6 +491,7 @@ files:
491
491
  - spec/nanoc/regressions/gh_1130_spec.rb
492
492
  - spec/nanoc/regressions/gh_1134_spec.rb
493
493
  - spec/nanoc/regressions/gh_1145_spec.rb
494
+ - spec/nanoc/regressions/gh_1171_spec.rb
494
495
  - spec/nanoc/regressions/gh_761_spec.rb
495
496
  - spec/nanoc/regressions/gh_767_spec.rb
496
497
  - spec/nanoc/regressions/gh_769_spec.rb
@@ -640,7 +641,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
640
641
  requirements:
641
642
  - - ">="
642
643
  - !ruby/object:Gem::Version
643
- version: 2.1.0
644
+ version: 2.3.0
644
645
  required_rubygems_version: !ruby/object:Gem::Requirement
645
646
  requirements:
646
647
  - - ">="