Skip to content

Instantly share code, notes, and snippets.

@peteruhnak
Last active June 25, 2017 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peteruhnak/d8709fe43cdbe6c0cc4fd4a56ab5781e to your computer and use it in GitHub Desktop.
Save peteruhnak/d8709fe43cdbe6c0cc4fd4a56ab5781e to your computer and use it in GitHub Desktop.
Pharo RPackage pseudo-docs

Packages RPackage

Retrieving existing package by name

  • 'MyPackage' asPackage
  • RPackage organizer packageNamed: 'MyPackage'

Create package

  • (RPackage named: 'MyPackage') register
pkg := (RPackage named: 'MyPackage').
RPackage organizer registerPackage: pkg.

Rename package

  • 'MyPackage' asPackage renameTo: 'YourPackage'

Remove package

  • 'MyPackage' asPackage unregister - this will NOT remove the classes (they will be in _UnpackagedPackage)
    • you might need 'MyPackage' asPackage definedClasses do: [ :each | each removeFromSystem ]

Tags RPackageTag (package tags / class tags)

Create tag

  • classTag := 'MyPackage' asPackage addClassTag: 'tag'

Retrieve tag from package

  • all tags - 'Nautilus' asPackage classTags
  • by name - 'Nautilus' asPackage classTagNamed: 'Tree'

Rename tag

  • ('Nautilus' asPackage classTagNamed: 'Tree') renameTo: 'Forest'
    • Btw. Nautilus seems to ignore this kind of change and I have to close and open tags tree to see the updated name

Remove tag

  • 'MyPackage' asPackage removeClassTag: 'tag'
    • removal of classes is required

Classes Class and packages/tags

Get package of a class

  • MyClass package

Get tag of a class

  • MyClass package classTagForClass: MyClass
    • the default tag (e.g. if you don't see any in Nautilus) has the same name as the package itself.

Move class to a package/tag

  • 'MyPackage' asPackage addClass: MyClass
  • ('MyPackage' asPackage classTagNamed: 'Tree') addClass: MyClass

More examples

Moving class to a tag and ensuring it exists

pkg := 'MyPackage' asPackage.
(pkg classTagNamed: 'tag' ifAbsent: [ pkg addClassTag: 'tag' ]) addClass: MyClass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment