Skip to content

Commit

Permalink
Merge branch 'release/0.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
malcommac committed Apr 19, 2018
2 parents 9df1568 + c19397a commit ef969d3
Show file tree
Hide file tree
Showing 16 changed files with 373 additions and 283 deletions.
81 changes: 81 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
disabled_rules: # rule identifiers to exclude from running
- line_length
- function_body_length
- cyclomatic_complexity
- multiple_closures_with_trailing_closure
- xctfail_message

# Swift 3 rules that do not make sense for Swift 2.3
- implicit_getter

identifier_name:
min_length:
warning: 1
error: 1
max_length:
warning: 60
error: 80

type_name:
max_length:
warning: 60
error: 100

type_body_length:
warning: 300
error: 400

file_length:
warning: 700
error: 800

excluded:
- Pods

function_parameter_count:
warning: 7
error: 10

large_tuple:
warning: 3

opt_in_rules: # some rules are only opt-in
- closure_end_indentation
- closure_spacing
- syntactic_sugar
- redundant_nil_coalescing
- number_separator
- sorted_imports
- overridden_super_call
- object_literal
- explicit_init
- first_where
- operator_usage_whitespace


number_separator:
minimum_length: 7

custom_rules:
double_space: # from https://github.com/IBM-Swift/Package-Builder
include: "*.swift"
name: "Double space"
regex: '([a-z,A-Z] \s+)'
message: "Double space between keywords"
match_kinds: keyword
severity: warning
comments_space: # from https://github.com/brandenr/swiftlintconfig
name: "Space After Comment"
regex: '(^ *//\w+)'
message: "There should be a space after //"
severity: warning
empty_line_after_guard: # from https://github.com/brandenr/swiftlintconfig
name: "Empty Line After Guard"
regex: '(^ *guard[ a-zA-Z0-9=?.\(\),><!]*\{[ a-zA-Z0-9=?.\(\),><!]*\}\n *(?!(?:return|guard))\S+)'
message: "There should be an empty line after a guard"
severity: warning
unnecessary_type: # from https://github.com/brandenr/swiftlintconfig
name: "Unnecessary Type"
regex: '[ a-zA-Z0-9]*(?:let|var) [ a-zA-Z0-9]*: ([a-zA-Z0-9]*)[ ]*= \1'
message: "Type Definition Not Needed"
severity: warning
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## CHANGELOG

Latest version of Repeat is [0.5.1](https://github.com/malcommac/Repeat/releases/tag/0.5.1) published on 2018/03/18.
Latest version of Repeat is [0.5.2](https://github.com/malcommac/Repeat/releases/tag/0.5.2) published on 2018/04/19.

**Changelog - 0.5.2**:

- [#14](https://github.com/malcommac/Repeat/pull/14): Refactors equatable implementation to use an identity operator.

**Changelog - 0.5.1**:

Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let package = Package(
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Repeat",
targets: ["Repeat"]),
targets: ["Repeat"])
],
dependencies: [
// Dependencies declare other packages that this package depends on.
Expand All @@ -23,6 +23,6 @@ let package = Package(
dependencies: []),
.testTarget(
name: "RepeatTests",
dependencies: ["Repeat"]),
dependencies: ["Repeat"])
]
)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ All Apple platforms are supported:

## Latest Version

