iCuke 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/.gitmodules +1 -1
  2. data/Gemfile +12 -0
  3. data/Gemfile.lock +41 -0
  4. data/README.markdown +126 -0
  5. data/Rakefile +34 -12
  6. data/VERSION +1 -1
  7. data/bin/icuke +12 -10
  8. data/ext/Rakefile +6 -0
  9. data/ext/iCuke/{sdk3.1/DefaultsResponse.h → DefaultsResponse.h} +0 -0
  10. data/ext/iCuke/{sdk3.1/DefaultsResponse.m → DefaultsResponse.m} +0 -0
  11. data/ext/iCuke/{sdk3.1/EventResponse.h → EventResponse.h} +0 -0
  12. data/ext/iCuke/{sdk3.1/EventResponse.m → EventResponse.m} +0 -0
  13. data/ext/iCuke/{sdk3.1/ModuleResponse.h → ModuleResponse.h} +0 -0
  14. data/ext/iCuke/{sdk3.1/ModuleResponse.m → ModuleResponse.m} +0 -0
  15. data/ext/iCuke/{sdk3.1/QuitResponse.h → QuitResponse.h} +0 -0
  16. data/ext/iCuke/{sdk3.1/QuitResponse.m → QuitResponse.m} +0 -0
  17. data/ext/iCuke/Rakefile +14 -13
  18. data/ext/iCuke/{sdk3.1/Recorder.h → Recorder.h} +0 -0
  19. data/ext/iCuke/{sdk3.1/Recorder.m → Recorder.m} +0 -0
  20. data/ext/iCuke/{sdk3.1/RecorderResponse.h → RecorderResponse.h} +0 -0
  21. data/ext/iCuke/{sdk3.1/RecorderResponse.m → RecorderResponse.m} +0 -0
  22. data/ext/iCuke/{sdk3.1/SynthesizeSingleton.h → SynthesizeSingleton.h} +0 -0
  23. data/ext/iCuke/{sdk3.1/ViewResponse.h → ViewResponse.h} +0 -0
  24. data/ext/iCuke/{sdk3.1/ViewResponse.m → ViewResponse.m} +0 -0
  25. data/ext/iCuke/{sdk3.1/Viewer.h → Viewer.h} +0 -0
  26. data/ext/iCuke/{sdk4.0/Viewer.m → Viewer.m} +0 -0
  27. data/ext/iCuke/{sdk3.1/iCukeHTTPResponseHandler.h → iCukeHTTPResponseHandler.h} +0 -0
  28. data/ext/iCuke/{sdk3.1/iCukeHTTPResponseHandler.m → iCukeHTTPResponseHandler.m} +0 -0
  29. data/ext/iCuke/{sdk3.1/iCukeHTTPServer.h → iCukeHTTPServer.h} +0 -0
  30. data/ext/iCuke/{sdk4.0/iCukeHTTPServer.m → iCukeHTTPServer.m} +4 -2
  31. data/ext/iCuke/{sdk3.1/iCukeServer.h → iCukeServer.h} +0 -0
  32. data/ext/iCuke/{sdk3.1/iCukeServer.m → iCukeServer.m} +0 -0
  33. data/ext/iCuke/{sdk3.1/json → json}/JSON.h +0 -0
  34. data/ext/iCuke/{sdk3.1/json → json}/NSObject+SBJSON.h +0 -0
  35. data/ext/iCuke/{sdk3.1/json → json}/NSObject+SBJSON.m +0 -0
  36. data/ext/iCuke/{sdk3.1/json → json}/NSString+SBJSON.h +0 -0
  37. data/ext/iCuke/{sdk3.1/json → json}/NSString+SBJSON.m +0 -0
  38. data/ext/iCuke/{sdk3.1/json → json}/SBJSON.h +0 -0
  39. data/ext/iCuke/{sdk3.1/json → json}/SBJSON.m +0 -0
  40. data/ext/iCuke/{sdk3.1/json → json}/SBJsonBase.h +0 -0
  41. data/ext/iCuke/{sdk3.1/json → json}/SBJsonBase.m +0 -0
  42. data/ext/iCuke/{sdk3.1/json → json}/SBJsonParser.h +0 -0
  43. data/ext/iCuke/{sdk3.1/json → json}/SBJsonParser.m +0 -0
  44. data/ext/iCuke/{sdk3.1/json → json}/SBJsonWriter.h +0 -0
  45. data/ext/iCuke/{sdk3.1/json → json}/SBJsonWriter.m +0 -0
  46. data/features/starting_project.feature +18 -0
  47. data/features/step_definitions/shell.rb +41 -0
  48. data/features/support/env.rb +2 -0
  49. data/features/support/environment.rb +40 -0
  50. data/features/supported_sdks.feature +12 -0
  51. data/iCuke.gemspec +149 -161
  52. data/lib/icuke/configuration.rb +19 -0
  53. data/lib/icuke/core_ext.rb +27 -0
  54. data/lib/icuke/cucumber.rb +29 -265
  55. data/lib/icuke/cucumber_compat.rb +4 -0
  56. data/lib/icuke/icuke_world.rb +149 -0
  57. data/lib/icuke/sdk.rb +5 -13
  58. data/lib/icuke/simulator_driver.rb +201 -0
  59. data/lib/icuke/waxsim.rb +47 -9
  60. data/spec/cucumber_spec.rb +130 -0
  61. data/spec/fixtures/controls_page.xml +252 -0
  62. data/spec/process_spec.rb +76 -0
  63. data/spec/screen_spec.rb +173 -0
  64. data/spec/simulate_spec.rb +75 -0
  65. data/spec/simulator_spec.rb +28 -0
  66. data/spec/spec.opts +2 -0
  67. data/spec/spec_helper.rb +67 -0
  68. metadata +222 -121
  69. data/.gitignore +0 -15
  70. data/README.rdoc +0 -68
  71. data/ext/WaxSim/Simulator.h +0 -31
  72. data/ext/WaxSim/Simulator.m +0 -131
  73. data/ext/WaxSim/WaxSim.m +0 -110
  74. data/ext/WaxSim/WaxSim.xcodeproj/project.pbxproj +0 -238
  75. data/ext/WaxSim/WaxSim_Prefix.pch +0 -7
  76. data/ext/WaxSim/build/Release/waxsim +0 -0
  77. data/ext/WaxSim/build/Release/waxsim.dSYM/Contents/Info.plist +0 -20
  78. data/ext/WaxSim/build/Release/waxsim.dSYM/Contents/Resources/DWARF/waxsim +0 -0
  79. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/Objects-normal/x86_64/Simulator.o +0 -0
  80. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/Objects-normal/x86_64/WaxSim.o +0 -0
  81. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/Objects-normal/x86_64/waxsim.LinkFileList +0 -2
  82. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/WaxSim.dep +0 -6
  83. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/WaxSim~.dep +0 -6
  84. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/build-state.dat +0 -227
  85. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/build-state~.dat +0 -227
  86. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/waxsim-all-target-headers.hmap +0 -0
  87. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/waxsim-generated-files.hmap +0 -0
  88. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/waxsim-own-target-headers.hmap +0 -0
  89. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/waxsim-project-headers.hmap +0 -0
  90. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/waxsim.hmap +0 -0
  91. data/ext/WaxSim/iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h +0 -126
  92. data/ext/iCuke/sdk3.1/Rakefile +0 -20
  93. data/ext/iCuke/sdk3.1/Viewer.m +0 -203
  94. data/ext/iCuke/sdk3.1/iCukeHTTPServer.m +0 -365
  95. data/ext/iCuke/sdk4.0/DefaultsResponse.h +0 -5
  96. data/ext/iCuke/sdk4.0/DefaultsResponse.m +0 -66
  97. data/ext/iCuke/sdk4.0/EventResponse.h +0 -5
  98. data/ext/iCuke/sdk4.0/EventResponse.m +0 -130
  99. data/ext/iCuke/sdk4.0/ModuleResponse.h +0 -5
  100. data/ext/iCuke/sdk4.0/ModuleResponse.m +0 -76
  101. data/ext/iCuke/sdk4.0/QuitResponse.h +0 -5
  102. data/ext/iCuke/sdk4.0/QuitResponse.m +0 -23
  103. data/ext/iCuke/sdk4.0/Rakefile +0 -20
  104. data/ext/iCuke/sdk4.0/Recorder.h +0 -17
  105. data/ext/iCuke/sdk4.0/Recorder.m +0 -90
  106. data/ext/iCuke/sdk4.0/RecorderResponse.h +0 -6
  107. data/ext/iCuke/sdk4.0/RecorderResponse.m +0 -68
  108. data/ext/iCuke/sdk4.0/SynthesizeSingleton.h +0 -68
  109. data/ext/iCuke/sdk4.0/ViewResponse.h +0 -5
  110. data/ext/iCuke/sdk4.0/ViewResponse.m +0 -84
  111. data/ext/iCuke/sdk4.0/Viewer.h +0 -8
  112. data/ext/iCuke/sdk4.0/iCukeHTTPResponseHandler.h +0 -50
  113. data/ext/iCuke/sdk4.0/iCukeHTTPResponseHandler.m +0 -381
  114. data/ext/iCuke/sdk4.0/iCukeHTTPServer.h +0 -53
  115. data/ext/iCuke/sdk4.0/iCukeServer.h +0 -14
  116. data/ext/iCuke/sdk4.0/iCukeServer.m +0 -65
  117. data/ext/iCuke/sdk4.0/json/JSON.h +0 -50
  118. data/ext/iCuke/sdk4.0/json/NSObject+SBJSON.h +0 -68
  119. data/ext/iCuke/sdk4.0/json/NSObject+SBJSON.m +0 -53
  120. data/ext/iCuke/sdk4.0/json/NSString+SBJSON.h +0 -58
  121. data/ext/iCuke/sdk4.0/json/NSString+SBJSON.m +0 -55
  122. data/ext/iCuke/sdk4.0/json/SBJSON.h +0 -75
  123. data/ext/iCuke/sdk4.0/json/SBJSON.m +0 -212
  124. data/ext/iCuke/sdk4.0/json/SBJsonBase.h +0 -86
  125. data/ext/iCuke/sdk4.0/json/SBJsonBase.m +0 -78
  126. data/ext/iCuke/sdk4.0/json/SBJsonParser.h +0 -87
  127. data/ext/iCuke/sdk4.0/json/SBJsonParser.m +0 -475
  128. data/ext/iCuke/sdk4.0/json/SBJsonWriter.h +0 -129
  129. data/ext/iCuke/sdk4.0/json/SBJsonWriter.m +0 -228
@@ -1,53 +0,0 @@
1
- //
2
- // HTTPServer.h
3
- // TextTransfer
4
- //
5
- // Created by Matt Gallagher on 2009/07/13.
6
- // Copyright 2009 Matt Gallagher. All rights reserved.
7
- //
8
- // Permission is given to use this source code file, free of charge, in any
9
- // project, commercial or otherwise, entirely at your risk, with the condition
10
- // that any redistribution (in part or whole) of source code must retain
11
- // this copyright and permission notice. Attribution in compiled projects is
12
- // appreciated but not required.
13
- //
14
-
15
- #if TARGET_OS_IPHONE
16
- #import <UIKit/UIKit.h>
17
- #else
18
- #import <Cocoa/Cocoa.h>
19
- #endif
20
-
21
- typedef enum
22
- {
23
- SERVER_STATE_IDLE,
24
- SERVER_STATE_STARTING,
25
- SERVER_STATE_RUNNING,
26
- SERVER_STATE_STOPPING
27
- } iCukeHTTPServerState;
28
-
29
- @class iCukeHTTPResponseHandler;
30
-
31
- @interface iCukeHTTPServer : NSObject
32
- {
33
- NSError *lastError;
34
- NSFileHandle *listeningHandle;
35
- CFSocketRef socket;
36
- iCukeHTTPServerState state;
37
- CFMutableDictionaryRef incomingRequests;
38
- NSMutableSet *responseHandlers;
39
- }
40
-
41
- @property (nonatomic, readonly, retain) NSError *lastError;
42
- @property (readonly, assign) iCukeHTTPServerState state;
43
-
44
- + (iCukeHTTPServer *)sharediCukeHTTPServer;
45
-
46
- - (void)start;
47
- - (void)stop;
48
-
49
- - (void)closeHandler:(iCukeHTTPResponseHandler *)aHandler;
50
-
51
- @end
52
-
53
- extern NSString * const iCukeHTTPServerNotificationStateChanged;
@@ -1,14 +0,0 @@
1
- //
2
- // iCukeServer.h
3
- // iCuke
4
- //
5
- // Created by Rob Holland on 01/03/2010.
6
- // Copyright 2010 The IT Refinery. All rights reserved.
7
- //
8
-
9
- #import "iCukeHTTPServer.h"
10
-
11
- @interface iCukeServer : iCukeHTTPServer {
12
- }
13
-
14
- @end
@@ -1,65 +0,0 @@
1
- //
2
- // iCukeServer.m
3
- // iCuke
4
- //
5
- // Created by Rob Holland on 01/03/2010.
6
- // Copyright 2010 The IT Refinery. All rights reserved.
7
- //
8
-
9
- #import "iCukeServer.h"
10
- #include <unistd.h>
11
- #include <stdlib.h>
12
-
13
- @implementation iCukeServer
14
-
15
- + (void)load
16
- {
17
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
18
-
19
- [[iCukeHTTPServer sharediCukeHTTPServer] start];
20
-
21
- NSFileManager *fileManager= [[NSFileManager alloc] init];
22
- NSArray *paths;
23
-
24
- if (!getenv("ICUKE_KEEP_PREFERENCES")) {
25
- NSString *preferences = [NSHomeDirectory() stringByAppendingPathComponent: @"Library/Preferences"];
26
-
27
- paths = [fileManager contentsOfDirectoryAtPath: preferences error: NULL];
28
- for (NSString *path in paths) {
29
- NSLog(@"Found: %@", path);
30
- if (![path hasPrefix: @"."]) {
31
- NSLog(@"Removing: %@", path);
32
- unlink([[preferences stringByAppendingPathComponent: path] cStringUsingEncoding: [NSString defaultCStringEncoding]]);
33
- }
34
- }
35
- }
36
-
37
- // This is a hack, I can't find a nicer way. The iPhone Simulator's
38
- // preferences are hidden away from applications. None of the preference APIs
39
- // allow access to them.
40
- NSString *path = [NSString stringWithFormat: @"/Users/%@/Library/Application Support/iPhone Simulator/%@/Library/Preferences", NSUserName(), [[UIDevice currentDevice] systemVersion]];
41
- path = [path stringByAppendingPathComponent: @"com.apple.Accessibility.plist"];
42
- NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile: path];
43
- if (!dict) {
44
- dict = [NSMutableDictionary dictionaryWithCapacity: 2];
45
- }
46
- NSNumber *enabled = [NSNumber numberWithBool: YES];
47
- [dict setObject: enabled forKey: @"AccessibilityEnabled"];
48
- [dict setObject: enabled forKey: @"ApplicationAccessibilityEnabled"];
49
- if (![dict writeToFile: path atomically: YES]) {
50
- NSLog(@"Failed to write %@ out to %@", dict, path);
51
- }
52
-
53
- NSString *documents = [NSHomeDirectory() stringByAppendingPathComponent: @"Documents"];
54
- paths = [fileManager contentsOfDirectoryAtPath: documents error: NULL];
55
- for (NSString *path in paths) {
56
- if (![path hasPrefix: @"."]) {
57
- NSLog(@"Removing: %@", path);
58
- unlink([[documents stringByAppendingPathComponent: path] cStringUsingEncoding: [NSString defaultCStringEncoding]]);
59
- }
60
- }
61
-
62
- [pool release];
63
- }
64
-
65
- @end
@@ -1,50 +0,0 @@
1
- /*
2
- Copyright (C) 2009 Stig Brautaset. All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright notice, this
8
- list of conditions and the following disclaimer.
9
-
10
- * Redistributions in binary form must reproduce the above copyright notice,
11
- this list of conditions and the following disclaimer in the documentation
12
- and/or other materials provided with the distribution.
13
-
14
- * Neither the name of the author nor the names of its contributors may be used
15
- to endorse or promote products derived from this software without specific
16
- prior written permission.
17
-
18
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- */
29
-
30
- /**
31
- @mainpage A strict JSON parser and generator for Objective-C
32
-
33
- JSON (JavaScript Object Notation) is a lightweight data-interchange
34
- format. This framework provides two apis for parsing and generating
35
- JSON. One standard object-based and a higher level api consisting of
36
- categories added to existing Objective-C classes.
37
-
38
- Learn more on the http://code.google.com/p/json-framework project site.
39
-
40
- This framework does its best to be as strict as possible, both in what it
41
- accepts and what it generates. For example, it does not support trailing commas
42
- in arrays or objects. Nor does it support embedded comments, or
43
- anything else not in the JSON specification. This is considered a feature.
44
-
45
- */
46
-
47
- #import "SBJSON.h"
48
- #import "NSObject+SBJSON.h"
49
- #import "NSString+SBJSON.h"
50
-
@@ -1,68 +0,0 @@
1
- /*
2
- Copyright (C) 2009 Stig Brautaset. All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright notice, this
8
- list of conditions and the following disclaimer.
9
-
10
- * Redistributions in binary form must reproduce the above copyright notice,
11
- this list of conditions and the following disclaimer in the documentation
12
- and/or other materials provided with the distribution.
13
-
14
- * Neither the name of the author nor the names of its contributors may be used
15
- to endorse or promote products derived from this software without specific
16
- prior written permission.
17
-
18
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- */
29
-
30
- #import <Foundation/Foundation.h>
31
-
32
-
33
- /**
34
- @brief Adds JSON generation to Foundation classes
35
-
36
- This is a category on NSObject that adds methods for returning JSON representations
37
- of standard objects to the objects themselves. This means you can call the
38
- -JSONRepresentation method on an NSArray object and it'll do what you want.
39
- */
40
- @interface NSObject (NSObject_SBJSON)
41
-
42
- /**
43
- @brief Returns a string containing the receiver encoded as a JSON fragment.
44
-
45
- This method is added as a category on NSObject but is only actually
46
- supported for the following objects:
47
- @li NSDictionary
48
- @li NSArray
49
- @li NSString
50
- @li NSNumber (also used for booleans)
51
- @li NSNull
52
-
53
- @deprecated Given we bill ourselves as a "strict" JSON library, this method should be removed.
54
- */
55
- - (NSString *)JSONFragment;
56
-
57
- /**
58
- @brief Returns a string containing the receiver encoded in JSON.
59
-
60
- This method is added as a category on NSObject but is only actually
61
- supported for the following objects:
62
- @li NSDictionary
63
- @li NSArray
64
- */
65
- - (NSString *)JSONRepresentation;
66
-
67
- @end
68
-
@@ -1,53 +0,0 @@
1
- /*
2
- Copyright (C) 2009 Stig Brautaset. All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright notice, this
8
- list of conditions and the following disclaimer.
9
-
10
- * Redistributions in binary form must reproduce the above copyright notice,
11
- this list of conditions and the following disclaimer in the documentation
12
- and/or other materials provided with the distribution.
13
-
14
- * Neither the name of the author nor the names of its contributors may be used
15
- to endorse or promote products derived from this software without specific
16
- prior written permission.
17
-
18
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- */
29
-
30
- #import "NSObject+SBJSON.h"
31
- #import "SBJsonWriter.h"
32
-
33
- @implementation NSObject (NSObject_SBJSON)
34
-
35
- - (NSString *)JSONFragment {
36
- SBJsonWriter *jsonWriter = [SBJsonWriter new];
37
- NSString *json = [jsonWriter stringWithFragment:self];
38
- if (!json)
39
- NSLog(@"-JSONFragment failed. Error trace is: %@", [jsonWriter errorTrace]);
40
- [jsonWriter release];
41
- return json;
42
- }
43
-
44
- - (NSString *)JSONRepresentation {
45
- SBJsonWriter *jsonWriter = [SBJsonWriter new];
46
- NSString *json = [jsonWriter stringWithObject:self];
47
- if (!json)
48
- NSLog(@"-JSONRepresentation failed. Error trace is: %@", [jsonWriter errorTrace]);
49
- [jsonWriter release];
50
- return json;
51
- }
52
-
53
- @end
@@ -1,58 +0,0 @@
1
- /*
2
- Copyright (C) 2009 Stig Brautaset. All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright notice, this
8
- list of conditions and the following disclaimer.
9
-
10
- * Redistributions in binary form must reproduce the above copyright notice,
11
- this list of conditions and the following disclaimer in the documentation
12
- and/or other materials provided with the distribution.
13
-
14
- * Neither the name of the author nor the names of its contributors may be used
15
- to endorse or promote products derived from this software without specific
16
- prior written permission.
17
-
18
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- */
29
-
30
- #import <Foundation/Foundation.h>
31
-
32
- /**
33
- @brief Adds JSON parsing methods to NSString
34
-
35
- This is a category on NSString that adds methods for parsing the target string.
36
- */
37
- @interface NSString (NSString_SBJSON)
38
-
39
-
40
- /**
41
- @brief Returns the object represented in the receiver, or nil on error.
42
-
43
- Returns a a scalar object represented by the string's JSON fragment representation.
44
-
45
- @deprecated Given we bill ourselves as a "strict" JSON library, this method should be removed.
46
- */
47
- - (id)JSONFragmentValue;
48
-
49
- /**
50
- @brief Returns the NSDictionary or NSArray represented by the current string's JSON representation.
51
-
52
- Returns the dictionary or array represented in the receiver, or nil on error.
53
-
54
- Returns the NSDictionary or NSArray represented by the current string's JSON representation.
55
- */
56
- - (id)JSONValue;
57
-
58
- @end
@@ -1,55 +0,0 @@
1
- /*
2
- Copyright (C) 2007-2009 Stig Brautaset. All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright notice, this
8
- list of conditions and the following disclaimer.
9
-
10
- * Redistributions in binary form must reproduce the above copyright notice,
11
- this list of conditions and the following disclaimer in the documentation
12
- and/or other materials provided with the distribution.
13
-
14
- * Neither the name of the author nor the names of its contributors may be used
15
- to endorse or promote products derived from this software without specific
16
- prior written permission.
17
-
18
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- */
29
-
30
- #import "NSString+SBJSON.h"
31
- #import "SBJsonParser.h"
32
-
33
- @implementation NSString (NSString_SBJSON)
34
-
35
- - (id)JSONFragmentValue
36
- {
37
- SBJsonParser *jsonParser = [SBJsonParser new];
38
- id repr = [jsonParser fragmentWithString:self];
39
- if (!repr)
40
- NSLog(@"-JSONFragmentValue failed. Error trace is: %@", [jsonParser errorTrace]);
41
- [jsonParser release];
42
- return repr;
43
- }
44
-
45
- - (id)JSONValue
46
- {
47
- SBJsonParser *jsonParser = [SBJsonParser new];
48
- id repr = [jsonParser objectWithString:self];
49
- if (!repr)
50
- NSLog(@"-JSONValue failed. Error trace is: %@", [jsonParser errorTrace]);
51
- [jsonParser release];
52
- return repr;
53
- }
54
-
55
- @end
@@ -1,75 +0,0 @@
1
- /*
2
- Copyright (C) 2007-2009 Stig Brautaset. All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright notice, this
8
- list of conditions and the following disclaimer.
9
-
10
- * Redistributions in binary form must reproduce the above copyright notice,
11
- this list of conditions and the following disclaimer in the documentation
12
- and/or other materials provided with the distribution.
13
-
14
- * Neither the name of the author nor the names of its contributors may be used
15
- to endorse or promote products derived from this software without specific
16
- prior written permission.
17
-
18
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- */
29
-
30
- #import <Foundation/Foundation.h>
31
- #import "SBJsonParser.h"
32
- #import "SBJsonWriter.h"
33
-
34
- /**
35
- @brief Facade for SBJsonWriter/SBJsonParser.
36
-
37
- Requests are forwarded to instances of SBJsonWriter and SBJsonParser.
38
- */
39
- @interface SBJSON : SBJsonBase <SBJsonParser, SBJsonWriter> {
40
-
41
- @private
42
- SBJsonParser *jsonParser;
43
- SBJsonWriter *jsonWriter;
44
- }
45
-
46
-
47
- /// Return the fragment represented by the given string
48
- - (id)fragmentWithString:(NSString*)jsonrep
49
- error:(NSError**)error;
50
-
51
- /// Return the object represented by the given string
52
- - (id)objectWithString:(NSString*)jsonrep
53
- error:(NSError**)error;
54
-
55
- /// Parse the string and return the represented object (or scalar)
56
- - (id)objectWithString:(id)value
57
- allowScalar:(BOOL)x
58
- error:(NSError**)error;
59
-
60
-
61
- /// Return JSON representation of an array or dictionary
62
- - (NSString*)stringWithObject:(id)value
63
- error:(NSError**)error;
64
-
65
- /// Return JSON representation of any legal JSON value
66
- - (NSString*)stringWithFragment:(id)value
67
- error:(NSError**)error;
68
-
69
- /// Return JSON representation (or fragment) for the given object
70
- - (NSString*)stringWithObject:(id)value
71
- allowScalar:(BOOL)x
72
- error:(NSError**)error;
73
-
74
-
75
- @end