Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove json dependency. JSONAPI.parse now only accepts a hash. #37

Merged

Conversation

NullVoxPopuli
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli commented Sep 19, 2016

Superseds #40, fixes #33, #35.

@NullVoxPopuli
Copy link
Contributor Author

rebased

@@ -23,6 +23,7 @@ module JSONAPI
# objects in the primary data must have an id.
# @return [JSONAPI::Parser::Document]
def parse(document, options = {})
raise Parser::InvalidDocument, 'document cannot be nil' if document.nil?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking that we might as well go the extra mile and require document to be a Hash.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated!

@@ -94,4 +94,10 @@
expect(document.data.first.relationships.author.data.to_hash).to eq @author_data_hash
expect(document.data.first.relationships.comments.data.map(&:to_hash)).to eq @comments_data_hash
end

it 'raises InvalidDocument on nil input' do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Owner

@beauby beauby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just update the yarddoc above the parse method (# @param document [Hash, String] the JSON API document.) and we're good to merge.

@NullVoxPopuli
Copy link
Contributor Author

It also made the json.parse method not required, so I removed that, too


Parser::Document.new(hash, options)
raise Parser::InvalidDocument, 'document must be a hash' unless document.is_a?(Hash)
Parser::Document.new(document, options)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, then you can also remove the dependency to json in both this file and the gemspec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@beauby beauby changed the title nil check + test Remove json dependency. JSONAPI.parse now only accepts a hash. Sep 28, 2016
Copy link
Owner

@beauby beauby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@NullVoxPopuli
Copy link
Contributor Author

woo!

Copy link
Owner

@beauby beauby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, update README.md first.

@NullVoxPopuli
Copy link
Contributor Author

Which part needs to be updated?

@beauby
Copy link
Owner

beauby commented Sep 30, 2016

My bad, no update needed. LGTM, rebase and we can merge.

@NullVoxPopuli NullVoxPopuli force-pushed the bugfix/raise-correct-exception-on-nil-input branch from 42ba2c9 to 01e5ff8 Compare September 30, 2016 20:37
@NullVoxPopuli
Copy link
Contributor Author

rebased

@beauby beauby merged commit 4d23582 into beauby:master Sep 30, 2016
@NullVoxPopuli NullVoxPopuli deleted the bugfix/raise-correct-exception-on-nil-input branch September 30, 2016 22:31
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.

2 participants