From 93bef861dffb359d93084fe2cacd654231f19931 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Fri, 22 Mar 2013 13:51:04 -0700 Subject: [PATCH] Remove unused stdlib files --- src/stdlib/settings.coffee | 55 -------------------------------------- src/stdlib/storage.coffee | 39 --------------------------- src/stdlib/watcher.coffee | 50 ---------------------------------- 3 files changed, 144 deletions(-) delete mode 100644 src/stdlib/settings.coffee delete mode 100644 src/stdlib/storage.coffee delete mode 100644 src/stdlib/watcher.coffee diff --git a/src/stdlib/settings.coffee b/src/stdlib/settings.coffee deleted file mode 100644 index e3eadea85..000000000 --- a/src/stdlib/settings.coffee +++ /dev/null @@ -1,55 +0,0 @@ -fs = require 'fs-utils' -CoffeeScript = require 'coffee-script' - -# Settings file looks like: -# editor: # name of class -# theme: "twilight" -# tabSize: 2 -# softTabs: true -# showInvisibles: false -# -# project: -# ignorePattern: /x|y|z/ -# -# Settings are applied to object x's settings variable by calling applyTo(x) on -# instance of Settings. -module.exports = -class Settings - settings: {} - - load: (path) -> - path = require.resolve path - if not fs.isFile path - console.warn "Could not find settings file '#{path}'" - return - - try - json = CoffeeScript.eval "return " + (fs.read path) - - for className, value of json - @settings[@simplifyClassName className] = value - catch error - console.error "Can't evaluate settings at `#{path}`." - console.error error - - applyTo: (object) -> - if not object.settings - console.warning "#{object.constructor.name}: Does not have `settings` varible" - return - - classHierarchy = [] - - # ICK: Using internal var __super to get the build heirarchy - walker = object - while walker - classHierarchy.unshift @simplifyClassName walker.constructor.name - walker = walker.constructor.__super__ - - for className in classHierarchy - for setting, value of @settings[className] ? {} - object.settings[setting] = value - - # I don't care if you use camelCase, underscores or dashes. It should all - # point to the same place - simplifyClassName: (className) -> - className.toLowerCase().replace /\W/, '' diff --git a/src/stdlib/storage.coffee b/src/stdlib/storage.coffee deleted file mode 100644 index 9a3334b29..000000000 --- a/src/stdlib/storage.coffee +++ /dev/null @@ -1,39 +0,0 @@ -module.exports = -class Storage - storagePath: (require.resolve '~/.atom/.storage') - - get: (key, defaultValue=null) -> - try - value = @storage().valueForKeyPath key - @toJS value or defaultValue - catch error - error.message += "\nGetting #{key}" - console.error(error) - - set: (key, value) -> - keys = key.split '.' - parent = storage = @storage() - for key in keys.slice 0, -1 - parent[key] = {} unless parent[key] - parent = parent[key] - - parent[keys.slice -1] = value - storage.writeToFile_atomically @storagePath, true - - storage: -> - storage = OSX.NSMutableDictionary.dictionaryWithContentsOfFile @storagePath - storage ?= OSX.NSMutableDictionary.dictionary - - toJS: (value) -> - if not value or not value.isKindOfClass - value - else if value.isKindOfClass OSX.NSDictionary.class - dict = {} - dict[k.valueOf()] = @toJS v for k, v of value - dict - else if value.isKindOfClass OSX.NSArray.class - array = [] - array.push @toJS v for v in value - array - else - value.valueOf() diff --git a/src/stdlib/watcher.coffee b/src/stdlib/watcher.coffee deleted file mode 100644 index 2ea02ff96..000000000 --- a/src/stdlib/watcher.coffee +++ /dev/null @@ -1,50 +0,0 @@ -module.exports = -class Watcher - @watchedPaths: {} - - @setup: -> - if not OSX.__AAWatcher__ - OSX.__AAWatcher__ = OSX.JSCocoa.createClass_parentClass "__AAWatcher__", "NSObject" - OSX.JSCocoa.addInstanceMethod_class_jsFunction_encoding "watcher:receivedNotification:forPath:", OSX.__AAWatcher__, @watcher_receivedNotification_forPath, "v:@@@@" - - @delegate = OSX.__AAWatcher__.alloc.init - @queue = OSX.UKKQueue.alloc.init - @queue.setDelegate @delegate - - @watch: (path, callback) -> - @setup() unless @queue? - - path = OSX.NSString.stringWithString(path).stringByStandardizingPath - @queue.addPath path if not @watchedPaths[path] - - (@watchedPaths[path] ?= []).push callback - - callback # Handy for anonymous functions. - - @unwatch: (path, callback=null) -> - return unless @watchedPaths[path] - - @watchedPaths[path] = (item for item in @watchedPaths[path] when item != callback) - if not callback? or @watchedPaths[path].length == 0 - @watchedPaths[path] = null - console.log "Unwatch #{path}" - @queue.removePathFromQueue path - - # Delegate method for __AAWatcher__ - @watcher_receivedNotification_forPath = (queue, notification, path) => - callbacks = @watchedPaths[path] ? [] - - switch notification.toString() - when "UKKQueueFileRenamedNotification" - throw "Doesn't handle this yet" - when "UKKQueueFileDeletedNotification" - @watchedPaths[path] = null - @queue.removePathFromQueue path - callback notification, path, callback for callback in callbacks - when "UKKQueueFileWrittenToNotification" - callback notification, path, callback for callback in callbacks - when "UKKQueueFileAttributesChangedNotification" - # Just ignore this - console.log "Attribute Changed on #{path}" - else - console.error "I HAVE NO IDEA WHY #{notification} WAS TRIGGERED ON #{path}"