Skip to content

Commit

Permalink
working on unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leogdion committed Aug 2, 2018
1 parent 8d5559d commit 466ce70
Show file tree
Hide file tree
Showing 25 changed files with 196 additions and 89 deletions.
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.3.7
3 changes: 0 additions & 3 deletions Brewfile

This file was deleted.

9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# gem "rails"

gem "cocoapods", "~> 1.5"
76 changes: 76 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.0)
activesupport (4.2.10)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
atomos (0.1.2)
claide (1.0.2)
cocoapods (1.5.3)
activesupport (>= 4.0.2, < 5)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.5.3)
cocoapods-deintegrate (>= 1.0.2, < 2.0)
cocoapods-downloader (>= 1.2.0, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-stats (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.3.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (~> 2.0.1)
gh_inspector (~> 1.0)
molinillo (~> 0.6.5)
nap (~> 1.0)
ruby-macho (~> 1.1)
xcodeproj (>= 1.5.7, < 2.0)
cocoapods-core (1.5.3)
activesupport (>= 4.0.2, < 6)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
cocoapods-deintegrate (1.0.2)
cocoapods-downloader (1.2.1)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.3.0)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.1.0)
colored2 (3.1.2)
concurrent-ruby (1.0.5)
escape (0.0.4)
fourflusher (2.0.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
minitest (5.11.3)
molinillo (0.6.5)
nanaimo (0.2.6)
nap (1.1.0)
netrc (0.11.0)
ruby-macho (1.2.0)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
xcodeproj (1.5.9)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.2)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.2.5)

PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 1.5)

BUNDLED WITH
1.16.2
1 change: 0 additions & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ target 'Speculid' do
target 'SpeculidTests' do
inherit! :search_paths
# Pods for testing
pod 'RandomKit', '~> 5.2.3'
end

end
Expand Down
22 changes: 5 additions & 17 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@
PODS:
- RandomKit (5.2.3):
- ShiftOperations (~> 1.0.2)
- Threadly (~> 1.0)
- ShiftOperations (1.0.2)
- SwiftFormat/CLI (0.33.11)
- SwiftLint (0.26.0)
- SwiftFormat/CLI (0.34.1)
- SwiftLint (0.27.0)
- SwiftVer (2.0.4)
- Threadly (1.2.0)

DEPENDENCIES:
- RandomKit (~> 5.2.3)
- SwiftFormat/CLI
- SwiftLint
- SwiftVer

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- RandomKit
- ShiftOperations
- SwiftFormat
- SwiftLint
- SwiftVer
- Threadly

SPEC CHECKSUMS:
RandomKit: 380745911c4f7989707489b2ce297194bfcf5031
ShiftOperations: 702c9aa98d3b20d98dceb71dd8437b562f7ab3ad
SwiftFormat: fa1b577bb4f0cd4f8cfe70d07945aa894ef5f97a
SwiftLint: f6b83e8d95ee1e91e11932d843af4fdcbf3fc764
SwiftFormat: 30408c64fbbb409387426b5cdd8225e0bd357e15
SwiftLint: 3207c1faa2240bf8973b191820a116113cd11073
SwiftVer: 85fca0c0087660e0b07fe021efdd4b794046e465
Threadly: b772ed7c1ff4a3f03eb4600bbc5ef83b3be5cb29

PODFILE CHECKSUM: 2f47a4ea7df13fb6f6479616c920a18b685187d2
PODFILE CHECKSUM: 2ecd26879e8bf7a7ac71ae7dbb51d7fe0d3d478d

