From ecfd326da45993679b8a72622d4d44d996cb9e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B8=CC=86=20=D0=90?= =?UTF-8?q?=D1=88=D0=B0=D0=BD=D0=B8=D0=BD?= Date: Fri, 5 Feb 2016 16:32:47 +0300 Subject: [PATCH] remove prefix & make static let instead var --- .../project.pbxproj | 24 ++++++++--------- .../{TIApp.swift => App.swift} | 26 +++++++------------ .../iOS-Base-Library/AppDelegate.swift | 6 ++--- .../{TILog.swift => Log.swift} | 16 +++++------- ...ILogFormatter.swift => LogFormatter.swift} | 10 +++---- 5 files changed, 37 insertions(+), 45 deletions(-) rename iOS-Base-Library/iOS-Base-Library/{TIApp.swift => App.swift} (51%) rename iOS-Base-Library/iOS-Base-Library/{TILog.swift => Log.swift} (67%) rename iOS-Base-Library/iOS-Base-Library/{TILogFormatter.swift => LogFormatter.swift} (85%) diff --git a/iOS-Base-Library/iOS-Base-Library.xcodeproj/project.pbxproj b/iOS-Base-Library/iOS-Base-Library.xcodeproj/project.pbxproj index 5868c060..796dfba7 100644 --- a/iOS-Base-Library/iOS-Base-Library.xcodeproj/project.pbxproj +++ b/iOS-Base-Library/iOS-Base-Library.xcodeproj/project.pbxproj @@ -13,9 +13,9 @@ 952A63921C5408AC00E3572C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 952A63901C5408AC00E3572C /* Main.storyboard */; }; 952A63941C5408AC00E3572C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 952A63931C5408AC00E3572C /* Assets.xcassets */; }; 952A63971C5408AC00E3572C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 952A63951C5408AC00E3572C /* LaunchScreen.storyboard */; }; - 952A63A51C543CD400E3572C /* TIApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952A63A41C543CD400E3572C /* TIApp.swift */; }; - 952A63A71C54F71500E3572C /* TILog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952A63A61C54F71500E3572C /* TILog.swift */; }; - 952A63AB1C54F76400E3572C /* TILogFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952A63AA1C54F76400E3572C /* TILogFormatter.swift */; }; + 952A63A51C543CD400E3572C /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952A63A41C543CD400E3572C /* App.swift */; }; + 952A63A71C54F71500E3572C /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952A63A61C54F71500E3572C /* Log.swift */; }; + 952A63AB1C54F76400E3572C /* LogFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952A63AA1C54F76400E3572C /* LogFormatter.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -28,9 +28,9 @@ 952A63931C5408AC00E3572C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 952A63961C5408AC00E3572C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 952A63981C5408AC00E3572C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 952A63A41C543CD400E3572C /* TIApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TIApp.swift; sourceTree = ""; }; - 952A63A61C54F71500E3572C /* TILog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TILog.swift; sourceTree = ""; }; - 952A63AA1C54F76400E3572C /* TILogFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TILogFormatter.swift; sourceTree = ""; }; + 952A63A41C543CD400E3572C /* App.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = ""; }; + 952A63A61C54F71500E3572C /* Log.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Log.swift; sourceTree = ""; }; + 952A63AA1C54F76400E3572C /* LogFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogFormatter.swift; sourceTree = ""; }; DF472984BADA33609A7AA065 /* Pods-iOS-Base-Library.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iOS-Base-Library.debug.xcconfig"; path = "Pods/Target Support Files/Pods-iOS-Base-Library/Pods-iOS-Base-Library.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -106,9 +106,9 @@ 952A63A31C543CB100E3572C /* Logger */ = { isa = PBXGroup; children = ( - 952A63A41C543CD400E3572C /* TIApp.swift */, - 952A63A61C54F71500E3572C /* TILog.swift */, - 952A63AA1C54F76400E3572C /* TILogFormatter.swift */, + 952A63A41C543CD400E3572C /* App.swift */, + 952A63A61C54F71500E3572C /* Log.swift */, + 952A63AA1C54F76400E3572C /* LogFormatter.swift */, ); name = Logger; sourceTree = ""; @@ -282,10 +282,10 @@ buildActionMask = 2147483647; files = ( 952A638F1C5408AC00E3572C /* ViewController.swift in Sources */, - 952A63A71C54F71500E3572C /* TILog.swift in Sources */, - 952A63AB1C54F76400E3572C /* TILogFormatter.swift in Sources */, + 952A63A71C54F71500E3572C /* Log.swift in Sources */, + 952A63AB1C54F76400E3572C /* LogFormatter.swift in Sources */, 952A638D1C5408AC00E3572C /* AppDelegate.swift in Sources */, - 952A63A51C543CD400E3572C /* TIApp.swift in Sources */, + 952A63A51C543CD400E3572C /* App.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iOS-Base-Library/iOS-Base-Library/TIApp.swift b/iOS-Base-Library/iOS-Base-Library/App.swift similarity index 51% rename from iOS-Base-Library/iOS-Base-Library/TIApp.swift rename to iOS-Base-Library/iOS-Base-Library/App.swift index aaf557f3..1289673c 100644 --- a/iOS-Base-Library/iOS-Base-Library/TIApp.swift +++ b/iOS-Base-Library/iOS-Base-Library/App.swift @@ -9,38 +9,32 @@ import Foundation import UIKit -public class TIApp { - private let stringVendorIdentifierKey: String = "stringIdentifierForVendor" +public class App { + private static let stringVendorIdentifierKey = "stringIdentifierForVendor" /// The value of CFBundleName - public var bundleName: String + public static var bundleName: String = NSBundle.mainBundle().infoDictionary!["CFBundleName"] as! String /// The value of CFBundleShortVersionString - public var shortBundleVersion: String + public static var shortVersion: String = NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"] as! String /// The value of CFBundleVersion - public var bundleVersion: String - init() { - bundleName = NSBundle.mainBundle().infoDictionary!["CFBundleName"] as! String - - shortBundleVersion = NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"] as! String - bundleVersion = NSBundle.mainBundle().infoDictionary!["CFBundleVersion"] as! String - } + public static var bundleVersion: String = NSBundle.mainBundle().infoDictionary!["CFBundleVersion"] as! String /** Return app's version - returns: shortBundleVersion.bundleVersion */ - public func version() -> String { - return shortBundleVersion + "." + bundleVersion + public static func version() -> String { + return App.shortVersion + "." + App.bundleVersion } /** Return device identifier - returns: UUIDString */ - public func stringIdentifierForVendor() -> String { - var returnValue = NSUserDefaults.standardUserDefaults().stringForKey(stringVendorIdentifierKey) + public static func stringIdentifierForVendor() -> String { + var returnValue = NSUserDefaults.standardUserDefaults().stringForKey(App.stringVendorIdentifierKey) if returnValue == nil { returnValue = NSUUID().UUIDString - NSUserDefaults.standardUserDefaults().setObject(returnValue, forKey: stringVendorIdentifierKey) + NSUserDefaults.standardUserDefaults().setObject(returnValue, forKey: App.stringVendorIdentifierKey) NSUserDefaults.standardUserDefaults().synchronize() } return returnValue! diff --git a/iOS-Base-Library/iOS-Base-Library/AppDelegate.swift b/iOS-Base-Library/iOS-Base-Library/AppDelegate.swift index 47bb6eba..76c37a5e 100644 --- a/iOS-Base-Library/iOS-Base-Library/AppDelegate.swift +++ b/iOS-Base-Library/iOS-Base-Library/AppDelegate.swift @@ -13,7 +13,7 @@ import CocoaLumberjack class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - var log: TILog? + var log: Log? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { @@ -24,8 +24,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } func initLog() -> Void { - log = TILog.init() - DDLogInfo(log!.startMessage()) + log = Log.init() + DDLogInfo(Log.startMessage()) } } diff --git a/iOS-Base-Library/iOS-Base-Library/TILog.swift b/iOS-Base-Library/iOS-Base-Library/Log.swift similarity index 67% rename from iOS-Base-Library/iOS-Base-Library/TILog.swift rename to iOS-Base-Library/iOS-Base-Library/Log.swift index 1473be59..659b5f55 100644 --- a/iOS-Base-Library/iOS-Base-Library/TILog.swift +++ b/iOS-Base-Library/iOS-Base-Library/Log.swift @@ -9,21 +9,20 @@ import Foundation import CocoaLumberjack -public class TILog { +public class Log { /// Logger for CocoaLumberJack - public var fileLogger: DDFileLogger + public let fileLogger = DDFileLogger() init() { - fileLogger = DDFileLogger.init() DDLog.addLogger(fileLogger) DDLog.addLogger(DDASLLogger.sharedInstance()) DDLog.addLogger(DDTTYLogger.sharedInstance()) - DDASLLogger.sharedInstance().logFormatter = TILogFormatter.init() - DDTTYLogger.sharedInstance().logFormatter = TILogFormatter.init() + DDASLLogger.sharedInstance().logFormatter = LogFormatter.init() + DDTTYLogger.sharedInstance().logFormatter = LogFormatter.init() let assertionHandler = NSAssertionHandler.init() @@ -35,10 +34,9 @@ public class TILog { - returns: Return value looks like "AppName 1.0.1 session started on version 9.2 (build 13c75)" */ - public func startMessage() -> String { - let app = TIApp.init() - let startMessage = app.bundleName + " " + app.shortBundleVersion + "." - + app.bundleVersion + " session started on " + public static func startMessage() -> String { + let startMessage = App.bundleName + " " + App.shortVersion + "." + + App.bundleVersion + " session started on " + NSProcessInfo.processInfo().operatingSystemVersionString.lowercaseString return startMessage } diff --git a/iOS-Base-Library/iOS-Base-Library/TILogFormatter.swift b/iOS-Base-Library/iOS-Base-Library/LogFormatter.swift similarity index 85% rename from iOS-Base-Library/iOS-Base-Library/TILogFormatter.swift rename to iOS-Base-Library/iOS-Base-Library/LogFormatter.swift index 496365f7..79060a50 100644 --- a/iOS-Base-Library/iOS-Base-Library/TILogFormatter.swift +++ b/iOS-Base-Library/iOS-Base-Library/LogFormatter.swift @@ -10,7 +10,7 @@ import Foundation import CocoaLumberjack import CocoaLumberjack.DDDispatchQueueLogFormatter -class TILogFormatter: DDDispatchQueueLogFormatter { +class LogFormatter: DDDispatchQueueLogFormatter { let dateFormatter: NSDateFormatter override init() { @@ -25,13 +25,13 @@ class TILogFormatter: DDDispatchQueueLogFormatter { var level: String! switch logMessage.flag { - case (DDLogFlag.Error): + case DDLogFlag.Error: level = "ERR" - case (DDLogFlag.Warning): + case DDLogFlag.Warning: level = "WRN" - case (DDLogFlag.Info): + case DDLogFlag.Info: level = "INF" - case (DDLogFlag.Debug): + case DDLogFlag.Debug: level = "DBG" default: level = "VRB"