Happy !

TorstenBergmann / Hubcap

Project infos

License MIT
Tags
Creation date 2014-11-12
Website

Monticello registration

About Hubcap

Hubcap for Pharo

Project info

The "Hubcap for Project" is a small project to provide an API and UI to access SmalltalkHub from within the Pharo image.

With this tool you can access the SmalltalkHub users, projects and packages directly.

Project location

The project is located on STHub at http://smalltalkhub.com/#!/~TorstenBergmann/Hubcap

Demo

not yet provided

Screenshot

not yet provided

License

Hubcap is licensed under MIT License.

Installation

You can access Hubcap from the Pharo configuration browser. Just select "Tools" -> "Configuration Browser" from the world menu, enter "Hubcap" and install the stable version. After that you will find a tool "SmalltalkHub Browser" in the world menu.

Alternatively to install the packages manually into your Pharo image just evaluate:

Gofer new
    url: 'http://smalltalkhub.com/mc/TorstenBergmann/Hubcap/main';
    package: 'ConfigurationOfHubcap';
    load.
((Smalltalk at: #ConfigurationOfHubcap) project stableVersion) load.

Use in your own application

Necessary packages

If you need access to SmalltalkHub in your own application you can use the package "Hubcap-Core". This one includes classes with an API to access SmalltalkHub.

Use in your code

Working with users

The most important class to use is the class HubClient. Internally this class uses a ZnClient instance to retrieve informations from Smalltalk via HTTP. As the SmalltalkHub interface is JSON based the NeoJSON package is used to transform to Smalltalk objects again.

With the class HubClient you do not have to care about the internals of the SmalltalkHub API but can use this class to access the informations directly.

The class HubClient

For instance the following expression:

HubClient new allUserNames

will retrieve all user names from SmalltalkHub and return them as a collection of Strings.

As we want to work with real objects (instead of plain Strings) a basic model of the SmalltalkHub entities is part of the package Hubcap-Core in the Model category. There you will find the following classes:

The hierarchy of Hub objects

So to retrieve real user objects you can use

HubClient new allUsers inspect

which will return instances of HubUser class.

HubClient new allUsers do: [:each | 
    Transcript show: each userName ].

There is also a method to check specific users:

 HubClient new userNamesIncludingSubString: 'Berg'

will retrieve several users like 'abergel' or 'TorstenBergmann' and 'SvenVanCaekenberghe' as these names include the String 'Berg' as part of the name.

You can also check if SmalltalkHub knows about a specific username:

HubClient new hasUserNamed: 'TorstenBergmann'

Checkout the example methods on the class side of class HubClient.

Working with projects

Packages

  • Hubcap-Core - package with the core, contains anything you need in an own app
  • Hubcap-Tests-Core - package with the SUnit tests for the core package
  • Hubcap-Tools - Tools for Pharo including the SmalltalkHub Browser

Testing

The package comes with many tests in the package Hubcap-Tests-Core. Just use the SUnit TestRunner to run them.