- CypressFileTreeReader
added: #readPackage:as:from:
changed: #readPackage:from:
category of:8 methods
- CypressAbstractWriter
category of:11 methods
- CypressRepository
added:
#packageDirectoryForPackageName:in:
#read:as:
changed:
#initialize
#read:
category of:
#read:
#writer
- CypressAbstractReader
class definition
added:
#packageDirectoryForPackageName:in:
#readPackage:as:from:
#readPackage:from:
- extensions
...
--- a/CypressAbstractReader.st Tue Sep 18 10:40:17 2012 +0000
+++ b/CypressAbstractReader.st Tue Sep 18 13:00:02 2012 +0000
@@ -1,7 +1,7 @@
"{ Package: 'stx:goodies/cypress' }"
CypressAbstractReaderWriter subclass:#CypressAbstractReader
- instanceVariableNames:''
+ instanceVariableNames:'packageId'
classVariableNames:''
poolDictionaries:''
category:'Cypress-New-Reader & Writer'
@@ -28,6 +28,20 @@
"
! !
+!CypressAbstractReader methodsFor:'reading'!
+
+readPackage:arg1 as:arg2 from:arg3
+ "raise an error: must be redefined in concrete subclass(es)"
+
+ ^ self subclassResponsibility
+!
+
+readPackage: name from: directory
+ ^self readPackage: name as: nil from: directory
+
+ "Created: / 18-09-2012 / 09:43:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!CypressAbstractReader class methodsFor:'documentation'!
version_SVN
--- a/CypressFileTreeReader.st Tue Sep 18 10:40:17 2012 +0000
+++ b/CypressFileTreeReader.st Tue Sep 18 13:00:02 2012 +0000
@@ -33,7 +33,29 @@
"Created: / 18-09-2012 / 09:44:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
-!CypressFileTreeReader methodsFor:'reading-model'!
+!CypressFileTreeReader methodsFor:'reading'!
+
+readPackage: name as: packageIdOrNil from: directory
+ | pkgdir pkg |
+
+ pkgdir := CypressRepository packageDirectoryForPackageName: name in: directory.
+ pkgdir isNil ifTrue:[
+ self error: 'No package named ', name ,' found in ', directory pathName.
+ ].
+
+ packageId := packageIdOrNil.
+
+ pkg := CypressPackage new.
+ self
+ readPropertiesFor: pkg from: pkgdir;
+ readClassesFor: pkg from: pkgdir;
+ readExtensionsFor: pkg from: pkgdir.
+ ^pkg
+
+ "Created: / 18-09-2012 / 13:16:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!CypressFileTreeReader methodsFor:'reading-private'!
readClass: name from: directory
| clsdir cls |
@@ -56,52 +78,6 @@
"Created: / 18-09-2012 / 09:54:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-readMethod: name from: directory
- | mthdfile mthd |
-
- mthdfile := directory / name.
- mthdfile exists ifFalse:[
- mthdfile := mthdfile withSuffix: self defaultFileSuffixForMethod.
- ].
- mthdfile exists ifFalse:[
- self error: 'No such method in ', directory pathName.
- ^nil.
- ].
-
- mthd := CypressMethod new.
- mthdfile readingFileDo:[:s|
- mthd category: s nextLine.
- mthd source: s upToEnd.
- ].
- ^mthd
-
- "Created: / 18-09-2012 / 10:03:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-readPackage: name from: directory
- | pkgdir pkg |
-
- pkgdir := directory / name.
- pkgdir exists ifFalse:[
- pkgdir := pkgdir withSuffix: self defaultFileSuffixForPackage.
- ].
- pkgdir exists ifFalse:[
- self error: 'No such package in ', directory pathName.
- ^nil.
- ].
-
- pkg := CypressPackage new.
- self
- readPropertiesFor: pkg from: pkgdir;
- readClassesFor: pkg from: pkgdir;
- readExtensionsFor: pkg from: pkgdir.
- ^pkg
-
- "Created: / 18-09-2012 / 09:43:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
-!CypressFileTreeReader methodsFor:'reading-utils'!
-
readClassesFor: pkg from: directory
directory directoryContentsAsFilenamesDo:[:each|
@@ -135,6 +111,28 @@
"Created: / 18-09-2012 / 10:11:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+readMethod: name from: directory
+ | mthdfile mthd |
+
+ mthdfile := directory / name.
+ mthdfile exists ifFalse:[
+ mthdfile := mthdfile withSuffix: self defaultFileSuffixForMethod.
+ ].
+ mthdfile exists ifFalse:[
+ self error: 'No such method in ', directory pathName.
+ ^nil.
+ ].
+
+ mthd := CypressMethod new.
+ mthdfile readingFileDo:[:s|
+ mthd category: s nextLine.
+ mthd source: s upToEnd.
+ ].
+ ^mthd
+
+ "Created: / 18-09-2012 / 10:03:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
readMethodsFor: cls from: directory
| dir |
--- a/CypressRepository.st Tue Sep 18 10:40:17 2012 +0000
+++ b/CypressRepository.st Tue Sep 18 13:00:02 2012 +0000
@@ -47,6 +47,28 @@
"Created: / 13-09-2012 / 14:49:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!CypressRepository class methodsFor:'private'!
+
+packageDirectoryForPackageName: pkgName in: repoDir
+ | pkgDir |
+
+ pkgDir := repoDir / pkgName.
+ pkgDir exists ifTrue:[ ^ pkgDir ].
+
+ "/Try add .package"
+ pkgDir := pkgDir withSuffix: self defaultFileSuffixForPackage.
+ pkgDir exists ifTrue:[ ^ pkgDir ].
+
+ "/Hmm...maybe stx package name
+ pkgDir := repoDir / ((pkgName asString copy replaceAll:$: with:$_; replaceAll:$/ with:$_) , '.' , self defaultFileSuffixForPackage).
+ pkgDir exists ifTrue:[ ^ pkgDir ].
+
+ "/ No luck, return nil
+ ^nil
+
+ "Created: / 18-09-2012 / 13:33:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!CypressRepository methodsFor:'accessing'!
directory
@@ -66,12 +88,6 @@
"Modified: / 17-09-2012 / 22:29:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-reader
- ^readerClass onRepository: self
-
- "Created: / 18-09-2012 / 09:21:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
readerClass
^ readerClass
!
@@ -80,12 +96,6 @@
readerClass := something.
!
-writer
- ^writerClass onRepository: self
-
- "Created: / 17-09-2012 / 22:22:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
writerClass
^ writerClass
!
@@ -110,7 +120,7 @@
| props |
writerClass := CypressWriter.
- readerClass := CypressReader.
+ readerClass := nil.
directory isNil ifTrue:[ ^ self ].
directory exists ifFalse:[ ^ self ].
@@ -135,17 +145,47 @@
^ self shouldNotImplement
"Modified: / 18-09-2012 / 10:58:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+writer
+ ^writerClass onRepository: self
+
+ "Created: / 17-09-2012 / 22:22:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!CypressRepository methodsFor:'reading'!
+
+read: packageName
+
+ ^self read: packageName as: nil
+
+ "Created: / 18-09-2012 / 09:34:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+read: packageName as: packageId
+ | readerCls |
+
+ readerCls := readerClass.
+ readerCls isNil ifTrue:[
+ | pdir |
+
+ pdir := self class packageDirectoryForPackageName: packageName in: directory.
+ pdir notNil ifTrue:[
+ readerCls := (pdir / 'properties.json') exists
+ ifTrue:[CypressFileTreeReader]
+ ifFalse:[CypressReader].
+ ] ifFalse:[
+ self error:'No such package found'.
+ ].
+ ].
+
+ ^(readerCls onRepository: self) readPackage: packageName as: packageId from: directory
+
+ "Created: / 18-09-2012 / 13:15:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CypressRepository methodsFor:'writing'!
-read: packageName
-
- ^self reader readPackage: packageName from: directory
-
- "Created: / 18-09-2012 / 09:34:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
write: packageIdOrProjectDefinition
self writer writePackage: packageIdOrProjectDefinition asCypressPackage to: directory
--- a/cypress.rc Tue Sep 18 10:40:17 2012 +0000
+++ b/cypress.rc Tue Sep 18 13:00:02 2012 +0000
@@ -25,7 +25,7 @@
VALUE "LegalCopyright", "Copyright Jan Vrany & Dale Henrichs 2012\0"
VALUE "ProductName", "Cypress\0"
VALUE "ProductVersion", "6.2.3.1\0"
- VALUE "ProductDate", "Tue, 18 Sep 2012 10:41:05 GMT\0"
+ VALUE "ProductDate", "Tue, 18 Sep 2012 13:00:33 GMT\0"
END
END