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

Add Field class #11

Merged
merged 14 commits into from
Oct 12, 2016
Merged

Add Field class #11

merged 14 commits into from
Oct 12, 2016

Conversation

pezholio
Copy link
Contributor

Fixes #9

@roll, @pwalsh - Does this chime with your expectations in #9?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 98.705% when pulling fbe4764 on feature-add-field into d03825e on master.

Copy link
Member

@roll roll left a comment

Choose a reason for hiding this comment

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

Thanks!

I added a few comments. And also one thing I think is missing - connection between Schema and Field in methods like schema.fields, schema.get_fields etc.

@@ -209,14 +207,31 @@ rows = [
['wrong column count']
]

schema.convert(rows)
schema.cast(rows)
Copy link
Member

@roll roll Oct 10, 2016

Choose a reason for hiding this comment

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

From my experience almost all interactions with schema related to casting go thru schema.cast_row - not sure this cast method needed at all. Also name could be confusing (schema.cast - cast what? schema? data?). WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, this was carried over from the old Python API - calling it cast_rows would probably make more sense

@@ -28,6 +28,7 @@
require "jsontableschema/types/string"
Copy link
Member

Choose a reason for hiding this comment

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

I suppose it's something like __init__.py in Python? I'm not sure how it works in Ruby but in Python we use this to declare API - adding only public interface and not adding internal stuff (like types after field introduction). Like it's internal API could be changed anytime without any notification etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's it, this is the main file that requires everything needed by the gem. There are other patterns (i.e. we could modularise, so you could only require jsonschema/table or jsonschema/schema), but this is the generally accepted pattern, especially for small, focussed gems.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 98.705% when pulling 98b9a30 on feature-add-field into d03825e on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 98.705% when pulling 993c9fe on feature-add-field into d03825e on master.

@pezholio
Copy link
Contributor Author

@roll The schema and field connections are defined in https://github.com/theodi/jsontableschema.rb/blob/feature-add-field/lib/jsontableschema/model.rb - which is a Ruby module which is included in schema.rb - I've split a lot of things out into modules, which keeps things neater.

@pikesley pikesley merged commit 74bd239 into master Oct 12, 2016
@pezholio pezholio deleted the feature-add-field branch October 12, 2016 12:56
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.

None yet

4 participants