[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Sc-devel] packages




I checked in Quarks/packages.sc


this is useful for determining dependencies, but also for iterating over all classes in a given package for testing/documentation etc.


Main.packages.do(_.postln)


(ProcessTools -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/quarks/ProcessTools)

(CrucialTests -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/quarks/CrucialTests)

(UnitTesting -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/quarks/UnitTesting)

(CommonTests -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/quarks/CommonTests)

(cxpatterns -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/quarks/cxpatterns)

(TabbedView -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/quarks/TabbedView)

(ixiViews -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/quarks/ixiViews)

(cxaudio -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/quarks/cxaudio)

(MathLib -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/quarks/MathLib)

(flatdb -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/quarks/flatdb)

(Felix -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/quarks/felix)

(ixi -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/quarks/ixi)

(MP3 -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/quarks/MP3)

(backwards_compatibility -> /Users/crucial/scsvn/sctrunk/build/SCClassLibrary/backwards_compatibility/)

(DefaultLibrary -> /Users/crucial/scsvn/sctrunk/build/SCClassLibrary/DefaultLibrary/)

(Platform -> /Users/crucial/scsvn/sctrunk/build/SCClassLibrary/Platform/)

(crucial -> /Users/crucial/scsvn/sctrunk/build/SCClassLibrary/crucial/)

(JITLib -> /Users/crucial/scsvn/sctrunk/build/SCClassLibrary/JITLib/)

(Common -> /Users/crucial/scsvn/sctrunk/build/SCClassLibrary/Common/)

(MCLD -> /Users/crucial/scsvn/sctrunk/build/SCClassLibrary/MCLD/)

(SCClassLibrary -> /Users/crucial/scsvn/sctrunk/build/SCClassLibrary/)

(SwingOSC -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/SwingOSC/)

(Extensions -> /Users/crucial/Library/Application Support/SuperCollider/Extensions/)


ie. all quarks plus DefaultLibrary, crucial, jitlib, any others you have in there.



// what package am I in ?

Pdef.package

JITLib



Quark.find("CommonTests")


Quark.find("CommonTests").definesClasses

[ class TestBuffer, class TestCollection, class TestControlSpec, class TestCurveWarp, class TestEnv, class TestFloat, class TestMixedBundle, class TestNetAddr, class TestOSCBundle, class TestPattern, class TestSCCompositeView, class TestSCHLayoutView, class TestSCScrollView, class TestServer ]



// not a quark, but the Quarks package manager can analyze its classes

Quarks.classesInPackage('Common')


// returns 1 method

Quark.find("UnitTesting").definesExtensionMethods


// assuming you have ixi currently installed

// extension methods and the package of the owner class

Quark.find("ixi").definesExtensionMethods.do({ |meth| [meth.asString,meth.ownerClass.package].postln })

[ Method Function:record, Common ]

[ Method Point:distanceFrom, Common ]

[ Method SCEnvelopeView:env2viewFormat_, Common ]

[ Method SCEnvelopeView:view2envFormat, Common ]

[ Method SCSlider:defaultKeyDownAction, Common ]

[ Method SCSlider:incrementCtrl, Common ]

[ Method SCSlider:decrementCtrl, Common ]

[ Method SimpleNumber:midiIsMicroTone, Common ]

[ Method SimpleNumber:freqIsMicroTone, Common ]



// the quark overwrites methods in the following package(s):  Common

Quark.find("ixi").definesExtensionMethods.select({ |meth| meth.ownerClass.package != 'ixi' })

.collect({ |meth| meth.ownerClass.package }).as(Set)


so its one or two steps away from Quark-checkDependencies

which would double check or even automatically set your dependencies.

it would also write into your quark file with what extension methods you add and/or overwrite from which other packages.


 



UnitTest.classesWithTests('crucial') // in package


so you could run tests within a package


UnitTest.classesWithoutTests('crucial').do(_.postln) // in package



(

// list all methods without tests written

// look through the list for things that really need it

UnitTest.classesWithTests('Common').do({ |c| 

c.postln;

UnitTest.findTestClass(c).untestedMethods.do({ |meth|

Post << Char.tab << meth.asString << Char.nl;

})

})

)



(

// methods without tests sorted by code size

// because longer methods have a higher chance of having side effects

UnitTest.classesWithTests('crucial').collect({ |c| 

UnitTest.findTestClass(c).untestedMethods

}).flat.reject(_.isNil)

.sort({ |metha,methb| metha.code.size > methb.code.size })

.do({ |meth|

meth.asString.postln;

})

// only of classes already having a test class

)