appjam 0.1.8.6 → 0.1.8.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/appjam.rb +1 -1
- data/lib/appjam/generators/blank.rb +133 -0
- data/lib/appjam/generators/help.rb +5 -3
- data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.pbxproj +855 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.xcworkspace/xcuserdata/eiffel.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/xcuserdata/eiffel.xcuserdatad/xcschemes/EiffelApplication.xcscheme +96 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/xcuserdata/eiffel.xcuserdatad/xcschemes/xcschememanagement.plist +27 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/AppDelegate.h.tt +22 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/AppDelegate.m.tt +156 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/EiffelApplication-Info.plist +45 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/EiffelApplication-Prefix.pch.tt +30 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/en.lproj/InfoPlist.strings +2 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFHTTPClient.h +636 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFHTTPClient.m +1359 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFHTTPRequestOperation.m +318 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFImageRequestOperation.h +108 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFImageRequestOperation.m +234 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFJSONRequestOperation.m +142 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFNetworkActivityIndicatorManager.m +145 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFNetworking.h +43 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFPropertyListRequestOperation.m +142 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFURLConnectionOperation.h +379 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFURLConnectionOperation.m +818 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFXMLRequestOperation.m +166 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/UIImageView+AFNetworking.m +184 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/JSONKit/JSONKit.h +251 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/JSONKit/JSONKit.m +3067 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabase.h +155 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabase.m +1162 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabaseAdditions.h +37 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabaseAdditions.m +163 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabasePool.h +75 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabasePool.m +244 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabaseQueue.h +38 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabaseQueue.m +176 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMResultSet.h +104 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMResultSet.m +413 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/EGOCache/EGOCache.h +78 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/EGOCache/EGOCache.m +370 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDASLLogger.h +41 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDASLLogger.m +99 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDAbstractDatabaseLogger.m +727 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDFileLogger.h +334 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDFileLogger.m +1353 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDLog.h +601 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDLog.m +1083 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDTTYLogger.h +167 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDTTYLogger.m +1479 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveMixin/Mixin.h +33 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveMixin/Mixin.m +122 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USArrayWrapper.h +72 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USArrayWrapper.m +305 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USConstants.h +38 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USDictionaryWrapper.h +57 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USDictionaryWrapper.m +188 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore+Functional.h +89 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore+Functional.m +261 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore-Prefix.pch +7 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore.h +50 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore.m +100 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/main.m.tt +18 -0
- data/lib/appjam/generators/templates/blank/EiffelApplicationTests/EiffelApplicationTests-Info.plist +22 -0
- data/lib/appjam/generators/templates/blank/EiffelApplicationTests/EiffelApplicationTests.h.tt +13 -0
- data/lib/appjam/generators/templates/blank/EiffelApplicationTests/EiffelApplicationTests.m.tt +32 -0
- data/lib/appjam/generators/templates/blank/EiffelApplicationTests/en.lproj/InfoPlist.strings +2 -0
- data/lib/appjam/generators/templates/resources/Default-568h@2x.png +0 -0
- data/lib/appjam/generators/templates/resources/Default.png +0 -0
- data/lib/appjam/generators/templates/resources/Default@2x.png +0 -0
- data/lib/appjam/generators/templates/resources/contents.tt +4 -0
- data/lib/appjam/version.rb +1 -1
- metadata +462 -326
- data/test/helper.rb +0 -132
- data/test/test_model_generator.rb +0 -28
- data/test/test_project_generator.rb +0 -38
@@ -0,0 +1,78 @@
|
|
1
|
+
//
|
2
|
+
// EGOCache.h
|
3
|
+
// enormego
|
4
|
+
//
|
5
|
+
// Created by Shaun Harrison on 7/4/09.
|
6
|
+
// Copyright (c) 2009-2012 enormego
|
7
|
+
//
|
8
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
+
// of this software and associated documentation files (the "Software"), to deal
|
10
|
+
// in the Software without restriction, including without limitation the rights
|
11
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12
|
+
// copies of the Software, and to permit persons to whom the Software is
|
13
|
+
// furnished to do so, subject to the following conditions:
|
14
|
+
//
|
15
|
+
// The above copyright notice and this permission notice shall be included in
|
16
|
+
// all copies or substantial portions of the Software.
|
17
|
+
//
|
18
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24
|
+
// THE SOFTWARE.
|
25
|
+
//
|
26
|
+
|
27
|
+
#import <Foundation/Foundation.h>
|
28
|
+
|
29
|
+
#if TARGET_OS_IPHONE
|
30
|
+
#import <UIKit/UIKit.h>
|
31
|
+
#endif
|
32
|
+
|
33
|
+
@interface EGOCache : NSObject
|
34
|
+
|
35
|
+
+ (instancetype)currentCache __deprecated; // Renamed to globalCache
|
36
|
+
|
37
|
+
// Global cache for easy use
|
38
|
+
+ (instancetype)globalCache;
|
39
|
+
|
40
|
+
// Opitionally create a different EGOCache instance with it's own cache directory
|
41
|
+
- (id)initWithCacheDirectory:(NSString*)cacheDirectory;
|
42
|
+
|
43
|
+
- (void)clearCache;
|
44
|
+
- (void)removeCacheForKey:(NSString*)key;
|
45
|
+
|
46
|
+
- (BOOL)hasCacheForKey:(NSString*)key;
|
47
|
+
|
48
|
+
- (NSData*)dataForKey:(NSString*)key;
|
49
|
+
- (void)setData:(NSData*)data forKey:(NSString*)key;
|
50
|
+
- (void)setData:(NSData*)data forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
|
51
|
+
|
52
|
+
- (NSString*)stringForKey:(NSString*)key;
|
53
|
+
- (void)setString:(NSString*)aString forKey:(NSString*)key;
|
54
|
+
- (void)setString:(NSString*)aString forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
|
55
|
+
|
56
|
+
#if TARGET_OS_IPHONE
|
57
|
+
- (UIImage*)imageForKey:(NSString*)key;
|
58
|
+
- (void)setImage:(UIImage*)anImage forKey:(NSString*)key;
|
59
|
+
- (void)setImage:(UIImage*)anImage forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
|
60
|
+
#else
|
61
|
+
- (NSImage*)imageForKey:(NSString*)key;
|
62
|
+
- (void)setImage:(NSImage*)anImage forKey:(NSString*)key;
|
63
|
+
- (void)setImage:(NSImage*)anImage forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
|
64
|
+
#endif
|
65
|
+
|
66
|
+
- (NSData*)plistForKey:(NSString*)key;
|
67
|
+
- (void)setPlist:(id)plistObject forKey:(NSString*)key;
|
68
|
+
- (void)setPlist:(id)plistObject forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
|
69
|
+
|
70
|
+
- (void)copyFilePath:(NSString*)filePath asKey:(NSString*)key;
|
71
|
+
- (void)copyFilePath:(NSString*)filePath asKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
|
72
|
+
|
73
|
+
- (id<NSCoding>)objectForKey:(NSString*)key;
|
74
|
+
- (void)setObject:(id<NSCoding>)anObject forKey:(NSString*)key;
|
75
|
+
- (void)setObject:(id<NSCoding>)anObject forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
|
76
|
+
|
77
|
+
@property(nonatomic,assign) NSTimeInterval defaultTimeoutInterval; // Default is 1 day
|
78
|
+
@end
|
@@ -0,0 +1,370 @@
|
|
1
|
+
//
|
2
|
+
// EGOCache.m
|
3
|
+
// enormego
|
4
|
+
//
|
5
|
+
// Created by Shaun Harrison on 7/4/09.
|
6
|
+
// Copyright (c) 2009-2012 enormego
|
7
|
+
//
|
8
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
+
// of this software and associated documentation files (the "Software"), to deal
|
10
|
+
// in the Software without restriction, including without limitation the rights
|
11
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12
|
+
// copies of the Software, and to permit persons to whom the Software is
|
13
|
+
// furnished to do so, subject to the following conditions:
|
14
|
+
//
|
15
|
+
// The above copyright notice and this permission notice shall be included in
|
16
|
+
// all copies or substantial portions of the Software.
|
17
|
+
//
|
18
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24
|
+
// THE SOFTWARE.
|
25
|
+
//
|
26
|
+
|
27
|
+
#import "EGOCache.h"
|
28
|
+
|
29
|
+
#if DEBUG
|
30
|
+
#define CHECK_FOR_EGOCACHE_PLIST() if([key isEqualToString:@"EGOCache.plist"]) { \
|
31
|
+
NSLog(@"EGOCache.plist is a reserved key and can not be modified."); \
|
32
|
+
return; }
|
33
|
+
#else
|
34
|
+
#define CHECK_FOR_EGOCACHE_PLIST() if([key isEqualToString:@"EGOCache.plist"]) return;
|
35
|
+
#endif
|
36
|
+
|
37
|
+
static inline NSString* cachePathForKey(NSString* directory, NSString* key) {
|
38
|
+
return [directory stringByAppendingPathComponent:key];
|
39
|
+
}
|
40
|
+
|
41
|
+
#pragma mark -
|
42
|
+
|
43
|
+
@interface EGOCache () {
|
44
|
+
dispatch_queue_t _cacheInfoQueue;
|
45
|
+
dispatch_queue_t _frozenCacheInfoQueue;
|
46
|
+
dispatch_queue_t _diskQueue;
|
47
|
+
NSMutableDictionary* _cacheInfo;
|
48
|
+
NSString* _directory;
|
49
|
+
BOOL _needsSave;
|
50
|
+
}
|
51
|
+
|
52
|
+
@property(nonatomic,copy) NSDictionary* frozenCacheInfo;
|
53
|
+
@end
|
54
|
+
|
55
|
+
@implementation EGOCache
|
56
|
+
|
57
|
+
+ (instancetype)currentCache {
|
58
|
+
return [self globalCache];
|
59
|
+
}
|
60
|
+
|
61
|
+
+ (instancetype)globalCache {
|
62
|
+
static id instance;
|
63
|
+
|
64
|
+
static dispatch_once_t onceToken;
|
65
|
+
dispatch_once(&onceToken, ^{
|
66
|
+
instance = [[[self class] alloc] init];
|
67
|
+
[instance setDefaultTimeoutInterval:86400];
|
68
|
+
});
|
69
|
+
|
70
|
+
return instance;
|
71
|
+
}
|
72
|
+
|
73
|
+
- (id)init {
|
74
|
+
NSString* cachesDirectory = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];
|
75
|
+
NSString* oldCachesDirectory = [[[cachesDirectory stringByAppendingPathComponent:[[NSProcessInfo processInfo] processName]] stringByAppendingPathComponent:@"EGOCache"] copy];
|
76
|
+
|
77
|
+
if([[NSFileManager defaultManager] fileExistsAtPath:oldCachesDirectory]) {
|
78
|
+
[[NSFileManager defaultManager] removeItemAtPath:oldCachesDirectory error:NULL];
|
79
|
+
}
|
80
|
+
|
81
|
+
cachesDirectory = [[[cachesDirectory stringByAppendingPathComponent:[[NSBundle mainBundle] bundleIdentifier]] stringByAppendingPathComponent:@"EGOCache"] copy];
|
82
|
+
return [self initWithCacheDirectory:cachesDirectory];
|
83
|
+
}
|
84
|
+
|
85
|
+
- (id)initWithCacheDirectory:(NSString*)cacheDirectory {
|
86
|
+
if((self = [super init])) {
|
87
|
+
|
88
|
+
_cacheInfoQueue = dispatch_queue_create("com.enormego.egocache.info", DISPATCH_QUEUE_SERIAL);
|
89
|
+
dispatch_queue_t priority = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
|
90
|
+
dispatch_set_target_queue(priority, _cacheInfoQueue);
|
91
|
+
|
92
|
+
_frozenCacheInfoQueue = dispatch_queue_create("com.enormego.egocache.info.frozen", DISPATCH_QUEUE_SERIAL);
|
93
|
+
priority = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
|
94
|
+
dispatch_set_target_queue(priority, _frozenCacheInfoQueue);
|
95
|
+
|
96
|
+
_diskQueue = dispatch_queue_create("com.enormego.egocache.disk", DISPATCH_QUEUE_CONCURRENT);
|
97
|
+
priority = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0);
|
98
|
+
dispatch_set_target_queue(priority, _cacheInfoQueue);
|
99
|
+
|
100
|
+
|
101
|
+
_directory = cacheDirectory;
|
102
|
+
|
103
|
+
_cacheInfo = [[NSDictionary dictionaryWithContentsOfFile:cachePathForKey(_directory, @"EGOCache.plist")] mutableCopy];
|
104
|
+
|
105
|
+
if(!_cacheInfo) {
|
106
|
+
_cacheInfo = [[NSMutableDictionary alloc] init];
|
107
|
+
}
|
108
|
+
|
109
|
+
[[NSFileManager defaultManager] createDirectoryAtPath:_directory withIntermediateDirectories:YES attributes:nil error:NULL];
|
110
|
+
|
111
|
+
NSTimeInterval now = [[NSDate date] timeIntervalSinceReferenceDate];
|
112
|
+
NSMutableArray* removedKeys = [[NSMutableArray alloc] init];
|
113
|
+
|
114
|
+
for(NSString* key in _cacheInfo) {
|
115
|
+
if([_cacheInfo[key] timeIntervalSinceReferenceDate] <= now) {
|
116
|
+
[[NSFileManager defaultManager] removeItemAtPath:cachePathForKey(_directory, key) error:NULL];
|
117
|
+
[removedKeys addObject:key];
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
[_cacheInfo removeObjectsForKeys:removedKeys];
|
122
|
+
self.frozenCacheInfo = _cacheInfo;
|
123
|
+
}
|
124
|
+
|
125
|
+
return self;
|
126
|
+
}
|
127
|
+
|
128
|
+
- (void)clearCache {
|
129
|
+
dispatch_sync(_cacheInfoQueue, ^{
|
130
|
+
for(NSString* key in _cacheInfo) {
|
131
|
+
[[NSFileManager defaultManager] removeItemAtPath:cachePathForKey(_directory, key) error:NULL];
|
132
|
+
}
|
133
|
+
|
134
|
+
[_cacheInfo removeAllObjects];
|
135
|
+
|
136
|
+
dispatch_sync(_frozenCacheInfoQueue, ^{
|
137
|
+
self.frozenCacheInfo = [_cacheInfo copy];
|
138
|
+
});
|
139
|
+
|
140
|
+
[self setNeedsSave];
|
141
|
+
});
|
142
|
+
}
|
143
|
+
|
144
|
+
- (void)removeCacheForKey:(NSString*)key {
|
145
|
+
CHECK_FOR_EGOCACHE_PLIST();
|
146
|
+
|
147
|
+
dispatch_async(_diskQueue, ^{
|
148
|
+
[[NSFileManager defaultManager] removeItemAtPath:cachePathForKey(_directory, key) error:NULL];
|
149
|
+
});
|
150
|
+
|
151
|
+
[self setCacheTimeoutInterval:0 forKey:key];
|
152
|
+
}
|
153
|
+
|
154
|
+
- (BOOL)hasCacheForKey:(NSString*)key {
|
155
|
+
__block NSDate* date = nil;;
|
156
|
+
|
157
|
+
dispatch_sync(_frozenCacheInfoQueue, ^{
|
158
|
+
date = (self.frozenCacheInfo)[key];
|
159
|
+
});
|
160
|
+
|
161
|
+
if(!date) return NO;
|
162
|
+
if([date compare:[NSDate date]] != NSOrderedDescending) return NO;
|
163
|
+
|
164
|
+
return [[NSFileManager defaultManager] fileExistsAtPath:cachePathForKey(_directory, key)];
|
165
|
+
}
|
166
|
+
|
167
|
+
- (void)setCacheTimeoutInterval:(NSTimeInterval)timeoutInterval forKey:(NSString*)key {
|
168
|
+
NSDate* date = timeoutInterval > 0 ? [NSDate dateWithTimeIntervalSinceNow:timeoutInterval] : nil;
|
169
|
+
|
170
|
+
// Temporarily store in the frozen state for quick reads
|
171
|
+
dispatch_sync(_frozenCacheInfoQueue, ^{
|
172
|
+
NSMutableDictionary* info = [self.frozenCacheInfo mutableCopy];
|
173
|
+
|
174
|
+
if(date) {
|
175
|
+
info[key] = date;
|
176
|
+
} else {
|
177
|
+
[info removeObjectForKey:key];
|
178
|
+
}
|
179
|
+
|
180
|
+
self.frozenCacheInfo = info;
|
181
|
+
});
|
182
|
+
|
183
|
+
|
184
|
+
// Save the final copy (this may be blocked by other operations)
|
185
|
+
dispatch_async(_cacheInfoQueue, ^{
|
186
|
+
if(date) {
|
187
|
+
_cacheInfo[key] = date;
|
188
|
+
} else {
|
189
|
+
[_cacheInfo removeObjectForKey:key];
|
190
|
+
}
|
191
|
+
|
192
|
+
dispatch_sync(_frozenCacheInfoQueue, ^{
|
193
|
+
self.frozenCacheInfo = [_cacheInfo copy];
|
194
|
+
});
|
195
|
+
|
196
|
+
[self setNeedsSave];
|
197
|
+
});
|
198
|
+
}
|
199
|
+
|
200
|
+
#pragma mark -
|
201
|
+
#pragma mark Copy file methods
|
202
|
+
|
203
|
+
- (void)copyFilePath:(NSString*)filePath asKey:(NSString*)key {
|
204
|
+
[self copyFilePath:filePath asKey:key withTimeoutInterval:self.defaultTimeoutInterval];
|
205
|
+
}
|
206
|
+
|
207
|
+
- (void)copyFilePath:(NSString*)filePath asKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval {
|
208
|
+
dispatch_async(_diskQueue, ^{
|
209
|
+
[[NSFileManager defaultManager] copyItemAtPath:filePath toPath:cachePathForKey(_directory, key) error:NULL];
|
210
|
+
});
|
211
|
+
|
212
|
+
[self setCacheTimeoutInterval:timeoutInterval forKey:key];
|
213
|
+
}
|
214
|
+
|
215
|
+
#pragma mark -
|
216
|
+
#pragma mark Data methods
|
217
|
+
|
218
|
+
- (void)setData:(NSData*)data forKey:(NSString*)key {
|
219
|
+
[self setData:data forKey:key withTimeoutInterval:self.defaultTimeoutInterval];
|
220
|
+
}
|
221
|
+
|
222
|
+
- (void)setData:(NSData*)data forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval {
|
223
|
+
CHECK_FOR_EGOCACHE_PLIST();
|
224
|
+
|
225
|
+
NSString* cachePath = cachePathForKey(_directory, key);
|
226
|
+
|
227
|
+
dispatch_async(_diskQueue, ^{
|
228
|
+
[data writeToFile:cachePath atomically:YES];
|
229
|
+
});
|
230
|
+
|
231
|
+
[self setCacheTimeoutInterval:timeoutInterval forKey:key];
|
232
|
+
}
|
233
|
+
|
234
|
+
- (void)setNeedsSave {
|
235
|
+
dispatch_async(_cacheInfoQueue, ^{
|
236
|
+
if(_needsSave) return;
|
237
|
+
_needsSave = YES;
|
238
|
+
|
239
|
+
double delayInSeconds = 0.5;
|
240
|
+
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
|
241
|
+
dispatch_after(popTime, _cacheInfoQueue, ^(void){
|
242
|
+
if(!_needsSave) return;
|
243
|
+
[_cacheInfo writeToFile:cachePathForKey(_directory, @"EGOCache.plist") atomically:YES];
|
244
|
+
_needsSave = NO;
|
245
|
+
});
|
246
|
+
});
|
247
|
+
}
|
248
|
+
|
249
|
+
- (NSData*)dataForKey:(NSString*)key {
|
250
|
+
if([self hasCacheForKey:key]) {
|
251
|
+
return [NSData dataWithContentsOfFile:cachePathForKey(_directory, key) options:0 error:NULL];
|
252
|
+
} else {
|
253
|
+
return nil;
|
254
|
+
}
|
255
|
+
}
|
256
|
+
|
257
|
+
#pragma mark -
|
258
|
+
#pragma mark String methods
|
259
|
+
|
260
|
+
- (NSString*)stringForKey:(NSString*)key {
|
261
|
+
return [[NSString alloc] initWithData:[self dataForKey:key] encoding:NSUTF8StringEncoding];
|
262
|
+
}
|
263
|
+
|
264
|
+
- (void)setString:(NSString*)aString forKey:(NSString*)key {
|
265
|
+
[self setString:aString forKey:key withTimeoutInterval:self.defaultTimeoutInterval];
|
266
|
+
}
|
267
|
+
|
268
|
+
- (void)setString:(NSString*)aString forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval {
|
269
|
+
[self setData:[aString dataUsingEncoding:NSUTF8StringEncoding] forKey:key withTimeoutInterval:timeoutInterval];
|
270
|
+
}
|
271
|
+
|
272
|
+
#pragma mark -
|
273
|
+
#pragma mark Image methds
|
274
|
+
|
275
|
+
#if TARGET_OS_IPHONE
|
276
|
+
|
277
|
+
- (UIImage*)imageForKey:(NSString*)key {
|
278
|
+
UIImage* image = nil;
|
279
|
+
|
280
|
+
@try {
|
281
|
+
image = [NSKeyedUnarchiver unarchiveObjectWithFile:cachePathForKey(_directory, key)];
|
282
|
+
} @catch (NSException* e) {
|
283
|
+
// Surpress any unarchiving exceptions and continue with nil
|
284
|
+
}
|
285
|
+
|
286
|
+
return image;
|
287
|
+
}
|
288
|
+
|
289
|
+
- (void)setImage:(UIImage*)anImage forKey:(NSString*)key {
|
290
|
+
[self setImage:anImage forKey:key withTimeoutInterval:self.defaultTimeoutInterval];
|
291
|
+
}
|
292
|
+
|
293
|
+
- (void)setImage:(UIImage*)anImage forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval {
|
294
|
+
@try {
|
295
|
+
// Using NSKeyedArchiver preserves all information such as scale, orientation, and the proper image format instead of saving everything as pngs
|
296
|
+
[self setData:[NSKeyedArchiver archivedDataWithRootObject:anImage] forKey:key withTimeoutInterval:timeoutInterval];
|
297
|
+
} @catch (NSException* e) {
|
298
|
+
// Something went wrong, but we'll fail silently.
|
299
|
+
}
|
300
|
+
}
|
301
|
+
|
302
|
+
|
303
|
+
#else
|
304
|
+
|
305
|
+
- (NSImage*)imageForKey:(NSString*)key {
|
306
|
+
return [[NSImage alloc] initWithData:[self dataForKey:key]];
|
307
|
+
}
|
308
|
+
|
309
|
+
- (void)setImage:(NSImage*)anImage forKey:(NSString*)key {
|
310
|
+
[self setImage:anImage forKey:key withTimeoutInterval:self.defaultTimeoutInterval];
|
311
|
+
}
|
312
|
+
|
313
|
+
- (void)setImage:(NSImage*)anImage forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval {
|
314
|
+
[self setData:[[[anImage representations] objectAtIndex:0] representationUsingType:NSPNGFileType properties:nil]
|
315
|
+
forKey:key withTimeoutInterval:timeoutInterval];
|
316
|
+
}
|
317
|
+
|
318
|
+
#endif
|
319
|
+
|
320
|
+
#pragma mark -
|
321
|
+
#pragma mark Property List methods
|
322
|
+
|
323
|
+
- (NSData*)plistForKey:(NSString*)key; {
|
324
|
+
NSData* plistData = [self dataForKey:key];
|
325
|
+
|
326
|
+
return [NSPropertyListSerialization propertyListFromData:plistData
|
327
|
+
mutabilityOption:NSPropertyListImmutable
|
328
|
+
format:nil
|
329
|
+
errorDescription:nil];
|
330
|
+
}
|
331
|
+
|
332
|
+
- (void)setPlist:(id)plistObject forKey:(NSString*)key; {
|
333
|
+
[self setPlist:plistObject forKey:key withTimeoutInterval:self.defaultTimeoutInterval];
|
334
|
+
}
|
335
|
+
|
336
|
+
- (void)setPlist:(id)plistObject forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval; {
|
337
|
+
// Binary plists are used over XML for better performance
|
338
|
+
NSData* plistData = [NSPropertyListSerialization dataFromPropertyList:plistObject
|
339
|
+
format:NSPropertyListBinaryFormat_v1_0
|
340
|
+
errorDescription:NULL];
|
341
|
+
|
342
|
+
[self setData:plistData forKey:key withTimeoutInterval:timeoutInterval];
|
343
|
+
}
|
344
|
+
|
345
|
+
#pragma mark -
|
346
|
+
#pragma mark Object methods
|
347
|
+
|
348
|
+
- (id<NSCoding>)objectForKey:(NSString*)key {
|
349
|
+
if([self hasCacheForKey:key]) {
|
350
|
+
return [NSKeyedUnarchiver unarchiveObjectWithData:[self dataForKey:key]];
|
351
|
+
} else {
|
352
|
+
return nil;
|
353
|
+
}
|
354
|
+
}
|
355
|
+
|
356
|
+
- (void)setObject:(id<NSCoding>)anObject forKey:(NSString*)key {
|
357
|
+
[self setObject:anObject forKey:key withTimeoutInterval:self.defaultTimeoutInterval];
|
358
|
+
}
|
359
|
+
|
360
|
+
- (void)setObject:(id<NSCoding>)anObject forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval {
|
361
|
+
[self setData:[NSKeyedArchiver archivedDataWithRootObject:anObject] forKey:key withTimeoutInterval:timeoutInterval];
|
362
|
+
}
|
363
|
+
|
364
|
+
#pragma mark -
|
365
|
+
|
366
|
+
- (void)dealloc {
|
367
|
+
|
368
|
+
}
|
369
|
+
|
370
|
+
@end
|
data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDASLLogger.h
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#import <Foundation/Foundation.h>
|
2
|
+
#import <asl.h>
|
3
|
+
|
4
|
+
#import "DDLog.h"
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Welcome to Cocoa Lumberjack!
|
8
|
+
*
|
9
|
+
* The project page has a wealth of documentation if you have any questions.
|
10
|
+
* https://github.com/robbiehanson/CocoaLumberjack
|
11
|
+
*
|
12
|
+
* If you're new to the project you may wish to read the "Getting Started" wiki.
|
13
|
+
* https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
|
14
|
+
*
|
15
|
+
*
|
16
|
+
* This class provides a logger for the Apple System Log facility.
|
17
|
+
*
|
18
|
+
* As described in the "Getting Started" page,
|
19
|
+
* the traditional NSLog() function directs it's output to two places:
|
20
|
+
*
|
21
|
+
* - Apple System Log
|
22
|
+
* - StdErr (if stderr is a TTY) so log statements show up in Xcode console
|
23
|
+
*
|
24
|
+
* To duplicate NSLog() functionality you can simply add this logger and a tty logger.
|
25
|
+
* However, if you instead choose to use file logging (for faster performance),
|
26
|
+
* you may choose to use a file logger and a tty logger.
|
27
|
+
**/
|
28
|
+
|
29
|
+
@interface DDASLLogger : DDAbstractLogger <DDLogger>
|
30
|
+
{
|
31
|
+
aslclient client;
|
32
|
+
}
|
33
|
+
|
34
|
+
+ (DDASLLogger *)sharedInstance;
|
35
|
+
|
36
|
+
// Inherited from DDAbstractLogger
|
37
|
+
|
38
|
+
// - (id <DDLogFormatter>)logFormatter;
|
39
|
+
// - (void)setLogFormatter:(id <DDLogFormatter>)formatter;
|
40
|
+
|
41
|
+
@end
|