Skip to content

Commit

Permalink
minor extract_magic_comment source tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
rtomayko committed Sep 15, 2011
1 parent 151854b commit c537f08
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/tilt/template.rb
Expand Up @@ -255,8 +255,11 @@ def unbind_compiled_method(method_name)

def extract_magic_comment(script)
comment = script.slice(/\A[ \t]*\#.*coding\s*[=:]\s*([[:alnum:]\-_]+).*$/)
return comment if comment and not %w[ascii-8bit binary].include?($1.downcase)
"# coding: #{@default_encoding}" if @default_encoding
if comment && !%w[ascii-8bit binary].include?($1.downcase)
comment
elsif @default_encoding
"# coding: #{@default_encoding}"
end
end

# Special case Ruby 1.9.1's broken yield.
Expand Down

0 comments on commit c537f08

Please sign in to comment.