Permalink
Browse files

restart this project.

  • Loading branch information...
1 parent 62cc069 commit c642dd8b4850ae40b623730a7ebfb7f9cab5284c stig committed Mar 21, 2008
Showing with 2,528 additions and 1,511 deletions.
  1. +31 −0 Classes/SBCouchServer.h
  2. +116 −0 Classes/SBCouchServer.m
  3. +0 −32 Couch.h
  4. +262 −198 CouchObjC.xcodeproj/project.pbxproj
  5. +7 −0 CouchObjC_Prefix.pch
  6. BIN English.lproj/InfoPlist.strings
  7. +26 −0 Info.plist
  8. +0 −59 SBCouch.h
  9. +0 −300 SBCouch.m
  10. +1 −1 Tests-Info.plist
  11. +0 −56 Tests/Database.m
  12. +0 −155 Tests/Document.m
  13. +0 −47 Tests/Errors.m
  14. +16 −0 Tests/Server.h
  15. +45 −0 Tests/Server.m
  16. +0 −36 Tests/Tests.h
  17. +0 −31 Tests/Tests.m
  18. +0 −51 Tests/View.m
  19. +10 −0 vendor/JSON/CREDITS
  20. +103 −0 vendor/JSON/Docs/JensAlfkePerformanceNotes.txt
  21. +54 −0 vendor/JSON/Docs/benchmark.patch
  22. +37 −0 vendor/JSON/Docs/parser-benchmark.txt
  23. +5 −3 vendor/JSON/JSON-Info.plist
  24. +291 −27 vendor/JSON/JSON.xcodeproj/project.pbxproj
  25. +54 −32 vendor/JSON/Makefile
  26. +135 −110 vendor/JSON/Site/index.html
  27. +103 −1 vendor/JSON/Site/news.xml
  28. +20 −2 vendor/JSON/Site/style.css
  29. +1 −1 vendor/JSON/Source/JSON.h
  30. +1 −1 vendor/JSON/Source/NSObject+SBJSON.h
  31. +107 −47 vendor/JSON/Source/NSObject+SBJSON.m
  32. +0 −261 vendor/JSON/Source/NSScanner+SBJSON.m
  33. +2 −1 vendor/JSON/Source/NSString+SBJSON.h
  34. +23 −8 vendor/JSON/Source/NSString+SBJSON.m
  35. +19 −9 vendor/JSON/Source/{NSScanner+SBJSON.h → SBJSONScanner.h}
  36. +442 −0 vendor/JSON/Source/SBJSONScanner.m
  37. +19 −8 vendor/JSON/Tests/Errors.m
  38. +74 −27 vendor/JSON/Tests/Examples.m
  39. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/README
  40. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail1.json
  41. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail10.json
  42. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail11.json
  43. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail12.json
  44. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail13.json
  45. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail14.json
  46. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail15.json
  47. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail16.json
  48. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail17.json
  49. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail18.json
  50. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail19.json
  51. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail2.json
  52. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail20.json
  53. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail21.json
  54. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail22.json
  55. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail23.json
  56. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail24.json
  57. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail25.json
  58. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail26.json
  59. +2 −0 vendor/JSON/Tests/Examples/JSONChecker/fail27.json
  60. +2 −0 vendor/JSON/Tests/Examples/JSONChecker/fail28.json
  61. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail29.json
  62. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail3.json
  63. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail30.json
  64. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail31.json
  65. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail32.json
  66. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail33.json
  67. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail4.json
  68. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail5.json
  69. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail6.json
  70. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail7.json
  71. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail8.json
  72. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/fail9.json
  73. +58 −0 vendor/JSON/Tests/Examples/JSONChecker/pass1.json
  74. +1 −0 vendor/JSON/Tests/Examples/JSONChecker/pass2.json
  75. +6 −0 vendor/JSON/Tests/Examples/JSONChecker/pass3.json
  76. 0 vendor/JSON/Tests/Examples/{json.org → }/ex1.json
  77. +44 −0 vendor/JSON/Tests/Examples/ex1.plist
  78. 0 vendor/JSON/Tests/Examples/{json.org → }/ex2.json
  79. +37 −0 vendor/JSON/Tests/Examples/ex2.plist
  80. 0 vendor/JSON/Tests/Examples/{json.org → }/ex3.json
  81. +54 −0 vendor/JSON/Tests/Examples/ex3.plist
  82. 0 vendor/JSON/Tests/Examples/{json.org → }/ex4.json
  83. +185 −0 vendor/JSON/Tests/Examples/ex4.plist
  84. 0 vendor/JSON/Tests/Examples/{json.org → }/ex5.json
  85. +0 −1 vendor/JSON/Tests/Examples/json.org/README
  86. 0 vendor/JSON/Tests/Examples/{rfc4627ex1.json → rfc4627a.json}
  87. +31 −0 vendor/JSON/Tests/Examples/rfc4627a.plist
  88. 0 vendor/JSON/Tests/Examples/{rfc4627ex2.json → rfc4627b.json}
  89. +42 −0 vendor/JSON/Tests/Examples/rfc4627b.plist
  90. +27 −3 vendor/JSON/Tests/Types.m
  91. +3 −3 Couch-Info.plist → vendor/JSON/libjsontests-Info.plist
