Merge: lib/github: GitHub loader
authorJean Privat <jean@pryen.org>
Mon, 27 Feb 2017 18:08:08 +0000 (13:08 -0500)
committerJean Privat <jean@pryen.org>
Mon, 27 Feb 2017 18:08:08 +0000 (13:08 -0500)
Helper tool to download a Github repo and store it in a Mongo database.

Features:
* supports github wallets
* save current job and restore jobs after failure
* options to enable branches, commits, issues, pulls, comments and events loading

Pull-Request: #2369
Reviewed-by: Jean Privat <jean@pryen.org>

1  2 
lib/json/serialization_write.nit

@@@ -99,8 -99,8 +99,8 @@@ class JsonSerialize
        do
                if not plain_json or not first_attribute then
                        stream.write ","
-                       first_attribute = false
                end
+               first_attribute = false
  
                new_line_and_indent
                stream.write "\""
@@@ -144,49 -144,26 +144,49 @@@ redef class Tex
        redef fun accept_json_serializer(v)
        do
                v.stream.write "\""
 +
 +              var start_i = 0
 +              var escaped = null
                for i in [0 .. self.length[ do
                        var char = self[i]
                        if char == '\\' then
 -                              v.stream.write "\\\\"
 +                              escaped = "\\\\"
                        else if char == '\"' then
 -                              v.stream.write "\\\""
 +                              escaped = "\\\""
                        else if char < ' ' then
                                if char == '\n' then
 -                                      v.stream.write "\\n"
 +                                      escaped = "\\n"
                                else if char == '\r' then
 -                                      v.stream.write "\\r"
 +                                      escaped = "\\r"
                                else if char == '\t' then
 -                                      v.stream.write "\\t"
 +                                      escaped = "\\t"
                                else
 -                                      v.stream.write char.escape_to_utf16
 +                                      escaped = char.escape_to_utf16
                                end
 +                      end
 +
 +                      if escaped != null then
 +                              # Write open non-escaped string
 +                              if start_i <= i then
 +                                      v.stream.write substring(start_i, i-start_i)
 +                              end
 +
 +                              # Write escaped character
 +                              v.stream.write escaped
 +                              escaped = null
 +                              start_i = i+1
 +                      end
 +              end
 +
 +              # Write remaining non-escaped string
 +              if start_i < length then
 +                      if start_i == 0 then
 +                              v.stream.write self
                        else
 -                              v.stream.write char.to_s
 +                              v.stream.write substring(start_i, length-start_i)
                        end
                end
 +
                v.stream.write "\""
        end
  end