Skip to content

Commit

Permalink
Use single-quote heredoc instead of attempting escaping.
Browse files Browse the repository at this point in the history
Addresses #8
  • Loading branch information
ronen committed Jun 25, 2015
1 parent 494f4bc commit 7d20b9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/schema_plus/views/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ def after(env)
class View < KeyStruct[:name, :definition]
def assemble(stream)
heredelim = "END_VIEW_#{name.upcase}"
stream.puts " create_view #{name.to_json}, <<-#{heredelim}, :force => true\n"
definition.split("\n").each { |line| stream.puts line.to_json[1...-1] + "\n" }
stream.puts " #{heredelim}\n\n"
stream.puts <<-ENDVIEW
create_view "#{name}", <<-'#{heredelim}', :force => true
#{definition}
#{heredelim}
ENDVIEW
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/dumper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Item < ActiveRecord::Base

def view_re(name, re)
heredelim = "END_VIEW_#{name.upcase}"
%r{create_view "#{name}", <<-#{heredelim}, :force => true\n\s*#{re}\s*\n *#{heredelim}$}mi
%r{create_view "#{name}", <<-'#{heredelim}', :force => true\n\s*#{re}\s*\n *#{heredelim}$}mi
end

def define_schema_and_data
Expand Down

0 comments on commit 7d20b9a

Please sign in to comment.