Skip to content

Handle the file argument properly#283

Merged
tenderlove merged 3 commits intosparklemotion:masterfrom
yb66:patch-1
Jul 4, 2020
Merged

Handle the file argument properly#283
tenderlove merged 3 commits intosparklemotion:masterfrom
yb66:patch-1

Conversation

@yb66
Copy link
Copy Markdown
Contributor

@yb66 yb66 commented Mar 16, 2020

The argument is a file path but is called file and yet it's treated as a string.
If passed an actual File or a Pathname it will be properly handled.

The argument is a file *path* but is called *file* and yet it's treated as a string.
If passed an actual File or a Pathname it will be properly handled.
@tenderlove
Copy link
Copy Markdown
Member

@yb66 do you mind adding a test for this?

@MSP-Greg
Copy link
Copy Markdown
Contributor

@yb66

Windows behaves a bit differently with file handles. The test below passes CI:

def test_filename_to_path
  tf = Tempfile.new 'thing'
  pn = Pathname tf.path
  db = SQLite3::Database.new pn
  assert_equal pn.expand_path.to_s, File.expand_path(db.filename)
ensure
  tf.close! if tf
end

@yb66
Copy link
Copy Markdown
Contributor Author

yb66 commented Apr 17, 2020

Thanks @MSP-Greg.

Regards,
iain

@tenderlove tenderlove merged commit d94c42b into sparklemotion:master Jul 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants