Remove unused stdlib files

This commit is contained in:
Corey Johnson
2013-03-22 13:51:04 -07:00
parent 7e6dc68bca
commit 93bef861df
3 changed files with 0 additions and 144 deletions

View File

@@ -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/, ''

View File

@@ -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()

View File

@@ -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}"