-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
now generated files variables are sorted alphabetically, chroma now l…
…ooks for existing file and replace it allowing it to run on project root without worrying about where the file is located, updated default generated file name to Colors.swift, clean up package structure & added unit tests
- Loading branch information
Jota Uribe
authored and
Jota Uribe
committed
Jul 12, 2021
1 parent
e5c8c79
commit 1d2678d
Showing
15 changed files
with
174 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,4 @@ extension File { | |
} | ||
self = file | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,5 +26,4 @@ extension Folder { | |
return platform.colorVariable(name: colorFolder.nameExcludingExtension) | ||
}) | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
Sources/Chroma/Output.swift → Sources/ChromaLibrary/OutputType.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// Output.swift | ||
// OutputType.swift | ||
// Chroma | ||
// | ||
// Created by Jota Uribe on 8/06/20. | ||
|
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import XCTest | ||
import Files | ||
@testable import ChromaLibrary | ||
|
||
final class FolderTests: XCTestCase { | ||
func testColorDefinitionsForiOS() throws { | ||
let path = Bundle.module.bundlePath | ||
let folder = try Folder(path: path) | ||
let definitions = folder.colorDefinitions(for: .iOS) | ||
XCTAssertEqual(definitions.count, 2) | ||
XCTAssertEqual(definitions.sorted().first, " static var ExampleColor1: UIColor { return UIColor(named: \"ExampleColor1\")! }") | ||
} | ||
|
||
func testColorDefinitionsForMacOS() throws { | ||
let path = Bundle.module.bundlePath | ||
let folder = try Folder(path: path) | ||
let definitions = folder.colorDefinitions(for: .macOS) | ||
XCTAssertEqual(definitions.count, 2) | ||
XCTAssertEqual(definitions.sorted().first, " static var ExampleColor1: NSColor { return NSColor(named: \"ExampleColor1\")! }") | ||
} | ||
|
||
func testColorDefinitionsForSwiftUI() throws { | ||
let path = Bundle.module.bundlePath | ||
let folder = try Folder(path: path) | ||
let definitions = folder.colorDefinitions(for: .swiftUI) | ||
XCTAssertEqual(definitions.count, 2) | ||
XCTAssertEqual(definitions.sorted().first, " static var ExampleColor1: Color { return Color(\"ExampleColor1\") }") | ||
} | ||
|
||
static var allTests = [ | ||
("testColorDefinitionsForiOS", testColorDefinitionsForiOS), | ||
("testColorDefinitionsForMacOS", testColorDefinitionsForMacOS), | ||
("testColorDefinitionsForSwiftUI", testColorDefinitionsForSwiftUI) | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import XCTest | ||
import Files | ||
@testable import ChromaLibrary | ||
|
||
final class PlatformTests: XCTestCase { | ||
func testColorVariableForiOS() throws { | ||
let variable = Platform.iOS.colorVariable(name: "ExampleColor1") | ||
XCTAssertEqual(variable, " static var ExampleColor1: UIColor { return UIColor(named: \"ExampleColor1\")! }") | ||
} | ||
|
||
func testColorVariableForMacOS() throws { | ||
let variable = Platform.macOS.colorVariable(name: "ExampleColor1") | ||
XCTAssertEqual(variable, " static var ExampleColor1: NSColor { return NSColor(named: \"ExampleColor1\")! }") | ||
} | ||
|
||
func testColorVariableForSwiftUI() throws { | ||
let variable = Platform.swiftUI.colorVariable(name: "ExampleColor1") | ||
XCTAssertEqual(variable, " static var ExampleColor1: Color { return Color(\"ExampleColor1\") }") | ||
} | ||
|
||
static var allTests = [ | ||
("testColorVariableForiOS", testColorVariableForiOS), | ||
("testColorVariableForMacOS", testColorVariableForMacOS), | ||
("testColorVariableForSwiftUI", testColorVariableForSwiftUI) | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Tests/ChromaTests/Resources/Tests.xcassets/ExampleColor1.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0.000", | ||
"green" : "0.000", | ||
"red" : "0.000" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "1.000", | ||
"green" : "1.000", | ||
"red" : "1.000" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Tests/ChromaTests/Resources/Tests.xcassets/ExampleColor2.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0.000", | ||
"green" : "0.000", | ||
"red" : "0.000" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "1.000", | ||
"green" : "1.000", | ||
"red" : "1.000" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters