 
   serialize: ->
 
+  getGistId: ->
+    gistId = atom.config.get 'sync-settings.gistId'
+    if gistId
+      gistId = gistId.trim()
+    return gistId
+
+  getPersonalAccessToken: ->
+    token = atom.config.get 'sync-settings.personalAccessToken'
+    if token
+      token = token.trim()
+    return token
+
   checkMandatorySettings: ->
     missingSettings = []
-    if not atom.config.get('sync-settings.gistId')
+    if not @getGistId()
       missingSettings.push("Gist ID")
-    if not atom.config.get('sync-settings.personalAccessToken')
+    if not @getPersonalAccessToken()
       missingSettings.push("GitHub personal access token")
     if missingSettings.length
       @notifyMissingMandatorySettings(missingSettings)
     return missingSettings.length is 0
 
   checkForUpdate: (cb=null) ->
-    if atom.config.get('sync-settings.gistId')
+    if @getGistId()
       console.debug('checking latest backup...')
       @createClient().gists.get
-        id: atom.config.get 'sync-settings.gistId'
+        id: @getGistId()
       , (err, res) =>
         console.debug(err, res)
         if err


  viewBackup: ->
    Shell = require 'shell'
    gistId = atom.config.get 'sync-settings.gistId'
    Shell.openExternal "https://gist.github.com/#{gistId}"

  getPackages: ->

        content: (@fileContent atom.config.configDirPath + "/#{file}") ? "#{cmtstart} #{file} (not found) #{cmtend}"

    @createClient().gists.edit
      id: @getGistId()
      description: atom.config.get 'sync-settings.gistDescription'
      files: files
    , (err, res) ->
