nhmood / watson-ruby

inline issue manager
MIT License
634 stars 50 forks source link

Could not get correct extname from filepath #248

Closed alpaca-tc closed 10 years ago

alpaca-tc commented 10 years ago

Watson can not detect '.haml' from '.html.haml'.

nhmood commented 10 years ago

I used your COMMENT_DEFINITIONS format (that was probably how I should have done it in the first place!) but I ended up implementing a different solution for chained extensions that I think works well. Let me know if you have any suggestions/problems/opinions on the chained extension support.

alpaca-tc commented 10 years ago

I want to use regexp to detect filetype as follows.

@definitions = { /\.(html\.erb|erb)$/ => [/(?<=<%#)\s*(.*)(?=%>)/] }

def can_parse?(filename)
  @definitions.each_key do |key| 
    return @definitions[key] if filename =~ key
  end

  nil
end

filename = 'bar.html.erb'
p can_parse?(filename)

BTW, I want to divide parser feature from watson-ruby because the feature of filtering comment from source code is a versatile approach. I am writing the gem called StripComment.(work in progress) If I finish implementing it, we can abstractly use comments in source code.

Let me know if you have any suggestions/problems/opinions on the chained extension support.

What's your opinion?

alpaca-tc commented 10 years ago

Hi, @nhmood :) I have almost finished implementing gem. comment_parser I want to introduce comment_parser into watson-ruby in the near future. Could I get your opinion?

nhmood commented 10 years ago

This seems like it might work out well, let me review the gem and see if there would be any reason to keep the comment parsing contained within watson-ruby instead of comment_parser. I'll get back to you once I get a chance to look over it.

alpaca-tc commented 10 years ago

Okay, I'll wait your response. I'll create a new issue about this talking. Please check it:)