nanoc 4.1.3 → 4.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 012ea17572e6f5ce450f61ab43b4d403b0c59d5e
4
- data.tar.gz: f9d48bcf89fe052d434b9c03fb34b87164f2a04b
3
+ metadata.gz: ec5f1b744e1d1a155a6b2d1dc1d603874d2deb57
4
+ data.tar.gz: eb4aa79555b133ab4ce28878aefb88b1644d3d04
5
5
  SHA512:
6
- metadata.gz: ec0466efe5a5c93b9b019da0d5d59b504bef75a08916ab12856998818e7f762303be85253295bbf788b455a6b45b4086b4c2ea940ce7c94f51e946706f618a41
7
- data.tar.gz: 77af4db8c9cd838a30774bb7f599fae40fd147010f626a8b71c22dfc8ed6f2486de228157f765c03746115968234a9e7d2a0c85deada56c13adbd3795c992f47
6
+ metadata.gz: e144b54d2dd138af0e36e90274d2c4d20350aae065496aaeaf5a0e39f3a8506c7235adc1c0325dfc94d0e835657359d9bd883536665de12dabc6b36626b90654
7
+ data.tar.gz: f1192638a1b3c2182c6c21911f54de5a9f0fa8c17e2ee99adbb683e55e7f7847aab1e34dec1f425a73d3a016035507eb3206b90aca1513203bb3cc13e94a78f6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nanoc (4.1.3)
4
+ nanoc (4.1.4)
5
5
  cri (~> 2.3)
6
6
 
7
7
  GEM
@@ -184,7 +184,7 @@ GEM
184
184
  handlebars-source (~> 3.0.0)
185
185
  therubyracer (~> 0.12.1)
186
186
  handlebars-source (3.0.3)
187
- hashdiff (0.2.3)
187
+ hashdiff (0.3.0)
188
188
  http-cookie (1.0.2)
189
189
  domain_name (~> 0.5)
190
190
  inflecto (0.0.2)
@@ -194,9 +194,9 @@ GEM
194
194
  less (2.6.0)
195
195
  commonjs (~> 0.2.7)
196
196
  libv8 (3.16.14.13)
197
- listen (3.0.5)
197
+ listen (3.0.6)
198
198
  rb-fsevent (>= 0.9.3)
199
- rb-inotify (>= 0.9)
199
+ rb-inotify (>= 0.9.7)
200
200
  lumberjack (1.0.10)
201
201
  markaby (0.8.0)
202
202
  builder
@@ -210,7 +210,7 @@ GEM
210
210
  metaclass (~> 0.0.1)
211
211
  multi_json (1.11.2)
212
212
  mustache (1.0.2)
213
- nenv (0.2.0)
213
+ nenv (0.3.0)
214
214
  netrc (0.11.0)
215
215
  nokogiri (1.6.7.2)
216
216
  mini_portile2 (~> 2.0.0.rc2)
@@ -218,7 +218,7 @@ GEM
218
218
  nenv (~> 0.1)
219
219
  shellany (~> 0.0)
220
220
  pandoc-ruby (1.0.0)
221
- parser (2.3.0.2)
221
+ parser (2.3.0.5)
222
222
  ast (~> 2.2)
223
223
  posix-spawn (0.3.11)
224
224
  powerpack (0.1.1)
@@ -234,14 +234,15 @@ GEM
234
234
  rainpress (1.0)
235
235
  rake (10.5.0)
236
236
  rb-fsevent (0.9.7)
237
- rb-inotify (0.9.5)
237
+ rb-inotify (0.9.7)
238
238
  ffi (>= 0.5.0)
239
239
  rbvmomi (1.8.2)
240
240
  builder
241
241
  nokogiri (>= 1.4.1)
242
242
  trollop
243
243
  rdiscount (2.1.8)
244
- rdoc (4.2.1)
244
+ rdoc (4.2.2)
245
+ json (~> 1.4)
245
246
  redcarpet (3.3.4)
246
247
  ref (2.0.0)
247
248
  rest-client (1.8.0)
@@ -262,17 +263,18 @@ GEM
262
263
  diff-lcs (>= 1.2.0, < 2.0)
263
264
  rspec-support (~> 3.4.0)
