Replace Atom::getLoadSettings with a ::loadSettings property

We assign a value into ::loadSettings anyway in a spec, so there's not
much point leaving it a method. Eventually I'd like to pass all these
settings in when constructing the Atom object and eliminate awareness
of the loadSettings altogether from the Atom global.
This commit is contained in:
Nathan Sobo
2013-12-12 15:41:52 -08:00
parent 14c58c4517
commit a564cc66f6
11 changed files with 18 additions and 24 deletions

View File

@@ -122,6 +122,7 @@ class Atom extends Model
created: ->
DeserializerManager = require './deserializer-manager'
@deserializers = new DeserializerManager()
@loadSettings = @constructor.getLoadSettings()
# Public: Sets up the basic services that should be available in all modes
# (both spec and application). Call after this instance has been assigned to
@@ -140,7 +141,7 @@ class Atom extends Model
ThemeManager = require './theme-manager'
ContextMenuManager = require './context-menu-manager'
MenuManager = require './menu-manager'
{devMode, resourcePath} = @getLoadSettings()
{devMode, resourcePath} = @loadSettings
configDirPath = @getConfigDirPath()
@config = new Config({configDirPath, resourcePath})
@@ -202,16 +203,10 @@ class Atom extends Model
setBodyPlatformClass: ->
document.body.classList.add("platform-#{process.platform}")
# Public: Get the load settings for the current window.
#
# Returns an object containing all the load setting key/value pairs.
getLoadSettings: ->
@constructor.getLoadSettings()
# Private:
deserializeProject: ->
Project = require './project'
@project ?= new Project(path: @getLoadSettings().initialPath)
@project ?= new Project(path: @loadSettings.initialPath)
# Private:
deserializeWorkspaceView: ->
@@ -299,7 +294,7 @@ class Atom extends Model
# Private:
restoreWindowDimensions: ->
windowDimensions = @state.getObject('windowDimensions') ? {}
{initialSize} = @getLoadSettings
{initialSize} = @loadSettings
windowDimensions.height ?= initialSize?.height ? global.screen.availHeight
windowDimensions.width ?= initialSize?.width ? Math.min(global.screen.availWidth, 1024)
@setWindowDimensions(windowDimensions)
@@ -407,11 +402,11 @@ class Atom extends Model
# Public: Is the current window in development mode?
inDevMode: ->
@getLoadSettings().devMode
@loadSettings.devMode
# Public: Is the current window running specs?
inSpecMode: ->
@getLoadSettings().isSpec
@loadSettings.isSpec
# Public: Toggle the full screen state of the current window.
toggleFullScreen: ->

View File

@@ -54,7 +54,7 @@ module.exports =
callback = resourcePath
resourcePath = null
resourcePath ?= atom.getLoadSettings().resourcePath
resourcePath ?= atom.loadSettings.resourcePath
commandPath = path.join(resourcePath, 'atom.sh')
@install(commandPath, callback)
@@ -63,6 +63,6 @@ module.exports =
callback = resourcePath
resourcePath = null
resourcePath ?= atom.getLoadSettings().resourcePath
resourcePath ?= atom.loadSettings.resourcePath
commandPath = path.join(resourcePath, 'node_modules', '.bin', 'apm')
@install(commandPath, callback)