summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2019-04-29 23:59:22 -0600
committerGitHub <noreply@github.com>2019-04-29 23:59:22 -0600
commitbb47c333df0aaab6daefa1f4acd3ba3d2623c0c8 (patch)
tree7399d00732e655f5f89581e3f2763d026f33fefb
parent2175b806d44ef9ef942c9cc7f63e3c402652a426 (diff)
resolves #3282 rename AbstractNode#options to AbstractNode#enabled_options (PR #3285)
-rw-r--r--CHANGELOG.adoc1
-rw-r--r--lib/asciidoctor/abstract_node.rb4
-rw-r--r--test/api_test.rb14
3 files changed, 16 insertions, 3 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 54000158..8f98dc90 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -19,6 +19,7 @@ Bug Fixes::
* process multiple single-item menu macros in same line (#3279)
* register images in catalog correctly (#3283)
+ * rename AbstractNode#options method to AbstractNode#enabled_options so it doesn't get shadowed by Document#options (#3282)
// tag::compact[]
== 2.0.8 (2019-04-22) - @mojavelinux
diff --git a/lib/asciidoctor/abstract_node.rb b/lib/asciidoctor/abstract_node.rb
index 024bbc1e..34ff17f7 100644
--- a/lib/asciidoctor/abstract_node.rb
+++ b/lib/asciidoctor/abstract_node.rb
@@ -161,10 +161,10 @@ class AbstractNode
nil
end
- # Public: Retrieve the Set of option names that are set on this node
+ # Public: Retrieve the Set of option names that are enabled on this node
#
# Returns a [Set] of option names
- def options
+ def enabled_options
::Set.new.tap {|accum| @attributes.each_key {|k| accum << (k.slice 0, k.length - 7) if k.to_s.end_with? '-option' } }
end
diff --git a/test/api_test.rb b/test/api_test.rb
index a3ebcee4..1af11bd5 100644
--- a/test/api_test.rb
+++ b/test/api_test.rb
@@ -1550,6 +1550,18 @@ context 'API' do
assert_equal '', block.attributes['reversed-option']
end
+ test 'enabled_options should return all options which are set' do
+ input = <<~'EOS'
+ [%interactive]
+ * [x] code
+ * [ ] test
+ * [ ] profit
+ EOS
+
+ block = (document_from_string input).blocks[0]
+ assert_equal %w(checklist interactive).to_set, block.enabled_options
+ end
+
test 'should append option to existing options' do
input = <<~'EOS'
[%fancy]
@@ -1586,7 +1598,7 @@ context 'API' do
EOS
block = (document_from_string input).blocks[0]
- assert_equal %w(compact reversed).to_set, block.options
+ assert_equal %w(compact reversed).to_set, block.enabled_options
end
test 'table column should not be a block or inline' do