Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asciidoctor: Log absolute path when copying images #565

Merged
merged 1 commit into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/asciidoctor/lib/copy_images/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def process_block block
return unless @copied.add? uri # Skip images we've copied before
source = find_source block, uri
return unless source # Skip images we can't find
logger.info message_with_context "copying #{uri}", :source_location => block.source_location
logger.info message_with_context "copying #{source}", :source_location => block.source_location
copy_image_proc = block.document.attr 'copy_image'
if copy_image_proc
# Delegate to a proc for copying if one is defined. Used for testing.
Expand Down
25 changes: 16 additions & 9 deletions resources/asciidoctor/spec/copy_images_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def copy_attributes copied
== Example
image::resources/copy_images/example1.png[]
ASCIIDOC
convert input, attributes, match(/INFO: <stdin>: line 2: copying resources\/copy_images\/example1.png/)
convert input, attributes,
eq("INFO: <stdin>: line 2: copying #{spec_dir}\/resources\/copy_images\/example1.png")
expect(copied).to eq([
["resources/copy_images/example1.png", "#{spec_dir}/resources/copy_images/example1.png"]
])
Expand All @@ -46,7 +47,8 @@ def copy_attributes copied
== Example
image::example1.png[]
ASCIIDOC
convert input, attributes, match(/INFO: <stdin>: line 2: copying example1.png/)
convert input, attributes,
eq("INFO: <stdin>: line 2: copying #{spec_dir}/resources/copy_images/example1.png")
expect(copied).to eq([
["example1.png", "#{spec_dir}/resources/copy_images/example1.png"]
])
Expand All @@ -59,7 +61,8 @@ def copy_attributes copied
== Example
image::copy_images/example1.png[]
ASCIIDOC
convert input, attributes, match(/INFO: <stdin>: line 2: copying copy_images\/example1.png/)
convert input, attributes,
eq("INFO: <stdin>: line 2: copying #{spec_dir}/resources/copy_images/example1.png")
expect(copied).to eq([
["copy_images/example1.png", "#{spec_dir}/resources/copy_images/example1.png"]
])
Expand Down Expand Up @@ -93,9 +96,12 @@ def copy_attributes copied
image::resources/copy_images/example2.png[]
image::resources/copy_images/example1.png[]
image::resources/copy_images/example2.png[]
ASCIIDOC
convert input, attributes, match(/INFO: <stdin>: line 2: copying resources\/copy_images\/example1.png/).and(
match(/INFO: <stdin>: line 4: copying resources\/copy_images\/example2.png/))
ASCIIDOC
expected_warnings = <<~LOG
INFO: <stdin>: line 2: copying #{spec_dir}/resources/copy_images/example1.png
INFO: <stdin>: line 4: copying #{spec_dir}/resources/copy_images/example2.png
LOG
convert input, attributes, eq(expected_warnings.strip)
expect(copied).to eq([
["resources/copy_images/example1.png", "#{spec_dir}/resources/copy_images/example1.png"],
["resources/copy_images/example2.png", "#{spec_dir}/resources/copy_images/example2.png"],
Expand Down Expand Up @@ -127,8 +133,8 @@ def copy_attributes copied
== Example
image::tmp_example1.png[]
ASCIIDOC
# NOCOMMIT full paths in logs too, I think
convert input, attributes, match(/INFO: <stdin>: line 2: copying tmp_example1.png/)
convert input, attributes,
eq("INFO: <stdin>: line 2: copying #{tmp}/tmp_example1.png")
expect(copied).to eq([
["tmp_example1.png", "#{tmp}/tmp_example1.png"]
])
Expand All @@ -149,7 +155,8 @@ def copy_attributes copied
== Example
image::tmp_example1.png[]
ASCIIDOC
convert input, attributes, match(/INFO: <stdin>: line 2: copying tmp_example1.png/)
convert input, attributes,
eq("INFO: <stdin>: line 2: copying #{tmp}/tmp_example1.png")
expect(copied).to eq([
["tmp_example1.png", "#{tmp}/tmp_example1.png"]
])
Expand Down
2 changes: 1 addition & 1 deletion resources/asciidoctor/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def convert input, extra_attributes = {}, warnings_matcher = eq('')
}
warnings_string = logger.messages
.map { |l| "#{l[:severity]}: #{l[:message].inspect}" }
.join('\n')
.join("\n")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little oopsie I caught!

expect(warnings_string).to warnings_matcher
result
end