Latest version of Repeat is [0.5.1](https://github.com/malcommac/Repeat/releases/tag/0.5.1) published on 2018/03/18.
Latest version of Repeat is [0.5.2](https://github.com/malcommac/Repeat/releases/tag/0.5.2) published on 2018/04/19.
Full changelog is available in [CHANGELOG.md](CHANGELOG.md) file.

## Installation
Expand Down
2 changes: 1 addition & 1 deletion Repeat.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Repeat"
s.version = "0.5.1"
s.version = "0.5.2"
s.summary = "Modern NSTimer alternative in Swift"
s.description = <<-DESC
Repeat is a modern alternative to NSTimer; no strong references, multiple observers, reusable instances with start/stop/pause support in swifty syntax.
Expand Down
26 changes: 25 additions & 1 deletion Repeat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
644EE2E4205D228D00238416 /* Repeat.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = Repeat.podspec; sourceTree = "<group>"; };
644EE2E5205D229300238416 /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
64A18883204D313800DC2B4B /* Repeater.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Repeater.swift; path = Repeat/Repeater.swift; sourceTree = "<group>"; };
64D71A022088AB3B0042C1A2 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .swiftlint.yml; sourceTree = "<group>"; };
8933C7891EB5B82A000D00A4 /* RepeatTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepeatTests.swift; sourceTree = "<group>"; };
AD2FAA261CD0B6D800659CF4 /* Repeat.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Repeat.plist; sourceTree = "<group>"; };
AD2FAA281CD0B6E100659CF4 /* RepeatTests.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = RepeatTests.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -132,6 +133,7 @@
644EE2E3205D15D100238416 /* README.md */,
644EE2E5205D229300238416 /* CHANGELOG.md */,
644EE2E4205D228D00238416 /* Repeat.podspec */,
64D71A022088AB3B0042C1A2 /* .swiftlint.yml */,
8933C7811EB5B7E0000D00A4 /* Sources */,
8933C7831EB5B7EB000D00A4 /* Tests */,
52D6D99C1BEFF38C002C0205 /* Configs */,
Expand Down Expand Up @@ -239,6 +241,7 @@
52D6D9781BEFF229002C0205 /* Frameworks */,
52D6D9791BEFF229002C0205 /* Headers */,
52D6D97A1BEFF229002C0205 /* Resources */,
64D71A042088AB880042C1A2 /* SwiftLint */,
);
buildRules = (
);
Expand Down Expand Up @@ -364,7 +367,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = Repeat;
TargetAttributes = {
52D6D97B1BEFF229002C0205 = {
Expand Down Expand Up @@ -472,6 +475,23 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
64D71A042088AB880042C1A2 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = SwiftLint;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "swiftlint autocorrect\nif which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
52D6D9771BEFF229002C0205 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -570,12 +590,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -627,12 +649,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
4 changes: 1 addition & 3 deletions Repeat.xcodeproj/xcshareddata/xcschemes/Repeat-iOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -56,7 +55,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -56,7 +55,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
4 changes: 1 addition & 3 deletions Repeat.xcodeproj/xcshareddata/xcschemes/Repeat-tvOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -56,7 +55,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -37,7 +36,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
20 changes: 10 additions & 10 deletions Sources/Repeat/Debouncer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ import Foundation
/// The Debouncer will delay a function call, and every time it's getting called it will
/// delay the preceding call until the delay time is over.
open class Debouncer {

/// Typealias for callback type
public typealias Callback = (() -> (Void))
public typealias Callback = (() -> Void)

/// Delay interval
public let delay: Repeater.Interval

/// Callback to activate
public var callback: Callback? = nil
public var callback: Callback?

/// Internal timer to fire callback event.
private var timer: Repeater?

/// Initialize a new debouncer with given delay and callback.
/// Debouncer class to delay functions that only get delay each other until the timer fires.
///
Expand All @@ -55,17 +55,17 @@ open class Debouncer {
self.delay = delay
self.callback = callback
}

/// Call debouncer to start the callback after the delayed time.
/// Multiple calls will ignore the older calls and overwrite the firing time.
public func call() {
if self.timer == nil {
self.timer = Repeater.once(after: self.delay, { _ in
guard let cb = self.callback else {
guard let callback = self.callback else {
debugPrint("Debouncer fired but callback not set.")
return
}
cb()
callback()
})
} else {
self.timer?.reset(self.delay, restart: true)
Expand Down
Loading

0 comments on commit ef969d3

Please sign in to comment.