Skip to content

Commit

Permalink
Fix encoding of serialized paths (frozen string error)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsegal committed Jan 7, 2020
1 parent 87caa35 commit 63c6788
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/yard/serializers/yardoc_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def serialized_path(object)
p.gsub(/[^\w\.-]/) do |x|
encoded = '_'

x.each_byte {|b| encoded << ("%X" % b) }
x.each_byte {|b| encoded += ("%X" % b) }
encoded
end
end.join('/') + '.' + extension
Expand Down
12 changes: 12 additions & 0 deletions spec/serializers/yardoc_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ class YARD::Serializers::YardocSerializer
end
end

describe "#serialized_path" do
it "handles String path name" do
path = @serializer.serialized_path('Path::To#object')
expect(path).to eq('objects/Path/To/object_i.dat')
end

it "handles special encoding characters" do
path = @serializer.serialized_path('object$')
expect(path).to eq('objects/object_24.dat')
end
end

describe "#lock_for_writing" do
it "creates a lock file during writing and cleans up" do
expect(File).to receive(:open!).with(@serializer.processing_path, 'w')
Expand Down

0 comments on commit 63c6788

Please sign in to comment.