Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Fix JSON print in Ruby #1274

Merged
merged 2 commits into from
May 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/main/resources/com/google/api/codegen/ruby/sample.snip
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
require 'googleauth'
@end
require '{@class.serviceRequirePath}'
@if class.hasResponse
require 'json'
@end

{@class.serviceVarName} = {@class.serviceTypeNamespace}::{@class.serviceTypeName}.new

Expand Down Expand Up @@ -116,22 +113,22 @@
@if class.pageStreaming.isResourceMap
{@class.pageStreaming.pageVarName}.each do |{@class.pageStreaming.resourceKeyVarName}, {@class.pageStreaming.resourceValueVarName}|
@# TODO: Change code below to process each ({@class.pageStreaming.resourceKeyVarName}, {@class.pageStreaming.resourceValueVarName}) pair:
puts String({@class.pageStreaming.resourceKeyVarName} << " => " << JSON.pretty_unparse({@class.pageStreaming.resourceValueVarName}.to_h)
puts String({@class.pageStreaming.resourceKeyVarName} << " => " << {@class.pageStreaming.resourceValueVarName}.to_json
end
@else
# We don't handle non-repeated page streaming resources separately in Ruby
# because the fetch_all treats them correctly.
{@class.pageStreaming.pageVarName}.each do |{@class.pageStreaming.resourceVarName}|
@# TODO: Change code below to process each `{@class.pageStreaming.resourceVarName}` resource:
puts JSON.pretty_unparse({@class.pageStreaming.resourceVarName}.to_h)
puts {@class.pageStreaming.resourceVarName}.to_json
end
@end
@else
@if class.hasResponse
{@class.responseVarName} = {@methodCall(class)}({@paramList(class.methodCallFieldVarNames)})

@# TODO: Change code below to process the `{@class.responseVarName}` object:
puts JSON.pretty_unparse({@class.responseVarName}.to_h)
puts {@class.responseVarName}.to_json
@else
{@methodCall(class)}({@paramList(class.methodCallFieldVarNames)})
@end
Expand Down
Loading