264
265
  rspec-support (3.4.1)
265
- rubocop (0.36.0)
266
- parser (>= 2.3.0.0, < 3.0)
266
+ rubocop (0.37.2)
267
+ parser (>= 2.3.0.4, < 3.0)
267
268
  powerpack (~> 0.1)
268
269
  rainbow (>= 1.99.1, < 3.0)
269
270
  ruby-progressbar (~> 1.7)
271
+ unicode-display_width (~> 0.3)
270
272
  ruby-progressbar (1.7.5)
271
273
  rubypants (0.2.0)
272
274
  safe_yaml (1.0.4)
273
275
  sass (3.4.21)
274
276
  shellany (0.0.1)
275
- simplecov (0.11.1)
277
+ simplecov (0.11.2)
276
278
  docile (~> 1.1.0)
277
279
  json (~> 1.8)
278
280
  simplecov-html (~> 0.10.0)
@@ -298,7 +300,8 @@ GEM
298
300
  json (>= 1.8.0)
299
301
  unf (0.1.4)
300
302
  unf_ext
301
- unf_ext (0.0.7.1)
303
+ unf_ext (0.0.7.2)
304
+ unicode-display_width (0.3.1)
302
305
  vcr (3.0.1)
303
306
  w3c_validators (1.2)
304
307
  json
