apigee/usergrid-ios-sdk — pull request #6 by timburks (2013-04-15 23:20:57+00:00)
Title: New SDK classes and tools for unit testing.

This commit adds new classes in the UGAPI/v2 directory that
provide direct access to the Usergrid HTTP API. Instances
of the UGConnection class can be used to create NSMutableURLRequests
that can then be performed to call the Usergrid API. These
calls can be made with any HTTP framework desired by the
app developer, but as a convenience, this commit also includes
the UGHTTPClient class, which can make calls synchronously or
asynchronously. Synchronous calls will block and return a
UGHTTPResult instance, and asynchronous calls take C blocks
which they call when the requests complete or fail. All
information about HTTP calls is returned in the UGHTTPResult
instance, including errors. This gives app developers full
visibility of any network problems that could occur.

It is also now possible to build the SDK on the command line
as a Mac framework, which can then be used to interactively
use the SDK from the command line or to write interpreted
utilities and unit tests. This requires Nu (http://programming.nu).
Builds and tests are supported by the included "Nukefile".
After installing Nu, you can type "nuke" at the command
line to build Usergrid.framework, and "nuke install" to
install Usergrid.framework in /Library/Frameworks. Then
you can interact with the Usergrid.framework using the Nu
shell by typing "nush" at the command line.

========= EXAMPLE ==========
tim% nush
Nu Shell.
% (load "Usergrid")
t
% (set client ((UGClient alloc) initWithOrganizationId:"1hotrod" withApplicationID:"fred"))

% (set response (client logInUser:"alice" password:"test1test"))

% (set object ((response rawResponse) JSONValue))
<__NSDictionaryM:7fc7ddb1e900>
% (puts (object JSONValue))
Nu uncaught exception: NuUndefinedSymbol: undefined symbol JSONValue while evaluating expression (object JSONValue)
from :1: in object
from :1: in puts

% (puts (object description))
{
"access_token" = YWMtTqsVbqYiEeKmQALoGuNOzAAAAT40B3oDr8iBRVTNHwVgBc3TL63UVqHO4LM;
"expires_in" = 604800;
user = {
activated = 1;
created = 1359834587923;
email = "alice@alice.com";
modified = 1359834587923;
name = alice;
picture = "http://www.gravatar.com/avatar/37bed650c57b657c441a586579edfea6";
type = user;
username = alice;
uuid = "b32b56df-6d71-11e2-81cf-02e81ac5a17b";
"validate-password" = test1test;
};
}
()
%
============================

To run the unit tests, type "nuke test" at the command line.

For more information about Nu, see http://programming.nu and http://github.com/timburks/nu