Skip to content

Commit

Permalink
Read YAML encoding to write file correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
mnoack committed May 10, 2017
1 parent db88f85 commit 453337d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/pansophy/local/create_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def initialize(path, body)
def call(options = {})
prevent_overwrite! unless options[:overwrite]
@pathname.dirname.mkpath
if @body[0..10] == '# encoding:'
encoding = @body.lines.first.split(':').last.strip
@body.force_encoding(encoding)
end
::File.write(@pathname, @body)
end

Expand Down

0 comments on commit 453337d

Please sign in to comment.