data/NEWS.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.1.4 (2016-02-13)
4
+
5
+ Fixes:
6
+
7
+ * Added missing `Configuration#key?` method (#815, #820)
8
+ * Made output diff use correct snapshot rather than `:last` (#813, #814)
9
+
10
+ Enhancements:
11
+
12
+ * Sped up item resolution in Sass filter (#821)
13
+ * Made `#link_to` more resilient to unsupported argument types (#816, #819)
14
+
3
15
  ## 4.1.3 (2016-01-30)
4
16
 
5
17
  Fixes:
@@ -88,7 +88,7 @@ module Nanoc
88
88
  # Returns the required libraries for this filter.
89
89
  # @return [Enumerable<String>] This filter’s list of library names that are required
90
90
  def requires(*requires)
91
- if requires.size > 0
91
+ if requires.any?
92
92
  @requires = requires
93
93
  else
94
94
  @requires || []
@@ -51,6 +51,10 @@ module Nanoc::Int
51
51
  @wrapped
52
52
  end
53
53
 
54
+ def key?(key)
55
+ @wrapped.key?(key)
56
+ end
57
+
54
58
  def [](key)
55
59
  @wrapped[key]
56
60
  end
@@ -124,7 +124,7 @@ module Nanoc
124
124
 
125
125
  extname = File.extname(@string)
126
126
 
127
- if extname.size > 0
127
+ if !extname.empty?
128
128
  @string[0..-extname.size - 1]
129
129
  else
130
130
  @string
@@ -144,7 +144,7 @@ module Nanoc
144
144
  # @return [String]
145
145
  def without_exts
146
146
  extname = exts.join('.')
147
- if extname.size > 0
147
+ if !extname.empty?
148
148
  @string[0..-extname.size - 2]
149
149
  else
150
150
  @string
@@ -70,7 +70,7 @@ module Nanoc::CLI::Commands
70
70
  unless rep.binary?
71
71
  new_contents = File.file?(path) ? File.read(path) : nil
72
72
  if old_contents[rep] && new_contents
73
- generate_diff_for(rep, old_contents[rep], new_contents)
73
+ generate_diff_for(path, old_contents[rep], new_contents)
74
74
  end
75
75
  old_contents.delete(rep)
76
76
  end
@@ -95,14 +95,14 @@ module Nanoc::CLI::Commands
95
95
  @diff_threads.each(&:join)
96
96
  end
97
97
 
98
- def generate_diff_for(rep, old_content, new_content)
98
+ def generate_diff_for(path, old_content, new_content)
99
99
  return if old_content == new_content
100
100
 
101
101
  @diff_threads << Thread.new do
102
102
  # Generate diff
103
103
  diff = diff_strings(old_content, new_content)
104
- diff.sub!(/^--- .*/, '--- ' + rep.raw_path)
105
- diff.sub!(/^\+\+\+ .*/, '+++ ' + rep.raw_path)
104
+ diff.sub!(/^--- .*/, '--- ' + path)
105
+ diff.sub!(/^\+\+\+ .*/, '+++ ' + path)
106
106
 
107
107
  # Write diff
108
108
  @diff_lock.synchronize do
@@ -10,7 +10,7 @@ module Nanoc::CLI::Commands
10
10
  class ShowPlugins < ::Nanoc::CLI::CommandRunner
11
11
  def run
12
12
  # Check arguments
13
- if arguments.size != 0
13
+ if arguments.any?
14
14
  raise Nanoc::Int::Errors::GenericTrivial, "usage: #{command.usage}"
15
15
  end
16
16
 
@@ -4,14 +4,6 @@ module Nanoc::Extra::Checking::Checks
4
4
  def run
5
5
  require 'set'
6
6
 
7
- item_rep_paths =
8
- Set.new(
9
- @items
10
- .flat_map(&:reps)
11
- .map(&:unwrap)
12
- .flat_map(&:raw_paths)
13
- .flat_map(&:values))
14
-
15
7
  output_filenames.each do |f|
16
8
  next if pruner.filename_excluded?(f)
17
9
  next if item_rep_paths.include?(f)
@@ -24,6 +16,16 @@ module Nanoc::Extra::Checking::Checks
24
16
 
25
17
  protected
26
18
 
19
+ def item_rep_paths
20
+ @item_rep_paths ||=
21
+ Set.new(
22
+ @items
23
+ .flat_map(&:reps)
24
+ .map(&:unwrap)
25
+ .flat_map(&:raw_paths)
26
+ .flat_map(&:values))
27
+ end
28
+
27
29
  def pruner
28
30
  exclude_config = @config.fetch(:prune, {}).fetch(:exclude, [])
29
31
  @pruner ||= Nanoc::Extra::Pruner.new(@site, exclude: exclude_config)
@@ -18,11 +18,24 @@ module Nanoc::Filters
18
18
  engine.render
19
19
  end
20
20
 
21
+ def self.item_filename_map_for_site(site, items)
22
+ @item_filename_map ||= {}
23
+ @item_filename_map[site] ||=
24
+ {}.tap do |map|
25
+ items.each do |item|
26
+ if item.raw_filename
27
+ path = Pathname.new(item.raw_filename).realpath.to_s
28
+ map[path] = item
29
+ end
30
+ end
31
+ end
32
+ end
33
+
21
34
  def imported_filename_to_item(filename)
22
- @items.find do |i|
23
- i.raw_filename &&
24
- Pathname.new(i.raw_filename).realpath == Pathname.new(filename).realpath
25
- end
35
+ realpath = Pathname.new(filename).realpath.to_s
36
+
37
+ map = self.class.item_filename_map_for_site(@site, @items)
38
+ map[realpath]
26
39
  end
27
40
  end
28
41
  end
@@ -43,12 +43,16 @@ module Nanoc::Helpers
43
43
  # # => '<a title="My super cool blog" href="/blog/">Blog</a>'
44
44
  def link_to(text, target, attributes = {})
45
45
  # Find path
46
- if target.is_a?(String)
47
- path = target
48
- else
49
- path = target.path
50
- raise "Cannot create a link to #{target.inspect} because this target is not outputted (its routing rule returns nil)" if path.nil?
51
- end
46
+ path =
47
+ case target
48
+ when String
49
+ target
50
+ when Nanoc::ItemWithRepsView, Nanoc::ItemWithoutRepsView, Nanoc::ItemRepView
51
+ raise "Cannot create a link to #{target.inspect} because this target is not outputted (its routing rule returns nil)" if target.path.nil?
52
+ target.path
53
+ else
54
+ raise ArgumentError, "Cannot link to #{target.inspect} (expected a string or an item, not a #{target.class.name})"
55
+ end
52
56
 
53
57
  # Join attributes
54
58
  attributes = attributes.reduce('') do |memo, (key, value)|
data/lib/nanoc/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Nanoc
2
2
  # The current Nanoc version.
3
- VERSION = '4.1.3'.freeze
3
+ VERSION = '4.1.4'.freeze
4
4
  end
@@ -2,34 +2,39 @@ class Nanoc::Helpers::LinkToTest < Nanoc::TestCase
2
2
  include Nanoc::Helpers::LinkTo
3
3
 
4
4
  def test_link_to_with_path
5
- # Check
6
5
  assert_equal(
7
6
  '<a href="/foo/">Foo</a>',
8
7
  link_to('Foo', '/foo/'),
9
8
  )
10
9
  end
11
10
 
12
- def test_link_to_with_rep
13
- # Create rep
14
- rep = mock
15
- rep.stubs(:path).returns('/bar/')
11
+ def test_link_to_with_item_without_reps_view
12
+ target = Nanoc::ItemWithoutRepsView.new(mock, {})
13
+ target.stubs(:path).returns('/bar/')
16
14
 
17
- # Check
18
15
  assert_equal(
19
16
  '<a href="/bar/">Bar</a>',
20
- link_to('Bar', rep),
17
+ link_to('Bar', target),
21
18
  )
22
19
  end
23
20
 
24
- def test_link_to_with_item
25
- # Create rep
26
- item = mock
27
- item.stubs(:path).returns('/bar/')
21
+ def test_link_to_with_item_with_reps_view
22
+ target = Nanoc::ItemWithRepsView.new(mock, {})
23
+ target.stubs(:path).returns('/bar/')
24
+
25
+ assert_equal(
26
+ '<a href="/bar/">Bar</a>',
27
+ link_to('Bar', target),
28
+ )
29
+ end
30
+
31
+ def test_link_to_with_item_rep_view
32
+ target = Nanoc::ItemRepView.new(mock, {})
33
+ target.stubs(:path).returns('/bar/')
28
34
 
29
- # Check
30
35
  assert_equal(
31
36
  '<a href="/bar/">Bar</a>',
32
- link_to('Bar', item),
37
+ link_to('Bar', target),
33
38
  )
34
39
  end
35
40
 
@@ -50,13 +55,11 @@ class Nanoc::Helpers::LinkToTest < Nanoc::TestCase
50
55
  end
51
56
 
52
57
  def test_link_to_to_nil_item_or_item_rep
53
- obj = Object.new
54
- def obj.path
55
- nil
56
- end
58
+ target = Nanoc::ItemRepView.new(mock, {})
59
+ target.stubs(:path).returns(nil)
57
60
 
58
61
  assert_raises RuntimeError do
59
- link_to('Some Text', obj)
62
+ link_to('Some Text', target)
60
63
  end
61
64
  end
62
65
 
@@ -208,14 +211,18 @@ class Nanoc::Helpers::LinkToTest < Nanoc::TestCase
208
211
  YARD.parse(LIB_DIR + '/nanoc/helpers/link_to.rb')
209
212
 
210
213
  # Mock
211
- @items = [mock, mock, mock]
214
+ @items = [
215
+ Nanoc::ItemRepView.new(mock, {}),
216
+ Nanoc::ItemRepView.new(mock, {}),
217
+ Nanoc::ItemRepView.new(mock, {}),
218
+ ]
212
219
  @items[0].stubs(:identifier).returns('/about/')
213
220
  @items[0].stubs(:path).returns('/about.html')
214
221
  @items[1].stubs(:identifier).returns('/software/')
215
222
  @items[1].stubs(:path).returns('/software.html')
216
223
  @items[2].stubs(:identifier).returns('/software/nanoc/')
217
224
  @items[2].stubs(:path).returns('/software/nanoc.html')
218
- about_rep_vcard = mock
225
+ about_rep_vcard = Nanoc::ItemRepView.new(mock, {})
219
226
  about_rep_vcard.stubs(:path).returns('/about.vcf')
220
227
  @items[0].stubs(:rep).with(:vcard).returns(about_rep_vcard)
221
228
 
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.1.3
4
+ version: 4.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-30 00:00:00.000000000 Z
11
+ date: 2016-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -378,7 +378,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
378
378
  version: '0'
379
379
  requirements: []
380
380
  rubyforge_project:
381
- rubygems_version: 2.5.1
381
+ rubygems_version: 2.5.2
382
382
  signing_key:
383
383
  specification_version: 4
384
384
  summary: A static-site generator with a focus on flexibility.