View
@@ -0,0 +1,31 @@
+//
+// SBCouchServer.h
+// CouchObjC
+//
+// Created by Stig Brautaset on 21/03/2008.
+// Copyright 2008 Stig Brautaset. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface SBCouchServer : NSObject {
+ NSString *host;
+ NSUInteger port;
+}
+
+@property (readonly) NSString *host;
+@property (readonly) NSUInteger port;
+
+/// Initialise a server object with a host and port
+- (id)initWithHost:(NSString*)h port:(NSUInteger)p;
+
+/// The server version
+- (NSString*)version;
+
+- (NSArray*)listDatabases;
+
+- (BOOL)createDatabase:(NSString*)n;
+- (BOOL)deleteDatabase:(NSString*)n;
+
+@end
View
@@ -0,0 +1,116 @@
+//
+// SBCouchServer.m
+// CouchObjC
+//
+// Created by Stig Brautaset on 21/03/2008.
+// Copyright 2008 Stig Brautaset. All rights reserved.
+//
+
+#import "SBCouchServer.h"
+#import <JSON/JSON.h>
+
+@implementation SBCouchServer
+
+@synthesize host;
+@synthesize port;
+
+- (id)initWithHost:(NSString*)h port:(NSUInteger)p
+{
+ if (self = [super init]) {
+ host = [h copy];
+ port = p;
+
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [host release];
+ [super dealloc];
+}
+
+- (id)init
+{
+ return [self initWithHost:@"localhost" port:5984];
+}
+
+- (NSString*)version
+{
+ NSString *server = [NSString stringWithFormat:@"http://%@:%u", self.host, self.port];
+ NSURL *url = [NSURL URLWithString:server];
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
+
+ NSError *error;
+ NSHTTPURLResponse *response;
+ NSData *data = [NSURLConnection sendSynchronousRequest:request
+ returningResponse:&response
+ error:&error];
+
+ if (data) {
+ NSString *json = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
+ NSDictionary *dict = [json JSONValue];
+ return [dict valueForKey:@"version"];
+ }
+
+ NSLog(@"Error occured.\nError: %@\nResponse: %@", error, response);
+ return nil;
+}
+
+- (BOOL)createDatabase:(NSString*)db
+{
+ NSString *escaped = [db stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+ NSString *server = [NSString stringWithFormat:@"http://%@:%u/%@", self.host, self.port, escaped];
+ NSURL *url = [NSURL URLWithString:server];
+
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
+ [request setHTTPMethod:@"PUT"];
+
+ NSError *error;
+ NSHTTPURLResponse *response;
+ (void)[NSURLConnection sendSynchronousRequest:request
+ returningResponse:&response
+ error:&error];
+
+ return 201 == [response statusCode];
+}
+
+- (BOOL)deleteDatabase:(NSString*)db
+{
+ NSString *escaped = [db stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+ NSString *server = [NSString stringWithFormat:@"http://%@:%u/%@", self.host, self.port, escaped];
+ NSURL *url = [NSURL URLWithString:server];
+
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
+ [request setHTTPMethod:@"DELETE"];
+
+ NSError *error;
+ NSHTTPURLResponse *response;
+ (void)[NSURLConnection sendSynchronousRequest:request
+ returningResponse:&response
+ error:&error];
+
+ return 202 == [response statusCode];
+}
+
+- (NSArray*)listDatabases
+{
+ NSString *server = [NSString stringWithFormat:@"http://%@:%u/_all_dbs", self.host, self.port];
+ NSURL *url = [NSURL URLWithString:server];
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
+
+ NSError *error;
+ NSHTTPURLResponse *response;
+ NSData *data = [NSURLConnection sendSynchronousRequest:request
+ returningResponse:&response
+ error:&error];
+
+ if (200 == [response statusCode]) {
+ NSString *json = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
+ return [json JSONValue];
+ }
+
+ return nil;
+}
+
+@end
View
32 Couch.h
@@ -1,32 +0,0 @@
-/*
-Copyright (c) 2007, Stig Brautaset. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- Neither the name of the author nor the names of its contributors may be used
- to endorse or promote products derived from this software without specific
- prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#import <Cocoa/Cocoa.h>
-
-#import <Couch/SBCouch.h>
Oops, something went wrong.

0 comments on commit c642dd8

Please sign in to comment.