From eea659a6b64dc9b4d53baca35d91b2851b6284d7 Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Thu, 12 Apr 2012 19:18:43 -0700 Subject: [PATCH] Add some basic Despair-specific Smalltalk --- js/Despair.deploy.js | 49 +++++++++++++++++++++++++++++++ js/Despair.js | 69 ++++++++++++++++++++++++++++++++++++++++++++ st/Despair.st | 34 ++++++++++++++++++++++ 3 files changed, 152 insertions(+) create mode 100644 js/Despair.deploy.js create mode 100644 js/Despair.js create mode 100644 st/Despair.st diff --git a/js/Despair.deploy.js b/js/Despair.deploy.js new file mode 100644 index 0000000..d4c5afd --- /dev/null +++ b/js/Despair.deploy.js @@ -0,0 +1,49 @@ +smalltalk.addPackage('Despair', {}); +smalltalk.addClass('DespairApp', smalltalk.Object, ['repos'], 'Despair'); +smalltalk.addMethod( +unescape('_bootstrap_'), +smalltalk.method({ +selector: unescape('bootstrap%3A'), +fn: function (aUsername){ +var self=this; +smalltalk.send((smalltalk.Repo || Repo), "_fetchReposFor_withEachDo_finally_", [aUsername, (function(repo){return nil;}), (function(){return nil;})]); +return self;} +}), +smalltalk.DespairApp); + +smalltalk.addMethod( +unescape('_initialize'), +smalltalk.method({ +selector: unescape('initialize'), +fn: function (){ +var self=this; +(self['@repos']=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])); +return self;} +}), +smalltalk.DespairApp); + + +smalltalk.DespairApp.klass.iVarNames = ['current']; +smalltalk.addMethod( +unescape('_current'), +smalltalk.method({ +selector: unescape('current'), +fn: function (){ +var self=this; +return (($receiver = self['@current']) == nil || $receiver == undefined) ? (function(){return (self['@current']=smalltalk.send(self, "_new", []));})() : $receiver; +return self;} +}), +smalltalk.DespairApp.klass); + +smalltalk.addMethod( +unescape('_flushCurrent'), +smalltalk.method({ +selector: unescape('flushCurrent'), +fn: function (){ +var self=this; +(self['@current']=nil); +return self;} +}), +smalltalk.DespairApp.klass); + + diff --git a/js/Despair.js b/js/Despair.js new file mode 100644 index 0000000..1687f43 --- /dev/null +++ b/js/Despair.js @@ -0,0 +1,69 @@ +smalltalk.addPackage('Despair', {}); +smalltalk.addClass('DespairApp', smalltalk.Object, ['repos'], 'Despair'); +smalltalk.addMethod( +unescape('_bootstrap_'), +smalltalk.method({ +selector: unescape('bootstrap%3A'), +category: 'initializers', +fn: function (aUsername){ +var self=this; +smalltalk.send((smalltalk.Repo || Repo), "_fetchReposFor_withEachDo_finally_", [aUsername, (function(repo){return nil;}), (function(){return nil;})]); +return self;}, +args: ["aUsername"], +source: unescape('bootstrap%3A%20aUsername%0A%09%22%20Start%20the%20application%20loading%20with%20aUsername%20%22%0A%0A%09Repo%20fetchReposFor%3A%20aUsername%0A%09%09withEachDo%3A%20%5B%20%3Arepo%20%7C%20%5D%0A%09%09finally%3A%20%5B%20%22continue%20initialization%22%20%5D.'), +messageSends: ["fetchReposFor:withEachDo:finally:"], +referencedClasses: ["Repo"] +}), +smalltalk.DespairApp); + +smalltalk.addMethod( +unescape('_initialize'), +smalltalk.method({ +selector: unescape('initialize'), +category: 'initializers', +fn: function (){ +var self=this; +(self['@repos']=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])); +return self;}, +args: [], +source: unescape('initialize%0A%09%22%20%60repos%60%20keys%20should%20be%20the%20names%20of%20the%20repositories%2C%20and%20the%20values%20should%20be%20an%20Array%20of%20each%20repo%27s%20pull%20requests%22%0A%09repos%20%3A%3D%20Dictionary%20new.'), +messageSends: ["new"], +referencedClasses: ["Dictionary"] +}), +smalltalk.DespairApp); + + +smalltalk.DespairApp.klass.iVarNames = ['current']; +smalltalk.addMethod( +unescape('_current'), +smalltalk.method({ +selector: unescape('current'), +category: 'accessors', +fn: function (){ +var self=this; +return (($receiver = self['@current']) == nil || $receiver == undefined) ? (function(){return (self['@current']=smalltalk.send(self, "_new", []));})() : $receiver; +return self;}, +args: [], +source: unescape('current%0A%09%5E%20current%20ifNil%3A%20%5B%20current%20%3A%3D%20self%20new%20%5D.'), +messageSends: ["ifNil:", "new"], +referencedClasses: [] +}), +smalltalk.DespairApp.klass); + +smalltalk.addMethod( +unescape('_flushCurrent'), +smalltalk.method({ +selector: unescape('flushCurrent'), +category: 'actions', +fn: function (){ +var self=this; +(self['@current']=nil); +return self;}, +args: [], +source: unescape('flushCurrent%0A%09current%20%3A%3D%20nil.'), +messageSends: [], +referencedClasses: [] +}), +smalltalk.DespairApp.klass); + + diff --git a/st/Despair.st b/st/Despair.st new file mode 100644 index 0000000..755e0a8 --- /dev/null +++ b/st/Despair.st @@ -0,0 +1,34 @@ +Smalltalk current createPackage: 'Despair' properties: #{}! +Object subclass: #DespairApp + instanceVariableNames: 'repos' + category: 'Despair'! + +!DespairApp methodsFor: 'initializers'! + +bootstrap: aUsername + " Start the application loading with aUsername " + + Repo fetchReposFor: aUsername + withEachDo: [ :repo | ] + finally: [ "continue initialization" ]. +! + +initialize + " `repos` keys should be the names of the repositories, and the values should be an Array of each repo's pull requests" + repos := Dictionary new. +! ! + +DespairApp class instanceVariableNames: 'current'! + +!DespairApp class methodsFor: 'accessors'! + +current + ^ current ifNil: [ current := self new ]. +! ! + +!DespairApp class methodsFor: 'actions'! + +flushCurrent + current := nil. +! ! +