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

Could not get correct extname from filepath #248

Closed
wants to merge 1 commit into from
Closed

Could not get correct extname from filepath #248

wants to merge 1 commit into from

Conversation

alpaca-tc
Copy link
Contributor

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

nhmood added a commit that referenced this pull request Feb 6, 2014
Parser now goes through chained extensions in reverse
and keeps parsing until recognized extension is found
Partially closes #236, #240, and #248
@nhmood
Copy link
Owner

nhmood commented Feb 6, 2014

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.

@nhmood nhmood closed this Feb 6, 2014
@alpaca-tc alpaca-tc deleted the fixed_bug_248 branch February 6, 2014 10:22
@alpaca-tc
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Owner

nhmood commented Feb 13, 2014

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
Copy link
Contributor Author

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

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.

2 participants