From edd4914ca7015654e772c6aaa07c231e9b64f792 Mon Sep 17 00:00:00 2001 From: Amir Abbas Date: Sat, 11 Feb 2017 06:08:17 +0330 Subject: [PATCH] Linting, fixed travis wrong device --- .travis.yml | 2 +- FileProvider.xcodeproj/project.pbxproj | 6 ------ README.md | 11 +++++------ Sources/ExtendedLocalFileProvider.swift | 2 +- Sources/FileObject.swift | 4 ++-- Sources/FileProvider.swift | 7 ++++--- 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index b644603..dcbcd30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ env: - MACOS_SDK=macosx - TVOS_SDK=appletvsimulator matrix: - - DESTINATION="OS=10.2,name=iPhone 7 Plus" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="NO" BUILD_EXAMPLE="NO" POD_LINT="YES" + - DESTINATION="OS=10.2,name=iPad Air 2" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="NO" BUILD_EXAMPLE="NO" POD_LINT="YES" - DESTINATION="OS=9.0,name=iPhone 6" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="NO" BUILD_EXAMPLE="NO" POD_LINT="NO" - DESTINATION="OS=8.1,name=iPhone 4S" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="NO" BUILD_EXAMPLE="NO" POD_LINT="NO" diff --git a/FileProvider.xcodeproj/project.pbxproj b/FileProvider.xcodeproj/project.pbxproj index 5aa7042..3890b86 100644 --- a/FileProvider.xcodeproj/project.pbxproj +++ b/FileProvider.xcodeproj/project.pbxproj @@ -162,14 +162,11 @@ 79BD63A71E2CC2940035128C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; 79BD63A91E2CC2BB0035128C /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk/System/Library/Frameworks/AVFoundation.framework; sourceTree = DEVELOPER_DIR; }; 79BD63AB1E2CC2C20035128C /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk/System/Library/Frameworks/ImageIO.framework; sourceTree = DEVELOPER_DIR; }; - 79BD63AD1E2CC2EB0035128C /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk/System/Library/Frameworks/MediaPlayer.framework; sourceTree = DEVELOPER_DIR; }; 79BD63AF1E2CC3300035128C /* libxml2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libxml2.tbd; path = usr/lib/libxml2.tbd; sourceTree = SDKROOT; }; 79BD63B11E2CC3350035128C /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; }; - 79BD63B31E2CC33D0035128C /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; }; 79BD63B51E2CC3860035128C /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; 79BD63B71E2CC38D0035128C /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 79BD63B91E2CC39B0035128C /* libxml2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libxml2.tbd; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS10.1.sdk/usr/lib/libxml2.tbd; sourceTree = DEVELOPER_DIR; }; - 79BD63BB1E2CC3B90035128C /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS10.1.sdk/System/Library/Frameworks/MediaPlayer.framework; sourceTree = DEVELOPER_DIR; }; 79BD63BD1E2CC3C20035128C /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS10.1.sdk/System/Library/Frameworks/ImageIO.framework; sourceTree = DEVELOPER_DIR; }; 79BD63BF1E2CC3CD0035128C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS10.1.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; 79BD63C11E2CC3D30035128C /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS10.1.sdk/System/Library/Frameworks/AVFoundation.framework; sourceTree = DEVELOPER_DIR; }; @@ -221,14 +218,11 @@ 79BD63C11E2CC3D30035128C /* AVFoundation.framework */, 79BD63BF1E2CC3CD0035128C /* CoreGraphics.framework */, 79BD63BD1E2CC3C20035128C /* ImageIO.framework */, - 79BD63BB1E2CC3B90035128C /* MediaPlayer.framework */, 79BD63B91E2CC39B0035128C /* libxml2.tbd */, 79BD63B71E2CC38D0035128C /* AVFoundation.framework */, 79BD63B51E2CC3860035128C /* CoreFoundation.framework */, - 79BD63B31E2CC33D0035128C /* MediaPlayer.framework */, 79BD63B11E2CC3350035128C /* ImageIO.framework */, 79BD63AF1E2CC3300035128C /* libxml2.tbd */, - 79BD63AD1E2CC2EB0035128C /* MediaPlayer.framework */, 79BD63AB1E2CC2C20035128C /* ImageIO.framework */, 79BD63A91E2CC2BB0035128C /* AVFoundation.framework */, 79BD63A71E2CC2940035128C /* CoreGraphics.framework */, diff --git a/README.md b/README.md index 002d039..2b9467b 100644 --- a/README.md +++ b/README.md @@ -141,11 +141,11 @@ let webdavProvider = WebDAVFileProvider(baseURL: URL(string: "http://www.example * In case you want to connect non-secure servers for WebDAV (http) in iOS 9+ / macOS 10.11+ you should disable App Transport Security (ATS) according to [this guide.](https://gist.github.com/mlynch/284699d676fe9ed0abfa) -* For Dropbox & OneDrive, user is clientID and password is Token which both must be retrieved via [OAuth2 API of Dropbox](https://www.dropbox.com/developers/reference/oauth-guide). There are libraries like [p2/OAuth2](https://github.com/p2/OAuth2) or [OAuthSwift](https://github.com/OAuthSwift/OAuthSwift) which can facilate the procedure to retrieve token. The latter is easier to use and prefered. Also you can use [auth0/Lock](https://github.com/auth0/Lock.iOS-OSX) which provides graphical user interface. +* For Dropbox & OneDrive, user is clientID and password is Token which both must be retrieved via [OAuth2 API of Dropbox](https://www.dropbox.com/developers/reference/oauth-guide). There are libraries like [p2/OAuth2](https://github.com/p2/OAuth2) or [OAuthSwift](https://github.com/OAuthSwift/OAuthSwift) which can facilate the procedure to retrieve token. The latter is easier to use and prefered. For interaction with UI, set delegate variable of `FileProvider` object -You can use `absoluteURL()` method if provider to get direct access url (local or remote files) for some file systems which allows to do so (Dropbox doesn't support and returns path simply wrapped in URL) +You can use `url(of:)` method if provider to get direct access url (local or remote files) for some file systems which allows to do so (Dropbox doesn't support and returns path simply wrapped in URL) ### Delegates @@ -384,8 +384,7 @@ You can monitor updates in some file system (Local and SMB2), there is three met ```swift // to register a new notification handler -documentsProvider.registerNotifcation(path: provider.currentPath) -{ +documentsProvider.registerNotifcation(path: provider.currentPath) { // calling functions to update UI } @@ -408,7 +407,7 @@ To check either file thumbnail is supported or not and fetch thumbnail, use (and let path = "/newImage.jpg" let thumbSize = CGSize(width: 64, height: 64) if documentsProvider.thumbnailOfFileSupported(path: path { - documentsProvider..thumbnailOfFile(path: file.path, dimension: thumbSize, completionHandler: { (image, error) in + documentsProvider.thumbnailOfFile(path: file.path, dimension: thumbSize, completionHandler: { (image, error) in DispatchQueue.main.async { self.previewImage.image = image } @@ -420,7 +419,7 @@ if documentsProvider.thumbnailOfFileSupported(path: path { ##### Meta-informations -To get meta-information like image/video taken date, dimension, etc., use (and modify) these example code: +To get meta-information like image/video taken date, location, dimension, etc., use (and modify) these example code: ```swift if documentsProvider..propertiesOfFile(path: file.path, completionHandler: { (propertiesDictionary, keys, error) in diff --git a/Sources/ExtendedLocalFileProvider.swift b/Sources/ExtendedLocalFileProvider.swift index e4b40f9..b8651df 100644 --- a/Sources/ExtendedLocalFileProvider.swift +++ b/Sources/ExtendedLocalFileProvider.swift @@ -166,7 +166,7 @@ public struct LocalFileInformationGenerator { let time = CMTimeMake(asset.duration.value / 3, asset.duration.timescale) if let cgImage = try? assetImgGenerate.copyCGImage(at: time, actualTime: nil) { #if os(macOS) - return ImageClass(cgImage: cgImage, size: NSSize.zero) + return ImageClass(cgImage: cgImage, size: .zero) #else return ImageClass(cgImage: cgImage) #endif diff --git a/Sources/FileObject.swift b/Sources/FileObject.swift index fe13068..5b88399 100644 --- a/Sources/FileObject.swift +++ b/Sources/FileObject.swift @@ -270,14 +270,14 @@ public struct FileObjectSorting { extension Array where Element: FileObject { /// Returns a sorted array of `FileObject`s by criterias set in properties. - public func sorted(by type: FileObjectSorting.SortType, ascending: Bool = true, isDirectoriesFirst: Bool = false) -> [Element] { + public func sort(by type: FileObjectSorting.SortType, ascending: Bool = true, isDirectoriesFirst: Bool = false) -> [Element] { let sorting = FileObjectSorting(type: type, ascending: ascending, isDirectoriesFirst: isDirectoriesFirst) return sorting.sort(self) as! [Element] } /// Sorts array of `FileObject`s by criterias set in properties public mutating func sorted(by type: FileObjectSorting.SortType, ascending: Bool = true, isDirectoriesFirst: Bool = false) { - self = self.sorted(by: type, ascending: ascending, isDirectoriesFirst: isDirectoriesFirst) + self = self.sort(by: type, ascending: ascending, isDirectoriesFirst: isDirectoriesFirst) } } diff --git a/Sources/FileProvider.swift b/Sources/FileProvider.swift index fea4405..c553087 100644 --- a/Sources/FileProvider.swift +++ b/Sources/FileProvider.swift @@ -111,6 +111,7 @@ public extension FileProviderBasic { } } +/// Cancels all active underlying tasks public var fileProviderCancelTasksOnInvalidating = true public protocol FileProviderBasicRemote: FileProviderBasic { @@ -832,14 +833,14 @@ extension ExtendedFileProvider { let newSize = CGSize(width: width, height: height) #if os(macOS) - var imageRect = NSRect(origin: CGPoint.zero, size: image.size) + var imageRect = NSRect(origin: .zero, size: image.size) let imageRef = image.cgImage(forProposedRect: &imageRect, context: nil, hints: nil) // Create NSImage from the CGImage using the new size return NSImage(cgImage: imageRef!, size: newSize) #else UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0) - image.draw(in: CGRect(origin: CGPoint.zero, size: newSize)) + image.draw(in: CGRect(origin: .zero, size: newSize)) let newImage = UIGraphicsGetImageFromCurrentImageContext() ?? image UIGraphicsEndImageContext() return newImage @@ -876,7 +877,7 @@ public enum FileOperationType: CustomStringConvertible { } } - /// present participle of action, like 'Copying`. + /// present participle of action, like `Copying`. public var actionDescription: String { return description.trimmingCharacters(in: CharacterSet(charactersIn: "e")) + "ing" }