voxpupuli / json-schema

Ruby JSON Schema Validator
MIT License
1.53k stars 242 forks source link

Developers often use Pathname objects for paths #274

Closed krainboltgreene closed 8 years ago

krainboltgreene commented 8 years ago

Strings are naive path names, and in Ruby we have an object specifically for path names called Pathname.

iainbeeston commented 8 years ago

I think really we should be moving away from explicit type checking and towards duck typing.

Looking at how OpenURI handles this problem, it checks for the open() method (which is supported by Pathname and IO objects) and failing that it checks for to_str() (which is supported by strings and Pathname in ruby prior to 1.9).

This method is a bit of a mess, it should probably be checking for supported methods (like OpenURI does) rather than using rescue instead of conditionals and rescue statements for flow control.

RST-J commented 8 years ago

I agree with @iainbeeston, I think it's the most flexible way and having rescue for control flow is really a code smell.

iainbeeston commented 8 years ago

I'm going to close this for now. Feel free to open another PR

krainboltgreene commented 8 years ago

This is rather disappointing. On Jan 8, 2016 2:50 AM, "Iain Beeston" notifications@github.com wrote:

I'm going to close this for now. Feel free to open another PR

— Reply to this email directly or view it on GitHub https://github.com/ruby-json-schema/json-schema/pull/274#issuecomment-169962136 .

iainbeeston commented 8 years ago

If you have time to make a new pull request that uses duck-typing rather than explicit type checking and we'll be more than happy to look at it