Skip to content

Commit

Permalink
Remove CanOnlyWriteStringError, due to it being private API
Browse files Browse the repository at this point in the history
  • Loading branch information
cllns committed Jun 27, 2022
1 parent 34b41c7 commit 4fe4c2f
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 35 deletions.
16 changes: 0 additions & 16 deletions lib/dry/files/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,5 @@ def initialize(path)
super("not a memory file `#{path}'")
end
end

# Internal file system adapters can only take
# strings as arguments to their `write` methods.
# (The public API can take string or array of strings)
#
# @since x.x.x
# @api private
class CanOnlyWriteStringError < Error
# Instantiate a new error
#
# @since x.x.x
# @api private
def initialize
super("Can only write a String (use `join` or `to_s`)")
end
end
end
end
3 changes: 0 additions & 3 deletions lib/dry/files/file_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,10 @@ def touch(path, **kwargs)
# @param content [String] the content to write
#
# @raise [Dry::Files::IOError] in case of I/O error
# @raise [CanOnlyWriteStringError] if content param isn't a String
#
# @since 0.1.0
# @api private
def write(path, content)
raise CanOnlyWriteStringError unless content.is_a?(String)

mkdir_p(path)

self.open(path, WRITE_MODE) do |f|
Expand Down
8 changes: 0 additions & 8 deletions spec/unit/dry/files/file_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,6 @@
path.chmod(mode)
end
end

it "raises error when trying to write non-string" do
path = root.join("write")
expect { subject.write(path, %w[new words]) }.to raise_error do |exception|
expect(exception).to be_kind_of(Dry::Files::CanOnlyWriteStringError)
expect(exception.message).to eq("Can only write a String (use `join` or `to_s`)")
end
end
end

describe "#join" do
Expand Down
8 changes: 0 additions & 8 deletions spec/unit/dry/files/memory_file_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,6 @@
path.chmod(mode)
end
end

it "raises error when trying to write non-string" do
path = subject.join("write")
expect { subject.write(path, %w[new words]) }.to raise_error do |exception|
expect(exception).to be_kind_of(Dry::Files::CanOnlyWriteStringError)
expect(exception.message).to eq("Can only write a String (use `join` or `to_s`)")
end
end
end

describe "#join" do
Expand Down

0 comments on commit 4fe4c2f

Please sign in to comment.