COCOAPODS: 1.5.3
16 changes: 6 additions & 10 deletions Speculid.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@
B3B5E9E81F96C74C004A6BEB /* CommandLineRunner.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B5E9E71F96C74C004A6BEB /* CommandLineRunner.swift */; };
B3B5E9EA1F96C777004A6BEB /* SpeculidApplicationModeParserProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B5E9E91F96C777004A6BEB /* SpeculidApplicationModeParserProtocol.swift */; };
B3B5E9EC1F96C7D5004A6BEB /* SpeculidApplicationModeParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B5E9EB1F96C7D5004A6BEB /* SpeculidApplicationModeParser.swift */; };
B3CB15702113AA8C00A6DC5C /* VersionProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3CB156F2113AA8C00A6DC5C /* VersionProvider.swift */; };
B3D32A021F9A5D760042B46F /* help.txt in Resources */ = {isa = PBXBuildFile; fileRef = B3D32A011F9A5D750042B46F /* help.txt */; };
B3D32A041F9A5E8F0042B46F /* CommandLineRunnerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3D32A031F9A5E8F0042B46F /* CommandLineRunnerTest.swift */; };
B3D32A061F9A5FEE0042B46F /* FileHandle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3D32A051F9A5FEE0042B46F /* FileHandle.swift */; };
Expand Down Expand Up @@ -1522,7 +1523,6 @@
B35B71251F904CF100BE477E /* SurfaceHandleBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SurfaceHandleBuilder.h; sourceTree = "<group>"; };
B35B71261F904CF100BE477E /* SurfaceHandleBuilder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SurfaceHandleBuilder.m; sourceTree = "<group>"; };
B35B71291F9052B200BE477E /* CairoSize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CairoSize.h; sourceTree = "<group>"; };
B35D13271FCF604C0047F1B8 /* Brewfile */ = {isa = PBXFileReference; lastKnownFileType = text; path = Brewfile; sourceTree = "<group>"; };
B36C2E8A1FA5B876003F48BD /* build.list */ = {isa = PBXFileReference; lastKnownFileType = text; path = build.list; sourceTree = "<group>"; };
B37C743E1F8C58F300DF505B /* Speculid.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Speculid.app; sourceTree = BUILT_PRODUCTS_DIR; };
B37C74431F8C58F300DF505B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1573,6 +1573,7 @@
B3B5E9E71F96C74C004A6BEB /* CommandLineRunner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandLineRunner.swift; sourceTree = "<group>"; };
B3B5E9E91F96C777004A6BEB /* SpeculidApplicationModeParserProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpeculidApplicationModeParserProtocol.swift; sourceTree = "<group>"; };
B3B5E9EB1F96C7D5004A6BEB /* SpeculidApplicationModeParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpeculidApplicationModeParser.swift; sourceTree = "<group>"; };
B3CB156F2113AA8C00A6DC5C /* VersionProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionProvider.swift; sourceTree = "<group>"; };
B3CEF3C41FB611D200F1DF87 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
B3D2F6AC1FB3EB7E00BF7AC1 /* shasum.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = shasum.sh; sourceTree = "<group>"; };
B3D32A011F9A5D750042B46F /* help.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = help.txt; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4087,7 +4088,6 @@
isa = PBXGroup;
children = (
B3F1C92D20F675FC0072F7C0 /* codesign-framework.sh */,
B35D13271FCF604C0047F1B8 /* Brewfile */,
B31D2AEB1FBC8F1D008087A6 /* build.sh */,
B3D2F6AC1FB3EB7E00BF7AC1 /* shasum.sh */,
B3B049C81FA262A8002906B1 /* exportOptions.plist */,
Expand Down Expand Up @@ -4155,16 +4155,16 @@
B3B5E9E71F96C74C004A6BEB /* CommandLineRunner.swift */,
B3136DF31F90F73A0002B7AB /* ImageConversionBuilder.swift */,
B3136DF01F90F73A0002B7AB /* ImageConversionSetBuilder.swift */,
B317B0D01FA560EE00BB5E57 /* QuitMenuItem.swift */,
B31BEAFB1F96269F00496E7A /* RegularExpressionSet.swift */,
B31BEAF81F96268000496E7A /* RegularExpressionSetBuilder.swift */,
B33F0BB81F958695004A87DD /* RemoteObjectInterfaceProvider.swift */,
B3136DCC1F90E2A20002B7AB /* Service.swift */,
B3B5E9EB1F96C7D5004A6BEB /* SpeculidApplicationModeParser.swift */,
B3136DF21F90F73A0002B7AB /* SpeculidBuilder.swift */,
B3B5E9D81F96C1BE004A6BEB /* SpeculidConfigurationBuilder.swift */,
B33F0BBA1F9586A9004A87DD /* StatusItemProvider.swift */,
B3F0ECF11F9E6AAD0078690E /* SpeculidImageSpecificationBuilder.swift */,
B317B0D01FA560EE00BB5E57 /* QuitMenuItem.swift */,
B33F0BBA1F9586A9004A87DD /* StatusItemProvider.swift */,
B3FAD3EA1FA564D0004381A7 /* VersionMenuItem.swift */,
);
path = Controllers;
Expand Down Expand Up @@ -4243,6 +4243,7 @@
B3136E091F90F73B0002B7AB /* SpeculidSpecificationsFileProtocol.swift */,
B33A53391F954E4B00E74800 /* StatusItemProviderProtocol.swift */,
B3F0ECEF1F9E6A4D0078690E /* SpeculidImageSpecificationBuilderProtocol.swift */,
B3CB156F2113AA8C00A6DC5C /* VersionProvider.swift */,
);
path = Protocols;
sourceTree = "<group>";
Expand Down Expand Up @@ -14450,16 +14451,10 @@
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-SpeculidTests/Pods-SpeculidTests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/RandomKit/RandomKit.framework",
"${BUILT_PRODUCTS_DIR}/ShiftOperations/ShiftOperations.framework",
"${BUILT_PRODUCTS_DIR}/Threadly/Threadly.framework",
"${BUILT_PRODUCTS_DIR}/SwiftVer/SwiftVer.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RandomKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ShiftOperations.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Threadly.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftVer.framework",
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -14602,6 +14597,7 @@
B3136E491F90F73B0002B7AB /* ImageConversionSetProtocol.swift in Sources */,
B3136E581F90F73B0002B7AB /* ProcessError.swift in Sources */,
B3136E541F90F73B0002B7AB /* ApplicationProtocol.swift in Sources */,
B3CB15702113AA8C00A6DC5C /* VersionProvider.swift in Sources */,
B3B5E9DA1F96C1C1004A6BEB /* SpeculidConfigurationBuilder.swift in Sources */,
B341888A1F9A44A700C5F356 /* CommandLineArgumentProviderProtocol.swift in Sources */,
B33A533E1F954FF800E74800 /* Result.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,31 +85,31 @@
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "-help"
argument = "--help"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "&quot;${SRCROOT}/examples/Assets/macOS AppIcon.speculid&quot;"
argument = "--process &quot;${SRCROOT}/examples/Assets/macOS AppIcon.speculid&quot;"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "&quot;${SRCROOT}/examples/Assets/AppIcon.speculid&quot;"
argument = "--process &quot;${SRCROOT}/examples/Assets/AppIcon.speculid&quot;"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "&quot;${SRCROOT}/examples/Assets/Image Set.speculid&quot;"
argument = "--process &quot;${SRCROOT}/examples/Assets/Image Set.speculid&quot;"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "&quot;${SRCROOT}/applications/mac/assets/svg-appicon.speculid&quot;"
argument = "--process &quot;${SRCROOT}/applications/mac/assets/svg-appicon.speculid&quot;"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "&quot;${SRCROOT}/applications/mac/assets/svg-trayicon.speculid&quot;"
argument = "--process&quot;${SRCROOT}/applications/mac/assets/svg-trayicon.speculid&quot;"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "-version"
argument = "--version"
isEnabled = "NO">
</CommandLineArgument>
</CommandLineArguments>
Expand Down
3 changes: 0 additions & 3 deletions Speculid.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "xcodebuild -workspace \"${SRCROOT}/../speculid.xcworkspace\" -scheme \"Speculid Application\" -derivedDataPath \"${PROJECT_TEMP_DIR}/speculid\" build -configuration Release SYMROOT=build CODE_SIGNING_REQUIRED=NO OBJROOT=\"${PROJECT_TEMP_DIR}/speculid\" SYMROOT=\"${PROJECT_TEMP_DIR}/speculid\"";
shellScript = "xcodebuild -workspace \"${SRCROOT}/../speculid.xcworkspace\" -scheme \"Speculid Application\" -derivedDataPath \"${PROJECT_TEMP_DIR}/speculid\" build -configuration Release SYMROOT=build CODE_SIGNING_REQUIRED=NO OBJROOT=\"${PROJECT_TEMP_DIR}/speculid\" SYMROOT=\"${PROJECT_TEMP_DIR}/speculid\"\n";
};
B38DDF241DA2E344005AA837 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -524,7 +524,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "find \"${SRCROOT}\" -name \"*.spcld\" -print0 |\nwhile IFS= read -r -d $'\\0' line; do\n\"${PROJECT_TEMP_DIR}/speculid/Release/Speculid.app/Contents/MacOS/Speculid\" \"$line\" &\ndone\nwait";
shellScript = "find \"${SRCROOT}\" -name \"*.spcld\" -print0 |\nwhile IFS= read -r -d $'\\0' line; do\n\"${PROJECT_TEMP_DIR}/speculid/Release/Speculid.app/Contents/MacOS/Speculid\" \"$line\" &\ndone\nwait\n";
};
B3AF65D51DA4055900BD008B /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
12 changes: 8 additions & 4 deletions frameworks/speculid/Controllers/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ open class Application: NSApplication, ApplicationProtocol {
imageSpecificationBuilder = SpeculidImageSpecificationBuilder()
commandLineRunner = CommandLineRunner(
outputStream: FileHandle.standardOutput,
errorStream: FileHandle.standardError)
errorStream: FileHandle.standardError
)

super.init()
}
Expand All @@ -79,7 +80,8 @@ open class Application: NSApplication, ApplicationProtocol {
imageSpecificationBuilder = SpeculidImageSpecificationBuilder()
commandLineRunner = CommandLineRunner(
outputStream: FileHandle.standardOutput,
errorStream: FileHandle.standardError)
errorStream: FileHandle.standardError
)

super.init(coder: coder)
}
Expand All @@ -101,7 +103,8 @@ open class Application: NSApplication, ApplicationProtocol {
trackingIdentifier: "UA-33667276-6",
applicationName: "speculid",
applicationVersion: applicationVersion,
customParameters: [.operatingSystemVersion: operatingSystem, .model: Sysctl.model])
customParameters: [.operatingSystemVersion: operatingSystem, .model: Sysctl.model]
)

remoteObjectInterfaceProvider.remoteObjectProxyWithHandler { result in
switch result {
Expand Down Expand Up @@ -167,5 +170,6 @@ open class Application: NSApplication, ApplicationProtocol {
public let version = Version(
bundle: bundle,
dictionary: sbd,
versionControl: vcs)
versionControl: vcs
)
}
11 changes: 8 additions & 3 deletions frameworks/speculid/Controllers/CommandLineRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ public struct UnknownArgumentsError: Error {
public class CommandLineRunner: CommandLineRunnerProtocol {
public var errorStream: TextOutputStream
public var outputStream: TextOutputStream
private let _versionProvider: VersionProvider?

public init(outputStream: TextOutputStream, errorStream: TextOutputStream) {
public var versionProvider: VersionProvider {
return _versionProvider ?? Application.current
}
public init(outputStream: TextOutputStream, errorStream: TextOutputStream, versionProvider: VersionProvider? = nil) {
self.outputStream = outputStream
self.errorStream = errorStream
_versionProvider = versionProvider
}

public func activity(withArguments arguments: SpeculidCommandArgumentSet, _ completed: @escaping (CommandLineActivityProtocol, Error?) -> Void) -> CommandLineActivityProtocol {
Expand All @@ -31,13 +36,13 @@ public class CommandLineRunner: CommandLineRunnerProtocol {
error = UnknownArgumentsError(arguments: arguments)
return completed()
case .version:
if let version = Application.current.version {
if let version = self.versionProvider.version {
self.outputStream.write(version.developmentDescription)
} else {
self.outputStream.write("\(Application.bundle.infoDictionary?["CFBundleShortVersionString"]) (\(Application.bundle.infoDictionary?["CFBundleVersion"]))")
}
return completed()
case let .file(url):
case let .process(url):
let tryDocument: SpeculidDocumentProtocol?
do {
tryDocument = try Application.current.document(url: url)
Expand Down
6 changes: 4 additions & 2 deletions frameworks/speculid/Controllers/ImageConversionBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ public struct ImageConversionBuilder: ImageConversionBuilderProtocol {
public func conversion(
forImage imageSpecification: AssetSpecificationProtocol,
withSpecifications specifications: SpeculidSpecificationsFileProtocol,
andConfiguration configuration: SpeculidConfigurationProtocol) -> Result<ImageConversionTaskProtocol>? {
andConfiguration configuration: SpeculidConfigurationProtocol
) -> Result<ImageConversionTaskProtocol>? {
for builders in builders {
if let conversion = builders.conversion(
forImage: imageSpecification,
withSpecifications: specifications,
andConfiguration: configuration) {
andConfiguration: configuration
) {
return conversion
}
}
Expand Down
Loading

0 comments on commit 466ce70

Please sign in to comment.