sshkit icon indicating copy to clipboard operation
sshkit copied to clipboard

SSHKit::Formatter.Dot isn't showing any dots

Open hab278 opened this issue 12 years ago • 3 comments

At least for MRI 1.9.3 and 2.0.0. I suspect its this line

return unless obj === SSHKit::Command

Perhaps change it to

return unless obj.is_a? SSHKit::Command

Must investigate further.

hab278 avatar Dec 12 '13 18:12 hab278

That might be true, if you could check and perhaps link any relevant docs. I know that at least I always have to check the docs for is_a? vs kind_of? I always mix them up.

To be honest, this and your BlackHole ticket… both are formatters that I dreamt up as some things which might be interesting, I didn't expect people to actually use them.

You should be able to define your own formatter (even if you copy one of ours into your code, just drop it before you use SSHKit) and then try setting that as the formatter, as long as the constant is defined, it should be found.

leehambley avatar Dec 12 '13 19:12 leehambley

@leehambley Sure, I'll see what relevant docs I can link up, and put them in my pull request.

And I was experimenting with the formatters because for some reason the output is out of order in my Jenkins instance's output. I decided to see if I could make a formatter and ran into these errors so I decided to fix them.

hab278 avatar Dec 12 '13 19:12 hab278

This fails:

return unless obj === SSHKit::Command

RubyDocs says the case equality operator === is typically overridden by descendants to provide meaningful semantics in case statements. I can't see if SSHKit::Command was overridden, but it seems the operator checks to see if the right-hand argument's type is the same as or a descendant of the left-hand side. In this case the right hand arguments type is Class whereas the left hand is not the same type nor is it an ancestor, it is SSHKit::Command!

This is why all of these pass:

return unless SSHKit::Command === obj  # obj is SSHKit::Command
return unless obj.is_a? SSHKit::Command # Same as above
return unless obj.kind_of? SSHKit::Command # Same as above

Looks like RubyDocs shows no difference between is_a? and kind_of?, but I think is_a? makes more semantic sense since we're not in a case statement and we only want to continue if obj is a SSHKit::Command.

hab278 avatar Dec 12 '13 19:12 hab278