Make :skip_links option work with true/false

pull/22/head
Thibaut 11 years ago
parent 47eb7eec7f
commit bf6c900ca7

@ -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?

@ -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
&copy; 2010&ndash;2013 Jeremy Ashkenas, DocumentCloud<br>

@ -9,7 +9,7 @@ module Docs
options[:title] = 'CoffeeScript'
options[:container] = '.container'
options[:skip_links] = ->(filter) { true }
options[:skip_links] = true
options[:attribution] = <<-HTML
&copy; 2009&ndash;2013 Jeremy Ashkenas<br>

@ -8,7 +8,7 @@ module Docs
options[:title] = 'LESS'
options[:container] = 'section'
options[:skip_links] = ->(filter) { true }
options[:skip_links] = true
options[:attribution] = <<-HTML
&copy; 2009&ndash;2013 Alexis Sellier &amp; The Core Less Team<br>

@ -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
&copy; 2012&ndash;2013 The Dojo Foundation<br>

@ -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
&copy; 2009&ndash;2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters &amp; Editors<br>

@ -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 }

Loading…
Cancel
Save