class << self #14

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

mihu commented Nov 18, 2012

Hi,

It seems that fog currently doesn't distinguish between instance methods and class methods defined in class << self. Example code

class Test
  class << self
    def test
      puts 'example'
    end
  end

  def test                                                                                                                              
      puts 'example'                                                                                                                    
  end                                                                                                                                   
end 

This gives me only the last method

     7.5: flog total
     3.8: flog/method average

     5.0: Test#none
     2.5: Test#test                        example.rb:9

with the patch I get this

     7.5: flog total
     2.5: flog/method average

     5.0: Test#none
     1.5: Test::test                       example.rb:4
     1.0: Test#test                        example.rb:9

The patch is a quick hack which works for me, don't exptect it to be pulled. Any ideas on how to make it less dirty?

Owner

zenspider commented Nov 19, 2012

This looks good... but it needs a test.

Owner

zenspider commented Nov 19, 2012

Hrm... @sclass should probably be a stack. See #in_klass

@ghost ghost assigned zenspider Nov 19, 2012

mihu commented Nov 20, 2012

well, the stack was my initial thought, but I'm totaly not sure how to handle something more complicated and frankly speaking, I don't even know how more complicated would look like. The only other thing coming to my mind is something like this

class << Time
  def something
  end
end

which posted patch doesn't handle properly, but that still doesn't require stack.

Owner

zenspider commented Nov 26, 2012

Yeah. I'm drawing a blank on when it'd occur... but I've parsed all of rubygems and know that if it can, it will...

Still need a test.

Owner

zenspider commented Nov 28, 2012

Awesome. Works for me. I'll let someone else report nesting issues if/when they come up. Thanks!

@zenspider zenspider closed this Nov 28, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment