appjam 0.1.8.7 → 0.1.8.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/README.md +9 -1
  2. data/lib/appjam/generators/help.rb +1 -1
  3. data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.pbxproj +356 -0
  4. data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.xcworkspace/xcuserdata/eiffel.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  5. data/lib/appjam/generators/templates/blank/EiffelApplication/AppDelegate.h.tt +3 -3
  6. data/lib/appjam/generators/templates/blank/EiffelApplication/AppDelegate.m.tt +5 -5
  7. data/lib/appjam/generators/templates/blank/EiffelApplication/EiffelApplication-Info.plist +1 -1
  8. data/lib/appjam/generators/templates/blank/EiffelApplication/EiffelApplication-Prefix.pch.tt +1 -1
  9. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/Toast/Toast+UIView.h +51 -0
  10. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/Toast/Toast+UIView.m +315 -0
  11. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/RaptureXML/RXMLElement.h +97 -0
  12. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/RaptureXML/RXMLElement.m +450 -0
  13. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Objective-C-HMTL-Parser/HTMLNode.h +111 -0
  14. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Objective-C-HMTL-Parser/HTMLNode.m +412 -0
  15. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Objective-C-HMTL-Parser/HTMLParser.h +37 -0
  16. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Objective-C-HMTL-Parser/HTMLParser.m +130 -0
  17. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveSugar/NSArray+ObjectiveSugar.h +39 -0
  18. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveSugar/NSArray+ObjectiveSugar.m +145 -0
  19. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveSugar/NSDictionary+ObjectiveSugar.h +18 -0
  20. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveSugar/NSDictionary+ObjectiveSugar.m +42 -0
  21. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveSugar/NSMutableArray+ObjectiveSugar.h +18 -0
  22. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveSugar/NSMutableArray+ObjectiveSugar.m +37 -0
  23. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveSugar/NSNumber+ObjectiveSugar.h +45 -0
  24. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveSugar/NSNumber+ObjectiveSugar.m +117 -0
  25. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveSugar/NSSet+ObjectiveSugar.h +21 -0
  26. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveSugar/NSSet+ObjectiveSugar.m +50 -0
  27. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveSugar/NSString+ObjectiveSugar.h +17 -0
  28. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveSugar/NSString+ObjectiveSugar.m +43 -0
  29. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveSugar/ObjectiveSugar.h +10 -0
  30. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SSKeychain/SSKeychain.h +160 -0
  31. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SSKeychain/SSKeychain.m +79 -0
  32. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SSKeychain/SSKeychainQuery.h +80 -0
  33. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SSKeychain/SSKeychainQuery.m +228 -0
  34. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SecureUDID/SecureUDID.h +75 -0
  35. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SecureUDID/SecureUDID.m +679 -0
  36. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Helpers/NSString+Versioning.h +41 -0
  37. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Helpers/NSString+Versioning.m +71 -0
  38. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Helpers/SS+Functions.h +38 -0
  39. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Helpers/SS+Functions.m +122 -0
  40. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Helpers/SS+System.h +41 -0
  41. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Helpers/SS+System.m +132 -0
  42. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Helpers/SSArguments.h +156 -0
  43. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSArray+JavaScript.h +46 -0
  44. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSArray+JavaScript.m +135 -0
  45. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSDate+JavaScript.h +42 -0
  46. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSDate+JavaScript.m +90 -0
  47. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSDictionary+JavaScript.h +38 -0
  48. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSDictionary+JavaScript.m +38 -0
  49. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSMutableArray+JavaScript.h +46 -0
  50. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSMutableArray+JavaScript.m +131 -0
  51. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSMutableDictionary+JavaScript.h +36 -0
  52. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSMutableDictionary+JavaScript.m +42 -0
  53. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSMutableString+JavaScript.h +36 -0
  54. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSMutableString+JavaScript.m +42 -0
  55. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSNumber+JavaScript.h +36 -0
  56. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSNumber+JavaScript.m +44 -0
  57. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSObject+JavaScript.h +50 -0
  58. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSObject+JavaScript.m +114 -0
  59. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSString+JavaScript.h +43 -0
  60. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/NSString+JavaScript.m +94 -0
  61. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/SS+JavaScript.h +52 -0
  62. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/SS+JavaScript.m +168 -0
  63. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/SS+Types.h +42 -0
  64. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/JavaScript/SS+Types.m +42 -0
  65. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/NSDictionary+NamedProperties.h +41 -0
  66. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/NSDictionary+NamedProperties.m +271 -0
  67. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/SS.h +36 -0
  68. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/SS.m +38 -0
  69. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/SubjectiveScript.h +67 -0
  70. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/SubjectiveScript.m +30 -0
  71. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSArray+SS.h +58 -0
  72. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSArray+SS.m +152 -0
  73. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSDate+SS.h +37 -0
  74. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSDate+SS.m +47 -0
  75. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSDictionary+SS.h +45 -0
  76. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSDictionary+SS.m +61 -0
  77. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSMutableArray+SS.h +43 -0
  78. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSMutableArray+SS.m +83 -0
  79. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSMutableDictionary+SS.h +47 -0
  80. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSMutableDictionary+SS.m +100 -0
  81. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSMutableString+SS.h +42 -0
  82. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSMutableString+SS.m +70 -0
  83. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSNumber+SS.h +51 -0
  84. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSNumber+SS.m +86 -0
  85. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSObject+SS.h +54 -0
  86. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSObject+SS.m +153 -0
  87. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSString+SS.h +46 -0
  88. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/NSString+SS.m +91 -0
  89. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/SubjectiveScript/Types/SSTypes.h +67 -0
  90. data/lib/appjam/generators/templates/blank/EiffelApplicationTests/EiffelApplicationTests-Info.plist +1 -1
  91. data/lib/appjam/generators/templates/blank/EiffelApplicationTests/EiffelApplicationTests.h.tt +5 -5
  92. data/lib/appjam/generators/templates/blank/EiffelApplicationTests/EiffelApplicationTests.m.tt +7 -7
  93. data/lib/appjam/version.rb +1 -1
  94. metadata +84 -3
@@ -0,0 +1,156 @@
1
+ //
2
+ // SSArguments.h
3
+ // SubjectiveScript.m
4
+ //
5
+ // Created by Kevin Malakoff on 7/17/12.
6
+ // Copyright (c) 2012 Kevin Malakoff. All rights reserved.
7
+ //
8
+ // Permission is hereby granted, free of charge, to any person
9
+ // obtaining a copy of this software and associated documentation
10
+ // files (the "Software"), to deal in the Software without
11
+ // restriction, including without limitation the rights to use,
12
+ // copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ // copies of the Software, and to permit persons to whom the
14
+ // Software is furnished to do so, subject to the following
15
+ // conditions:
16
+ //
17
+ // The above copyright notice and this permission notice shall be
18
+ // included in all copies or substantial portions of the Software.
19
+ //
20
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22
+ // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24
+ // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
+ // OTHER DEALINGS IN THE SOFTWARE.
28
+ //
29
+
30
+ #import "NSMutableArray+SS.h"
31
+ #import "TargetConditionals.h"
32
+
33
+ // any number of arguments of type id or NSObject terminated with nil
34
+ #define ARGS_AO(_name, _lastNamedArg) \
35
+ A* _name = A.newArguments; \
36
+ { \
37
+ va_list argList; \
38
+ va_start(argList, _lastNamedArg); \
39
+ for (NSO* arg = _lastNamedArg; arg != nil; arg = va_arg(argList, NSO*)) { [_name addObject:arg]; } \
40
+ va_end(argList); \
41
+ }
42
+
43
+ #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
44
+ // any number of arguments of type NSInteger terminated with AI_END
45
+ #define AI_END (I)NSNotFound
46
+ #define ARGS_AI(_name, _lastNamedArg) \
47
+ A* _name = A.newArguments; \
48
+ { \
49
+ va_list argList; \
50
+ va_start(argList, _lastNamedArg); \
51
+ for (I arg = _lastNamedArg; arg != AI_END; arg = va_arg(argList, I)) { [_name addObject:N.I(arg)]; } \
52
+ va_end(argList); \
53
+ }
54
+ #elif TARGET_OS_MAC
55
+ // any number of arguments of type NSInteger terminated with AI_END
56
+ #define AI_END (int)NSNotFound
57
+ #define ARGS_AI(_name, _lastNamedArg) \
58
+ A* _name = A.newArguments; \
59
+ { \
60
+ va_list argList; \
61
+ va_start(argList, _lastNamedArg); \
62
+ for (int arg = (int) _lastNamedArg; arg != AI_END; arg = va_arg(argList, int)) { [_name addObject:N.I((I)arg)]; } \
63
+ va_end(argList); \
64
+ }
65
+ #endif
66
+
67
+ // one argument of type BOOL
68
+ #define ARG_B(_name, _lastNamedArg) \
69
+ I _name; \
70
+ { \
71
+ va_list argList; \
72
+ va_start(argList, _lastNamedArg); \
73
+ _name = va_arg(argList, B); \
74
+ va_end(argList); \
75
+ }
76
+
77
+ #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
78
+ // one argument of type NSInteger
79
+ #define ARG_I(_name, _lastNamedArg) \
80
+ I _name; \
81
+ { \
82
+ va_list argList; \
83
+ va_start(argList, _lastNamedArg); \
84
+ _name = va_arg(argList, I); \
85
+ va_end(argList); \
86
+ }
87
+
88
+ // one argument of type NSUInteger
89
+ #define ARG_UI(_name, _lastNamedArg) \
90
+ UI _name; \
91
+ { \
92
+ va_list argList; \
93
+ va_start(argList, _lastNamedArg); \
94
+ _name = va_arg(argList, UI); \
95
+ va_end(argList); \
96
+ }
97
+ #elif TARGET_OS_MAC
98
+ // one argument of type NSInteger
99
+ #define ARG_I(_name, _lastNamedArg) \
100
+ I _name; \
101
+ { \
102
+ va_list argList; \
103
+ va_start(argList, _lastNamedArg); \
104
+ _name = (I) va_arg(argList, int); \
105
+ va_end(argList); \
106
+ }
107
+ // one argument of type NSUInteger
108
+ #define ARG_UI(_name, _lastNamedArg) \
109
+ UI _name; \
110
+ { \
111
+ va_list argList; \
112
+ va_start(argList, _lastNamedArg); \
113
+ _name = (UI) va_arg(argList, unsigned int); \
114
+ va_end(argList); \
115
+ }
116
+ #endif
117
+
118
+ // one argument of type float
119
+ #define ARG_F(_name, _lastNamedArg) \
120
+ F _name; \
121
+ { \
122
+ va_list argList; \
123
+ va_start(argList, _lastNamedArg); \
124
+ _name = va_arg(argList, F); \
125
+ va_end(argList); \
126
+ }
127
+
128
+ // one argument of type double
129
+ #define ARG_D(_name, _lastNamedArg) \
130
+ D _name; \
131
+ { \
132
+ va_list argList; \
133
+ va_start(argList, _lastNamedArg); \
134
+ _name = va_arg(argList, D); \
135
+ va_end(argList); \
136
+ }
137
+
138
+ // one argument of type NSNumber
139
+ #define ARG_N(_name, _lastNamedArg) \
140
+ N* _name; \
141
+ { \
142
+ va_list argList; \
143
+ va_start(argList, _lastNamedArg); \
144
+ _name = va_arg(argList, N*); \
145
+ va_end(argList); \
146
+ }
147
+
148
+ // one argument of type NSNumber
149
+ #define ARG_NSO(_name, _lastNamedArg) \
150
+ NSO* _name; \
151
+ { \
152
+ va_list argList; \
153
+ va_start(argList, _lastNamedArg); \
154
+ _name = va_arg(argList, NSO*); \
155
+ va_end(argList); \
156
+ }
@@ -0,0 +1,46 @@
1
+ //
2
+ // NSArray+JavaScript.h
3
+ // SubjectiveScript.m
4
+ //
5
+ // Created by Kevin Malakoff on 7/29/12.
6
+ // Copyright (c) 2012 Kevin Malakoff. All rights reserved.
7
+ //
8
+ // Permission is hereby granted, free of charge, to any person
9
+ // obtaining a copy of this software and associated documentation
10
+ // files (the "Software"), to deal in the Software without
11
+ // restriction, including without limitation the rights to use,
12
+ // copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ // copies of the Software, and to permit persons to whom the
14
+ // Software is furnished to do so, subject to the following
15
+ // conditions:
16
+ //
17
+ // The above copyright notice and this permission notice shall be
18
+ // included in all copies or substantial portions of the Software.
19
+ //
20
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22
+ // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24
+ // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
+ // OTHER DEALINGS IN THE SOFTWARE.
28
+ //
29
+
30
+ #import "SSTypes.h"
31
+
32
+ @interface NSArray (JavaScript)
33
+
34
+ - (NSS*(^)())toString;
35
+ - (UI)length;
36
+ - (B(^)(id key))hasOwnProperty;
37
+
38
+ // accessor Array functions
39
+ - (A*(^)(NSA* other))concat;
40
+ - (S*(^)(NSS* separator))join;
41
+ - (NSA*(^)(I start, I count))slice; // TODO: test with negative parameters
42
+
43
+ - (A*(^)())reverse;
44
+ - (A*(^)(B shallow))flatten;
45
+
46
+ @end
@@ -0,0 +1,135 @@
1
+ //
2
+ // NSArray+JavaScript.m
3
+ // SubjectiveScript.m
4
+ //
5
+ // Created by Kevin Malakoff on 7/29/12.
6
+ // Copyright (c) 2012 Kevin Malakoff. All rights reserved.
7
+ //
8
+ // Permission is hereby granted, free of charge, to any person
9
+ // obtaining a copy of this software and associated documentation
10
+ // files (the "Software"), to deal in the Software without
11
+ // restriction, including without limitation the rights to use,
12
+ // copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ // copies of the Software, and to permit persons to whom the
14
+ // Software is furnished to do so, subject to the following
15
+ // conditions:
16
+ //
17
+ // The above copyright notice and this permission notice shall be
18
+ // included in all copies or substantial portions of the Software.
19
+ //
20
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22
+ // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24
+ // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
+ // OTHER DEALINGS IN THE SOFTWARE.
28
+ //
29
+
30
+ #import "NSArray+JavaScript.h"
31
+ #import "NSArray+SS.h"
32
+ #import "NSMutableString+JavaScript.h"
33
+ #import "NSObject+JavaScript.h"
34
+ #import "NSString+SS.h"
35
+ #import "NSNumber+SS.h"
36
+ #import "SS+JavaScript.h"
37
+ #import "SS+Types.h"
38
+
39
+ @implementation NSArray (JavaScript)
40
+
41
+ - (NSS*(^)())toString { return ^{ return S.newFormatted(@"[%@]", self.join(@",")); }; }
42
+ - (UI)length { return self.count; }
43
+ - (B(^)(id key))hasOwnProperty
44
+ {
45
+ return ^B(id key) {
46
+ N* indexNumber = (N*)key;
47
+
48
+ // requesting a property
49
+ if ([key isKindOfClass:[NSString class]])
50
+ indexNumber = SS.parseInt((NSS*)key);
51
+ if (!indexNumber) return false;
52
+
53
+ I index = indexNumber.I;
54
+ return (index >=0) && (index < self.count);
55
+ };
56
+ }
57
+
58
+ // accessor Array functions
59
+ - (A*(^)(NSA* other))concat
60
+ {
61
+ return ^(NSA* other) {
62
+ return ((A*)self.mutableCopy).concat(other);
63
+ };
64
+ }
65
+
66
+ - (S*(^)(NSS* separator))join
67
+ {
68
+ return ^(NSS* separator) {
69
+ S* result = S.new;
70
+ UI count = self.count;
71
+
72
+ for (I index=0; index<count; index++) {
73
+ NSO* item = [self objectAtIndex:index];
74
+ if (index>0) result.append(separator);
75
+
76
+ // JavaScript collapses arrays on join only if they do not contain other arrays and there are multiple elements. A bit quirky, but supported.
77
+ if ((index>0) && SS.isArray(item) && (((NSA*)item).count==1)) {
78
+ B hasArrays = NO;
79
+ for (NSO* subitem in (NSA*)item) {
80
+ if (SS.isArray(subitem)) {
81
+ hasArrays = YES;
82
+ break;
83
+ }
84
+ }
85
+ if(hasArrays)
86
+ result.append(item.toString());
87
+ else
88
+ result.append(item.join(separator));
89
+ }
90
+ else
91
+ result.append(item.toString());
92
+ }
93
+ return result;
94
+ };
95
+ }
96
+
97
+ - (NSA*(^)(I start, I count))slice
98
+ {
99
+ return ^(I start, I count) {
100
+ NSRange range = self.resolveRange(start, count);
101
+ if (range.length<=0) return NSA.new;
102
+ return [self subarrayWithRange:range];
103
+ };
104
+ }
105
+
106
+ - (A*(^)())reverse
107
+ {
108
+ return ^{
109
+ return ((A*)self.mutableCopy).reverse();
110
+ };
111
+ }
112
+
113
+ + (A*)flatten:(NSA*)array shallow:(B)shallow output:(A*)output
114
+ {
115
+ for (id value in array) {
116
+ if (SS.isArray(value)) {
117
+ shallow ? [output addObjectsFromArray:value] : (void) [self flatten:value shallow:shallow output:output];
118
+ } else {
119
+ output.push(value);
120
+ }
121
+ }
122
+
123
+ return output;
124
+ }
125
+
126
+ - (A*(^)(B shallow))flatten
127
+ {
128
+ return ^(B shallow){
129
+ A* output = A.new;
130
+ [NSArray flatten:self shallow:shallow output:output];
131
+ return output;
132
+ };
133
+ }
134
+
135
+ @end
@@ -0,0 +1,42 @@
1
+ //
2
+ // NSDate+JavaScript.h
3
+ // SubjectiveScript.m
4
+ //
5
+ // Created by Kevin Malakoff on 7/29/12.
6
+ // Copyright (c) 2012 Kevin Malakoff. All rights reserved.
7
+ //
8
+ // Permission is hereby granted, free of charge, to any person
9
+ // obtaining a copy of this software and associated documentation
10
+ // files (the "Software"), to deal in the Software without
11
+ // restriction, including without limitation the rights to use,
12
+ // copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ // copies of the Software, and to permit persons to whom the
14
+ // Software is furnished to do so, subject to the following
15
+ // conditions:
16
+ //
17
+ // The above copyright notice and this permission notice shall be
18
+ // included in all copies or substantial portions of the Software.
19
+ //
20
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22
+ // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24
+ // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
+ // OTHER DEALINGS IN THE SOFTWARE.
28
+ //
29
+
30
+ #import "SSTypes.h"
31
+
32
+ @interface NSDate (JavaScript)
33
+
34
+ // note the month is 0-indexed based like JavaScript
35
+ + (Date*(^)(I year, I month, I day))newYMD_JS;
36
+
37
+ - (NSS*(^)())toString;
38
+
39
+ + (NSDateFormatter*)ISO8601Writter;
40
+ //+ (NSDateFormatter*)ISO8601Parser;
41
+
42
+ @end
@@ -0,0 +1,90 @@
1
+ //
2
+ // NSDate+JavaScript.m
3
+ // SubjectiveScript.m
4
+ //
5
+ // Created by Kevin Malakoff on 7/29/12.
6
+ // Copyright (c) 2012 Kevin Malakoff. All rights reserved.
7
+ //
8
+ // Permission is hereby granted, free of charge, to any person
9
+ // obtaining a copy of this software and associated documentation
10
+ // files (the "Software"), to deal in the Software without
11
+ // restriction, including without limitation the rights to use,
12
+ // copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ // copies of the Software, and to permit persons to whom the
14
+ // Software is furnished to do so, subject to the following
15
+ // conditions:
16
+ //
17
+ // The above copyright notice and this permission notice shall be
18
+ // included in all copies or substantial portions of the Software.
19
+ //
20
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22
+ // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24
+ // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
+ // OTHER DEALINGS IN THE SOFTWARE.
28
+ //
29
+
30
+ #import "NSDate+JavaScript.h"
31
+ // #import "ISO8601DateFormatter.h" // REVIEW: should this be part of the library?
32
+
33
+ @implementation NSDate (JavaScript)
34
+
35
+ + (Date*(^)(I year, I month, I day))newYMD_JS
36
+ {
37
+ return ^(I year, I month, I day) {
38
+ NSDateComponents *components = NSDateComponents.new;
39
+ components.calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
40
+ components.year = year;
41
+ components.month = month+1;
42
+ components.day = day;
43
+
44
+ return components.date;
45
+ };
46
+ }
47
+
48
+ - (NSS*(^)())toString
49
+ {
50
+ return ^{
51
+ return [[Date ISO8601Writter] stringFromDate:self];
52
+ };
53
+ }
54
+
55
+ + (NSDateFormatter*)ISO8601Writter
56
+ {
57
+ static NSDateFormatter *singleton = nil;
58
+ static dispatch_once_t onceToken;
59
+ dispatch_once(&onceToken, ^{
60
+ NSTimeZone *utcTimeZone = [NSTimeZone timeZoneWithName:@"UTC"];
61
+ NSCalendar *utcCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
62
+ utcCalendar.timeZone = utcTimeZone;
63
+
64
+ singleton = NSDateFormatter.new;
65
+ singleton.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.000'Z'";
66
+ singleton.timeZone = utcTimeZone;
67
+ singleton.calendar = utcCalendar;
68
+ singleton.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
69
+ });
70
+ return singleton;
71
+ }
72
+
73
+ //+ (NSDateFormatter*)ISO8601Parser
74
+ //{
75
+ // static ISO8601DateFormatter *singleton = nil;
76
+ // static dispatch_once_t onceToken;
77
+ // dispatch_once(&onceToken, ^{
78
+ // NSTimeZone *utcTimeZone = [NSTimeZone timeZoneWithName:@"UTC"];
79
+ // NSCalendar *utcCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
80
+ // utcCalendar.timeZone = utcTimeZone;
81
+ //
82
+ // singleton = ISO8601DateFormatter.new;
83
+ // singleton.format = ISO8601DateFormatCalendar;
84
+ // singleton.defaultTimeZone = utcTimeZone;
85
+ // singleton.includeTime = YES;
86
+ // });
87
+ // return (NSDateFormatter*) singleton;
88
+ //}
89
+
90
+ @end