diff --git a/lib/schema_plus/views/middleware.rb b/lib/schema_plus/views/middleware.rb index 2aa8a44..39f83ed 100644 --- a/lib/schema_plus/views/middleware.rb +++ b/lib/schema_plus/views/middleware.rb @@ -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 diff --git a/spec/dumper_spec.rb b/spec/dumper_spec.rb index 04bace9..ff29543 100644 --- a/spec/dumper_spec.rb +++ b/spec/dumper_spec.rb @@ -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