-
Notifications
You must be signed in to change notification settings - Fork 29
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
3.0.0 complete rewrite #59
Conversation
@jeena asked a very reasonable question about the differences between v2 and v3, attempting to enumerate those differences.
…the parser, or marked them as pending
…r versions of ruby
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left the same comment in a few places, but it can be applied everywhere. I think this is a good time to move to almost/all named parameters since it's already a big breaking change release.
Also, I don't love the test suite requiring npm. I understand why you did it. It's pragmatic. But I'd like to see this get moved over to a ruby/rake workflow in the future.
lib/microformats2/format_parser.rb
Outdated
when node.is_a?(Nokogiri::XML::Element) then [parse_for_microformats(node, parsing_children)] | ||
end | ||
end | ||
def parse(element, base=nil, element_type=nil, fmt_classes=[], backcompat=false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should use named parameters here.
lib/microformats2.rb
Outdated
def parse(html) | ||
Parser.new.parse(html) | ||
def parse(html, base: nil) | ||
Parser.new.parse(html, base) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Parser.new.parse()
should use a named parameter for base
.
lib/microformats2/parser.rb
Outdated
end | ||
|
||
def parse(html, headers={}) | ||
def parse(html, base= nil, headers={}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More that should be named parameters.
class Collection | ||
def initialize(hash) | ||
@hash = hash | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods should have vertical whitespace between them.
end | ||
def to_hash | ||
@hash | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be good to alias to_h
to to_hash
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, but for future resilience and DRYer code, you should use alias_method
.
alias_method :baz, :foo
missed a few tabbing issues more consistant spacing changed all functions to be named parameters after the first this should have been changed when that change was first made, but this now adds a min version for ruby of 2.0 when named params first introduced
hmm thought i had privileges to review, it seems not.