Replace String#indent from activesupport with helper method
This commit is contained in:
parent
40919b4c69
commit
696f50f40d
3 changed files with 8 additions and 3 deletions
|
|
@ -34,7 +34,7 @@ module DiasporaFederation
|
|||
<subject>#{data[:subject]}</subject>
|
||||
<created_at>#{data[:created_at].utc.iso8601}</created_at>
|
||||
<participant_handles>#{data[:participants]}</participant_handles>
|
||||
#{data[:messages].map {|a| a.to_xml.to_s.indent(2) }.join("\n")}
|
||||
#{data[:messages].map {|a| indent(a.to_xml.to_s, 2) }.join("\n")}
|
||||
</conversation>
|
||||
XML
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ module DiasporaFederation
|
|||
<poll>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<question>#{data[:question]}</question>
|
||||
#{data[:poll_answers].map {|a| a.to_xml.to_s.indent(2) }.join("\n")}
|
||||
#{data[:poll_answers].map {|a| indent(a.to_xml.to_s, 2) }.join("\n")}
|
||||
</poll>
|
||||
XML
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ XML
|
|||
"guid": "#{data[:guid]}",
|
||||
"question": "#{data[:question]}",
|
||||
"poll_answers": [
|
||||
#{data[:poll_answers].map {|a| JSON.pretty_generate(a.to_json).indent(6) }.join(",\n")}
|
||||
#{data[:poll_answers].map {|a| indent(JSON.pretty_generate(a.to_json), 6) }.join(",\n")}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,3 +35,8 @@ def change_time(time, options={})
|
|||
|
||||
::Time.utc(time.year, time.month, time.day, new_hour, new_min, new_sec)
|
||||
end
|
||||
|
||||
# indent helper
|
||||
def indent(string, amount)
|
||||
string.gsub(/^/, " " * amount)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue