From d614bc0b2c581a4c0dba4ddd44db347dd825fc86 Mon Sep 17 00:00:00 2001 From: Alexandr Goncharov Date: Sun, 8 Oct 2017 02:15:55 +0300 Subject: [PATCH] Create a package --- .gitignore | 1 + .swift-version | 2 + .swiftlint.yml | 41 +++++++++++++++++++ Package.swift | 29 +++++++++++++ .../JSONDecoder_Keypath.swift | 3 ++ .../JSONDecoder_KeypathTests.swift | 16 ++++++++ Tests/LinuxMain.swift | 6 +++ 7 files changed, 98 insertions(+) create mode 100644 .swift-version create mode 100644 .swiftlint.yml create mode 100644 Package.swift create mode 100644 Sources/JSONDecoder-Keypath/JSONDecoder_Keypath.swift create mode 100644 Tests/JSONDecoder-KeypathTests/JSONDecoder_KeypathTests.swift create mode 100644 Tests/LinuxMain.swift diff --git a/.gitignore b/.gitignore index d534044..23cc35c 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,4 @@ fastlane/report.xml fastlane/Preview.html fastlane/screenshots fastlane/test_output +JSONDecoder-Keypath.xcodeproj diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..8ccd63e --- /dev/null +++ b/.swift-version @@ -0,0 +1,2 @@ +4.0 + diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..076e05c --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,41 @@ +included: # paths to include during linting. `--path` is ignored if present. + - Sources + - Tests +excluded: # paths to ignore during linting. Takes precedence over `included`. + - Carthage + - Pods +reporter: "xcode" # reporter type (xcode, json, csv, checkstyle) + +disabled_rules: # rule identifiers to exclude from running + - line_length + - todo + - nesting +opt_in_rules: # some rules are only opt-in + - empty_count + - explicit_init + - closure_spacing + - overridden_super_call + - redundant_nil_coalescing + - private_outlet + - operator_usage_whitespace + - first_where + - fatal_error_message + - vertical_parameter_alignment_on_call + - unneeded_parentheses_in_closure_argument + - extension_access_modifier + - pattern_matching_keywords + - force_unwrapping + + +# configurable rules can be customized from this configuration file +# binary rules can set their severity level +trailing_whitespace: + ignores_empty_lines: true + ignores_comments: true + +vertical_whitespace: # Limit vertical whitespace to a single empty line. + max_empty_lines: 2 + +identifier_name: + excluded: + - id \ No newline at end of file diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..b74aee7 --- /dev/null +++ b/Package.swift @@ -0,0 +1,29 @@ +// swift-tools-version:4.0 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "JSONDecoder-Keypath", + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "JSONDecoder-Keypath", + targets: ["JSONDecoder-Keypath"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + .target( + name: "JSONDecoder-Keypath", + dependencies: []), + .testTarget( + name: "JSONDecoder-KeypathTests", + dependencies: ["JSONDecoder-Keypath"]), + ], + swiftLanguageVersions: [4] +) diff --git a/Sources/JSONDecoder-Keypath/JSONDecoder_Keypath.swift b/Sources/JSONDecoder-Keypath/JSONDecoder_Keypath.swift new file mode 100644 index 0000000..63d98ea --- /dev/null +++ b/Sources/JSONDecoder-Keypath/JSONDecoder_Keypath.swift @@ -0,0 +1,3 @@ +struct JSONDecoder_Keypath { + var text = "Hello, World!" +} diff --git a/Tests/JSONDecoder-KeypathTests/JSONDecoder_KeypathTests.swift b/Tests/JSONDecoder-KeypathTests/JSONDecoder_KeypathTests.swift new file mode 100644 index 0000000..838791f --- /dev/null +++ b/Tests/JSONDecoder-KeypathTests/JSONDecoder_KeypathTests.swift @@ -0,0 +1,16 @@ +import XCTest +@testable import JSONDecoder_Keypath + +class JSONDecoder_KeypathTests: XCTestCase { + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + XCTAssertEqual(JSONDecoder_Keypath().text, "Hello, World!") + } + + + static var allTests = [ + ("testExample", testExample), + ] +} diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100644 index 0000000..4eaae76 --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1,6 @@ +import XCTest +@testable import JSONDecoder_KeypathTests + +XCTMain([ + testCase(JSONDecoder_KeypathTests.allTests), +])