Skip to content

Commit 4fe4c2f

Browse files
committed
Remove CanOnlyWriteStringError, due to it being private API
1 parent 34b41c7 commit 4fe4c2f

File tree

4 files changed

+0
-35
lines changed

4 files changed

+0
-35
lines changed

lib/dry/files/error.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,5 @@ def initialize(path)
116116
super("not a memory file `#{path}'")
117117
end
118118
end
119-
120-
# Internal file system adapters can only take
121-
# strings as arguments to their `write` methods.
122-
# (The public API can take string or array of strings)
123-
#
124-
# @since x.x.x
125-
# @api private
126-
class CanOnlyWriteStringError < Error
127-
# Instantiate a new error
128-
#
129-
# @since x.x.x
130-
# @api private
131-
def initialize
132-
super("Can only write a String (use `join` or `to_s`)")
133-
end
134-
end
135119
end
136120
end

lib/dry/files/file_system.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,10 @@ def touch(path, **kwargs)
129129
# @param content [String] the content to write
130130
#
131131
# @raise [Dry::Files::IOError] in case of I/O error
132-
# @raise [CanOnlyWriteStringError] if content param isn't a String
133132
#
134133
# @since 0.1.0
135134
# @api private
136135
def write(path, content)
137-
raise CanOnlyWriteStringError unless content.is_a?(String)
138-
139136
mkdir_p(path)
140137

141138
self.open(path, WRITE_MODE) do |f|

spec/unit/dry/files/file_system_spec.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,6 @@
217217
path.chmod(mode)
218218
end
219219
end
220-
221-
it "raises error when trying to write non-string" do
222-
path = root.join("write")
223-
expect { subject.write(path, %w[new words]) }.to raise_error do |exception|
224-
expect(exception).to be_kind_of(Dry::Files::CanOnlyWriteStringError)
225-
expect(exception.message).to eq("Can only write a String (use `join` or `to_s`)")
226-
end
227-
end
228220
end
229221

230222
describe "#join" do

spec/unit/dry/files/memory_file_system_spec.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,6 @@
188188
path.chmod(mode)
189189
end
190190
end
191-
192-
it "raises error when trying to write non-string" do
193-
path = subject.join("write")
194-
expect { subject.write(path, %w[new words]) }.to raise_error do |exception|
195-
expect(exception).to be_kind_of(Dry::Files::CanOnlyWriteStringError)
196-
expect(exception.message).to eq("Can only write a String (use `join` or `to_s`)")
197-
end
198-
end
199191
end
200192

201193
describe "#join" do

0 commit comments

Comments
 (0)