diff --git a/.mention-bot b/.mention-bot new file mode 100644 index 0000000..08affd9 --- /dev/null +++ b/.mention-bot @@ -0,0 +1,3 @@ +{ + "maxReviewers": 2 +} diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..59cabaa --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,40 @@ +included: # paths to include during linting. `--path` is ignored if present. + - Source +excluded: # paths to ignore during linting. Takes precedence over `included`. + - Carthage + - Pods + +# configurable rules can be customized from this configuration file +# binary rules can set their severity level +force_cast: warning # implicitly +force_try: + severity: warning # explicitly +# rules that have both warning and error levels, can set just the warning level +# implicitly +line_length: 200 +# they can set both implicitly with an array +type_body_length: + - 300 # warning + - 400 # error +# or they can set both explicitly +file_length: + warning: 500 + error: 1200 +# naming rules can set warnings/errors for min_length and max_length +# additionally they can set excluded names +type_name: + min_length: 3 # only warning + max_length: # warning and error + warning: 40 + error: 50 + excluded: iPhone # excluded via string +variable_name: + min_length: # only min_length + error: 2 # only error + excluded: # excluded via string array + - x + - y + - id + - URL + - GlobalAPIKey +reporter: "xcode" # reporter type (xcode, json, csv, checkstyle) diff --git a/Cartfile.resolved b/Cartfile.resolved index 3b2a447..83e1b6c 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1,2 @@ -github "hyperoslo/Cache" "5af9d7f80b5c39ec578c54874d5acda248d10831" +github "krzyzanowskim/CryptoSwift" "0.4.1" +github "hyperoslo/Cache" "36ef82487589ad6c91cfc66308ff0c799512b9d6" diff --git a/Imaginary.xcodeproj/project.pbxproj b/Imaginary.xcodeproj/project.pbxproj index 3e8b92e..cab6ace 100644 --- a/Imaginary.xcodeproj/project.pbxproj +++ b/Imaginary.xcodeproj/project.pbxproj @@ -128,6 +128,7 @@ D5DF758E1C403D8200BF1AB6 /* Headers */, D5DF758F1C403D8200BF1AB6 /* Resources */, D5DF75B31C403FC700BF1AB6 /* Run Script */, + BD58C3AF1CF30382003F7141 /* ShellScript */, ); buildRules = ( ); @@ -180,6 +181,19 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + BD58C3AF1CF30382003F7141 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi"; + }; D5DF75B31C403FC700BF1AB6 /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/Source/Data/Capsule.swift b/Source/Data/Capsule.swift index f235b54..df1928a 100644 --- a/Source/Data/Capsule.swift +++ b/Source/Data/Capsule.swift @@ -1,6 +1,6 @@ import Foundation -class Capsule : NSObject { +class Capsule: NSObject { static var ObjectKey = 0 let value: Any diff --git a/Source/Data/Fetcher.swift b/Source/Data/Fetcher.swift index ef08bc5..ae9f774 100644 --- a/Source/Data/Fetcher.swift +++ b/Source/Data/Fetcher.swift @@ -84,7 +84,7 @@ class Fetcher { func complete(closure: () -> Void) { active = false - + dispatch_async(dispatch_get_main_queue()) { closure() } diff --git a/Source/Extensions/UIImageView+Imaginary.swift b/Source/Extensions/UIImageView+Imaginary.swift index f5e38c9..f31dca0 100644 --- a/Source/Extensions/UIImageView+Imaginary.swift +++ b/Source/Extensions/UIImageView+Imaginary.swift @@ -55,7 +55,7 @@ extension UIImageView { return fetcher } set (fetcher) { - var wrapper : Capsule? + var wrapper: Capsule? if let fetcher = fetcher { wrapper = Capsule(value: fetcher) } diff --git a/Source/Imaginary.swift b/Source/Imaginary.swift index 76458a7..6912cc4 100644 --- a/Source/Imaginary.swift +++ b/Source/Imaginary.swift @@ -6,7 +6,7 @@ public struct Imaginary { public static var preConfigure: ((imageView: UIImageView) -> Void)? = { imageView in imageView.layer.opacity = 0.0 } - + public static var transitionClosure: ((imageView: UIImageView, image: UIImage) -> Void) = { imageView, newImage in guard let oldImage = imageView.image else { imageView.image = newImage @@ -31,14 +31,16 @@ public struct Imaginary { } public var imageCache: Cache { + struct Static { static let config = Config( frontKind: .Memory, backKind: .Disk, expiry: .Date(NSDate().dateByAddingTimeInterval(60 * 60 * 24 * 3)), - maxSize: 0) + maxSize: 0, + maxObjects: 10) - static let cache = Cache(name: "Imaginary") + static let cache = Cache(name: "Imaginary", config: config) } return Static.cache