History

Make :skip_links option work with true/false

Thibaut committed 12 years ago

Commit bf6c9001 parent 47eb7ee7 files · +20 −6Browse files

Unified · Split

7 files
  1. lib/docs/filters/core/internal_urls.rb +1 −1
  2. lib/docs/scrapers/backbone.rb +1 −1
  3. lib/docs/scrapers/coffeescript.rb +1 −1
  4. lib/docs/scrapers/less.rb +1 −1
  5. lib/docs/scrapers/lodash.rb +1 −1
  6. lib/docs/scrapers/underscore.rb +1 −1
  7. test/lib/docs/filters/core/internal_urls_test.rb +14 −0
lib/docs/filters/core/internal_urls.rb+1−1
@@ -25,7 +25,7 @@ module Docs · 24 unmodified lines
25 end25 end
26 26
27 def skip_links?27 def skip_links?
28 context[:skip_links] && context[:skip_links].call(self)28 context[:skip_links].is_a?(Proc) ? context[:skip_links].call(self) : context[:skip_links]
29 end29 end
30 30
31 def follow_links?31 def follow_links?
lib/docs/scrapers/backbone.rb+1−1
@@ -10,7 +10,7 @@ module Docs · 9 unmodified lines
10 10
11 options[:title] = 'Backbone.js'11 options[:title] = 'Backbone.js'
12 options[:container] = '.container'12 options[:container] = '.container'
13 options[:skip_links] = ->(filter) { true }13 options[:skip_links] = true
14 14
15 options[:attribution] = <<-HTML15 options[:attribution] = <<-HTML
16 &copy; 2010&ndash;2013 Jeremy Ashkenas, DocumentCloud<br>16 &copy; 2010&ndash;2013 Jeremy Ashkenas, DocumentCloud<br>
lib/docs/scrapers/coffeescript.rb+1−1
@@ -9,7 +9,7 @@ module Docs · 8 unmodified lines
9 9
10 options[:title] = 'CoffeeScript'10 options[:title] = 'CoffeeScript'
11 options[:container] = '.container'11 options[:container] = '.container'
12 options[:skip_links] = ->(filter) { true }12 options[:skip_links] = true
13 13
14 options[:attribution] = <<-HTML14 options[:attribution] = <<-HTML
15 &copy; 2009&ndash;2013 Jeremy Ashkenas<br>15 &copy; 2009&ndash;2013 Jeremy Ashkenas<br>
lib/docs/scrapers/less.rb+1−1
@@ -8,7 +8,7 @@ module Docs · 7 unmodified lines
8 8
9 options[:title] = 'LESS'9 options[:title] = 'LESS'
10 options[:container] = 'section'10 options[:container] = 'section'
11 options[:skip_links] = ->(filter) { true }11 options[:skip_links] = true
12 12
13 options[:attribution] = <<-HTML13 options[:attribution] = <<-HTML
14 &copy; 2009&ndash;2013 Alexis Sellier &amp; The Core Less Team<br>14 &copy; 2009&ndash;2013 Alexis Sellier &amp; The Core Less Team<br>
lib/docs/scrapers/lodash.rb+1−1
@@ -10,7 +10,7 @@ module Docs · 9 unmodified lines
10 10
11 options[:title] = 'Lo-Dash'11 options[:title] = 'Lo-Dash'
12 options[:container] = 'h1+div+div'12 options[:container] = 'h1+div+div'
13 options[:skip_links] = ->(filter) { true }13 options[:skip_links] = true
14 14
15 options[:attribution] = <<-HTML15 options[:attribution] = <<-HTML
16 &copy; 2012&ndash;2013 The Dojo Foundation<br>16 &copy; 2012&ndash;2013 The Dojo Foundation<br>
lib/docs/scrapers/underscore.rb+1−1
@@ -10,7 +10,7 @@ module Docs · 9 unmodified lines
10 10
11 options[:title] = 'Underscore.js'11 options[:title] = 'Underscore.js'
12 options[:container] = '#documentation'12 options[:container] = '#documentation'
13 options[:skip_links] = ->(filter) { true }13 options[:skip_links] = true
14 14
15 options[:attribution] = <<-HTML15 options[:attribution] = <<-HTML
16 &copy; 2009&ndash;2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters &amp; Editors<br>16 &copy; 2009&ndash;2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters &amp; Editors<br>
test/lib/docs/filters/core/internal_urls_test.rb+14−0
@@ -285,6 +285,20 @@ class InternalUrlsFilterTest < MiniTest::Spec · 284 unmodified lines
285 @body = link_to context[:url]285 @body = link_to context[:url]
286 end286 end
287 287
288 context "when it is true" do
289 before do
290 context[:skip_links] = true
291 end
292
293 it "doesn't set :internal_urls" do
294 refute internal_urls
295 end
296
297 it "doesn't replace urls" do
298 assert_equal @body, filter_output_string
299 end
300 end
301
288 context "when it is a block" do302 context "when it is a block" do
289 it "calls the block with the filter instance" do303 it "calls the block with the filter instance" do
290 context[:skip_links] = ->(arg) { @arg = arg; nil }304 context[:skip_links] = ->(arg) { @arg = arg; nil }