hoxworth/json-schema — pull request #26 by vapir (2012-01-27 08:06:15+00:00)
Title: Validation fails if root data object is a string 

#initialize_data tries to be too clever with its input, which ends up being problematic - see output attached below.

I think that there should be separate methods, #validate which only takes parsed (ruby) objects, #validate_json which will parse json and validate the object, #validate_from_uri which opens a URI and reads it.

having the validator guess when it's initialized is way too ambiguous. plus, I'm dealing with user-input data; I certainly don't want it to be able to open some arbitrary URI.

I haven't bothered to do similar with schemas as with data due to the facts that 1) users don't typically supply schemas, whereas they do supply data, and 2) a string is never a valid schema, whereas it can be valid data.

```
>> JSON::Validator.fully_validate({'type' => 'string'}, "hello")
Errno::ENOENT: No such file or directory - hello
from /Users/ethan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/open-uri.rb:35:in `initialize'
from /Users/ethan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/open-uri.rb:35:in `open'
from /Users/ethan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/open-uri.rb:35:in `open'
from /Users/ethan/.rvm/gems/ruby-1.9.2-p290@eureka/gems/json-schema-1.0.0/lib/json-schema/validator.rb:458:in `rescue in initialize_data'
from /Users/ethan/.rvm/gems/ruby-1.9.2-p290@eureka/gems/json-schema-1.0.0/lib/json-schema/validator.rb:447:in `initialize_data'
from /Users/ethan/.rvm/gems/ruby-1.9.2-p290@eureka/gems/json-schema-1.0.0/lib/json-schema/validator.rb:131:in `initialize'
from /Users/ethan/.rvm/gems/ruby-1.9.2-p290@eureka/gems/json-schema-1.0.0/lib/json-schema/validator.rb:266:in `new'
from /Users/ethan/.rvm/gems/ruby-1.9.2-p290@eureka/gems/json-schema-1.0.0/lib/json-schema/validator.rb:266:in `fully_validate'
from (irb):44
from /Users/ethan/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `

'
```