diff --git a/.gitignore b/.gitignore index 747b1a2..1aba4d3 100644 --- a/.gitignore +++ b/.gitignore @@ -35,7 +35,7 @@ playground.xcworkspace # Swift Package Manager # # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. -# Packages/ +Packages/ .build/ # CocoaPods diff --git a/.travis.yml b/.travis.yml index 148c464..3b01f9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,34 +1,59 @@ -language: objective-c -osx_image: xcode7.2 env: - global: - - FRAMEWORK_NAME=PathToRegex -before_install: - - brew update - - brew unlink carthage - - brew install carthage - - brew link carthage -before_script: - # bootstrap the dependencies for the project - # you can remove if you don't have dependencies - - carthage bootstrap -before_deploy: - - carthage build --no-skip-current - - carthage archive $FRAMEWORK_NAME - # - pod trunk push PathToRegex.podspec -script: -- xcodebuild test -project PathToRegex.xcodeproj -scheme PathToRegex -#- xcodebuild test -project Regex.xcodeproj -scheme Regex-iOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6' -#- xcodebuild test -project Regex.xcodeproj -scheme Regex-tvOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV 1080p' -#- xcodebuild build -project Regex.xcodeproj -scheme Regex-watchOS -sdk watchsimulator -destination 'platform=watchOS Simulator,name=Apple Watch - 42mm' + global: + - MODULE_NAME=PathToRegex +matrix: + include: + - script: + - xcodebuild test -project $MODULE_NAME.xcodeproj -scheme $MODULE_NAME + os: osx + osx_image: xcode7.2 + language: objective-c + before_install: + - brew update + - brew unlink carthage + - brew install carthage + - brew link carthage + before_script: + # bootstrap the dependencies for the project + # you can remove if you don't have dependencies + - carthage bootstrap + before_deploy: + - carthage build --no-skip-current + - carthage archive $MODULE_NAME + deploy: + provider: releases + api_key: + secure: 8Mxwjx8i5YytiW8s95AJ1CTi71WyPLhMd2RGMrR24oizic0zUwHG2rNBgGrnj/ONmd/sUg3XOvNgLXxLl4D5BgI6bsM/Vg+iOd+Gx4xbSmvZSBAt/aqbefSGL8Mpexpfe0vKlT+JXUy8C7WxLpKrlB3kFmaB7r0sq3bc3j/A5FkfI6uGCgEjcOr+emQ+nCr6YI3KcNfHVNquF5nXk1apJMbKJnkQK9D7iQV9wcKzXyIO8uGSMo1qrciWV8wsV6wJgBDXUspUuwa9+Je56doJb6z0kSiIc0cCZwGSkHIQEQY9v9LcB5q0YQ7UkzWM/O01VUnABzjYbKjzwQG1EZxB1PaXu4dH76QGOjg8bD2wh+P5ecYAGxc99GbscTGpEgMtSKqTXQdebsqU9xaQUBxRx5vt0HgLoCv3MTGo+CZ18XXp7Ie9Xkd5T1Nanb/i8MA4QCojNk9vCRpP3YSoGhQpfY7fZgQiRbE+L2+GxTX4jQBSIbLdPaX/ov58qLzbvpSH0nZSgXKJtk7lk4aOApCuzYlTqLs04Z5wgEgWlN3spFKuRqpK/PyAjwMVf1qctacKKZjKOA6HhZijlGtfXkYw3eVut1an/RJCSFagKhXVSvomcG3dnE+FqtLGXtLacP4jtVIkl4tdc1Y5nnTWQJbok/XofgwkNhMq0XXXmF9Lh5c= + file: $MODULE_NAME.framework.zip + skip_cleanup: true + on: + repo: crossroadlabs/PathToRegex + tags: true + - script: + # build (yes for now swift-build should be like this) + - export SBCMD=`which swift-build` + - $SBCMD + # test - temporary disabled because of bug in swift test + # - swift test + sudo: required + dist: trusty + language: generic + before_install: + # install original swift distribution + - wget -q -O - https://swift.org/keys/all-keys.asc | gpg --import - + - cd .. + - export SWIFT_VERSION=swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a + - wget https://swift.org/builds/development/ubuntu1404/$SWIFT_VERSION/$SWIFT_VERSION-ubuntu14.04.tar.gz + - tar xzf $SWIFT_VERSION-ubuntu14.04.tar.gz + - export PATH="${PWD}/${SWIFT_VERSION}-ubuntu14.04/usr/bin:${PATH}" + # install latest package manager with `swift-test` + - git clone https://github.com/apple/swift-package-manager + - cd swift-package-manager + - Utilities/bootstrap + - export SWIFT_BUILD_PATH=`pwd` + - export PATH=$SWIFT_BUILD_PATH/.build/debug:$PATH + - cd .. + # get back home + - cd $MODULE_NAME notifications: email: false -deploy: - provider: releases - api_key: - secure: 8Mxwjx8i5YytiW8s95AJ1CTi71WyPLhMd2RGMrR24oizic0zUwHG2rNBgGrnj/ONmd/sUg3XOvNgLXxLl4D5BgI6bsM/Vg+iOd+Gx4xbSmvZSBAt/aqbefSGL8Mpexpfe0vKlT+JXUy8C7WxLpKrlB3kFmaB7r0sq3bc3j/A5FkfI6uGCgEjcOr+emQ+nCr6YI3KcNfHVNquF5nXk1apJMbKJnkQK9D7iQV9wcKzXyIO8uGSMo1qrciWV8wsV6wJgBDXUspUuwa9+Je56doJb6z0kSiIc0cCZwGSkHIQEQY9v9LcB5q0YQ7UkzWM/O01VUnABzjYbKjzwQG1EZxB1PaXu4dH76QGOjg8bD2wh+P5ecYAGxc99GbscTGpEgMtSKqTXQdebsqU9xaQUBxRx5vt0HgLoCv3MTGo+CZ18XXp7Ie9Xkd5T1Nanb/i8MA4QCojNk9vCRpP3YSoGhQpfY7fZgQiRbE+L2+GxTX4jQBSIbLdPaX/ov58qLzbvpSH0nZSgXKJtk7lk4aOApCuzYlTqLs04Z5wgEgWlN3spFKuRqpK/PyAjwMVf1qctacKKZjKOA6HhZijlGtfXkYw3eVut1an/RJCSFagKhXVSvomcG3dnE+FqtLGXtLacP4jtVIkl4tdc1Y5nnTWQJbok/XofgwkNhMq0XXXmF9Lh5c= - file: $FRAMEWORK_NAME.framework.zip - skip_cleanup: true - on: - repo: crossroadlabs/PathToRegex - tags: true diff --git a/Cartfile b/Cartfile index 00fae0a..aeb9046 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "crossroadlabs/Regex" ~> 0.4 +github "crossroadlabs/Regex" ~> 0.5 diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..608fe3d --- /dev/null +++ b/Package.swift @@ -0,0 +1,32 @@ +//===--- Package.swift ------------------------------------------------===// +// +//Copyright (c) 2016 Daniel Leping (dileping) +// +//This file is part of PathToRegex. +// +//PathToRegex is free software: you can redistribute it and/or modify +//it under the terms of the GNU Lesser General Public License as published by +//the Free Software Foundation, either version 3 of the License, or +//(at your option) any later version. +// +//PathToRegex is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public License +//along with PathToRegex. If not, see . +// +//===----------------------------------------------------------------------===// + +import PackageDescription + +let package = Package( + name: "PathToRegex", + targets: [ + Target( + name: "PathToRegex" + ) + ], + dependencies: [.Package(url: "https://github.com/crossroadlabs/Regex.git", versions: Version(0,5,0)..CFBundlePackageType FMWK CFBundleShortVersionString - 0.1 + 0.2 CFBundleSignature ???? CFBundleVersion diff --git a/PathToRegex/PathToRegex.swift b/PathToRegex/PathToRegex.swift index 883a309..a390a19 100644 --- a/PathToRegex/PathToRegex.swift +++ b/PathToRegex/PathToRegex.swift @@ -182,9 +182,7 @@ func tokensToRegex (tokens:[Token], options:Options = Options()) throws -> Regex var groups = [String]() // Iterate over the tokens and create our regexp string. - for (var i = 0; i < tokens.count; i++) { - let token = tokens[i] - + for token in tokens { switch token { case .Simple(token: let token): route += escapeString(token) case .Complex(name: let tokenName, prefix: let prefix, delimeter: _, optional: let optional, repeating: let repeating, pattern: let pattern): diff --git a/README.md b/README.md index d194c57..e096be1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # PathToRegex +![🐧 linux: ready](https://img.shields.io/badge/%F0%9F%90%A7%20linux-ready-red.svg) [![GitHub license](https://img.shields.io/badge/license-LGPL v3-lightgrey.svg)](https://raw.githubusercontent.com/crossroadlabs/Express/master/LICENSE) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) ![Platform OS X | Linux](https://img.shields.io/badge/platform-OS%20X%20%7C%20Linux-orange.svg) diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100644 index 0000000..c6a81b9 --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1,28 @@ +//===--- LinuxMain.swift ---------------------------------------------------===// +// +//Copyright (c) 2016 Daniel Leping (dileping) +// +//This file is part of PathToRegex. +// +//PathToRegex is free software: you can redistribute it and/or modify +//it under the terms of the GNU Lesser General Public License as published by +//the Free Software Foundation, either version 3 of the License, or +//(at your option) any later version. +// +//PathToRegex is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public License +//along with PathToRegex. If not, see . +// +//===----------------------------------------------------------------------===// + +import XCTest + +@testable import PathToRegextest + +XCTMain([ + PathToRegexTests(), +]) diff --git a/PathToRegexTests/Info.plist b/Tests/PathToRegex/Info.plist similarity index 100% rename from PathToRegexTests/Info.plist rename to Tests/PathToRegex/Info.plist diff --git a/PathToRegexTests/PathToRegexTests.swift b/Tests/PathToRegex/PathToRegexTests.swift similarity index 81% rename from PathToRegexTests/PathToRegexTests.swift rename to Tests/PathToRegex/PathToRegexTests.swift index 36b650a..d9c3272 100644 --- a/PathToRegexTests/PathToRegexTests.swift +++ b/Tests/PathToRegex/PathToRegexTests.swift @@ -24,17 +24,7 @@ import Regex @testable import PathToRegex class PathToRegexTests: XCTestCase { - - override func setUp() { - super.setUp() - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDown() { - // Put teardown code here. This method is called after the invocation of each test method in the class. - super.tearDown() - } - + func testPaths() { let digitOptionalVar = try! pathToRegex("/:test(\\d+)?") XCTAssert("/123" =~ digitOptionalVar) @@ -67,13 +57,15 @@ class PathToRegexTests: XCTestCase { let methodFormat = try! pathToRegex("/api/user/:id.:format") XCTAssertEqual("123", methodFormat.findFirst("/api/user/123.json")!.group("id")!) XCTAssertEqual("json", methodFormat.findFirst("/api/user/123.json")!.group("format")!) + } +} + +#if os(Linux) +extension PathToRegexTests : XCTestCaseProvider { + var allTests : [(String, () throws -> Void)] { + return [ + ("testPaths", testPaths) + ] } - - func testPerformanceExample() { - // This is an example of a performance test case. - self.measureBlock { - // Put the code you want to measure the time of here. - } - } - } +#endif