SublimeLinter / SublimeLinter-ruby

SublimeLinter plugin for ruby, using ruby -wc.
MIT License
60 stars 9 forks source link

Problem with UTF-8 characters #6

Closed gabrielecirulli closed 10 years ago

gabrielecirulli commented 10 years ago

I have the following ruby code:

module ApplicationHelper
  # Page titles
  def base_page_title
    "My App"
  end

  def page_title(title)
    if title.present?
      "#{title} — #{base_page_title}"
    else
      base_page_title
    end
  end
end

SublimeLinter-ruby complains about line 9:

      "#{title} — #{base_page_title}"

This line contains an unicode character, an em dash ("—"), and SublimeLinter-ruby reports it as an error with the following message:

Error: unexpected end-of-input, expecting keyword_end

I think this is a problem with SublimeLinter-ruby (or maybe SublimeLinter in general). If I run the same code through ruby -wc app/helpers/application_helper.rb I get Syntax OK, and if I remove that unicode character and replace it with an ASCII character, SublimeLinter starts complaining.

Is there a way to work around this, or is it a bug that needs fixing? Thanks!

piersadrian commented 10 years ago

Are you using ruby <= 2.0? I'm on 2.1.0-p0 and I'm getting the same issue, even though ruby treats all source files as UTF8 by default these days.

Adding the old-school # encoding: utf-8 line to the top of the file resolves the error, although I don't understand why. The oldest version of ruby on my machine is 2.0.0p247, so I shouldn't be seeing source-encoding issues like this.

gabrielecirulli commented 10 years ago

I'm on Ruby 2.1.0 too :smile:. Is adding that comment at the top the only way to avoid this?

aparajita commented 10 years ago

I'm looking for someone to take responsibility for this linter. I don't use it, so I won't be supporting it.

batamire commented 10 years ago

I'm on ruby 2.1.2 and having the same issue. ruby -wc filename.rb is OK but sublimelinter complains about utf8 characters. # encoding: utf-8 is a fix but an ugly one.

aparajita commented 10 years ago

I have a fix in the pipeline which took many hours to track down.

I can only assume you guys get paid for what you are doing with ruby and that SublimeLinter is a valuable tool. I don't use ruby and I took time from my paying clients (time I really don't have) to fix this for you. I would greatly appreciate it if you would place some value on your time and my time by donating.

aparajita commented 10 years ago

Fixed in 3.4.0.

Donations — or even better, collaborators — are welcome. Otherwise the future it's doubtful I'll do anything to support ruby.