From bf6c900ca772366760b8c6845db245aa9d7ef446 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Mon, 2 Dec 2013 18:24:06 +0000 Subject: [PATCH] Make :skip_links option work with true/false --- lib/docs/filters/core/internal_urls.rb | 2 +- lib/docs/scrapers/backbone.rb | 2 +- lib/docs/scrapers/coffeescript.rb | 2 +- lib/docs/scrapers/less.rb | 2 +- lib/docs/scrapers/lodash.rb | 2 +- lib/docs/scrapers/underscore.rb | 2 +- test/lib/docs/filters/core/internal_urls_test.rb | 14 ++++++++++++++ 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/docs/filters/core/internal_urls.rb b/lib/docs/filters/core/internal_urls.rb index 5db6285e..e5f79c4a 100644 --- a/lib/docs/filters/core/internal_urls.rb +++ b/lib/docs/filters/core/internal_urls.rb @@ -25,7 +25,7 @@ module Docs end def skip_links? - context[:skip_links] && context[:skip_links].call(self) + context[:skip_links].is_a?(Proc) ? context[:skip_links].call(self) : context[:skip_links] end def follow_links? diff --git a/lib/docs/scrapers/backbone.rb b/lib/docs/scrapers/backbone.rb index 66e26eba..b5fb3e53 100644 --- a/lib/docs/scrapers/backbone.rb +++ b/lib/docs/scrapers/backbone.rb @@ -10,7 +10,7 @@ module Docs options[:title] = 'Backbone.js' options[:container] = '.container' - options[:skip_links] = ->(filter) { true } + options[:skip_links] = true options[:attribution] = <<-HTML © 2010–2013 Jeremy Ashkenas, DocumentCloud
diff --git a/lib/docs/scrapers/coffeescript.rb b/lib/docs/scrapers/coffeescript.rb index dca7c448..ecd45040 100644 --- a/lib/docs/scrapers/coffeescript.rb +++ b/lib/docs/scrapers/coffeescript.rb @@ -9,7 +9,7 @@ module Docs options[:title] = 'CoffeeScript' options[:container] = '.container' - options[:skip_links] = ->(filter) { true } + options[:skip_links] = true options[:attribution] = <<-HTML © 2009–2013 Jeremy Ashkenas
diff --git a/lib/docs/scrapers/less.rb b/lib/docs/scrapers/less.rb index ec094c53..f182ca8b 100644 --- a/lib/docs/scrapers/less.rb +++ b/lib/docs/scrapers/less.rb @@ -8,7 +8,7 @@ module Docs options[:title] = 'LESS' options[:container] = 'section' - options[:skip_links] = ->(filter) { true } + options[:skip_links] = true options[:attribution] = <<-HTML © 2009–2013 Alexis Sellier & The Core Less Team
diff --git a/lib/docs/scrapers/lodash.rb b/lib/docs/scrapers/lodash.rb index c0147790..0d535b6d 100644 --- a/lib/docs/scrapers/lodash.rb +++ b/lib/docs/scrapers/lodash.rb @@ -10,7 +10,7 @@ module Docs options[:title] = 'Lo-Dash' options[:container] = 'h1+div+div' - options[:skip_links] = ->(filter) { true } + options[:skip_links] = true options[:attribution] = <<-HTML © 2012–2013 The Dojo Foundation
diff --git a/lib/docs/scrapers/underscore.rb b/lib/docs/scrapers/underscore.rb index a5c6a19a..9728e117 100644 --- a/lib/docs/scrapers/underscore.rb +++ b/lib/docs/scrapers/underscore.rb @@ -10,7 +10,7 @@ module Docs options[:title] = 'Underscore.js' options[:container] = '#documentation' - options[:skip_links] = ->(filter) { true } + options[:skip_links] = true options[:attribution] = <<-HTML © 2009–2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
diff --git a/test/lib/docs/filters/core/internal_urls_test.rb b/test/lib/docs/filters/core/internal_urls_test.rb index 52c1a7d9..76d95299 100644 --- a/test/lib/docs/filters/core/internal_urls_test.rb +++ b/test/lib/docs/filters/core/internal_urls_test.rb @@ -285,6 +285,20 @@ class InternalUrlsFilterTest < MiniTest::Spec @body = link_to context[:url] end + context "when it is true" do + before do + context[:skip_links] = true + end + + it "doesn't set :internal_urls" do + refute internal_urls + end + + it "doesn't replace urls" do + assert_equal @body, filter_output_string + end + end + context "when it is a block" do it "calls the block with the filter instance" do context[:skip_links] = ->(arg) { @arg = arg; nil }