Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #10 from ArtSabintsev/improvement/regex
Browse files Browse the repository at this point in the history
Regex Improvements
  • Loading branch information
ArtSabintsev authored Mar 10, 2017
2 parents 384123d + b460497 commit ec0ce79
Show file tree
Hide file tree
Showing 26 changed files with 585 additions and 636 deletions.
6 changes: 3 additions & 3 deletions Guitar.podspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Pod::Spec.new do |s|
s.name = 'Guitar'
s.version = '0.0.8'
s.summary = 'A Cross-Platform String Library Written in Swift.'
s.version = '0.0.9'
s.summary = 'A Cross-Platform String and Regular Expression Library Written in Swift.'

description = <<-DESC
A Cross-Platform String Library Written in Swift.
A Cross-Platform String and Regular Expression Library Written in Swift.
DESC

s.ios.deployment_target = '9.0'
Expand Down
20 changes: 8 additions & 12 deletions GuitarExample/GuitarExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
55A36A171E71228300DC6BBF /* GuitarCharacter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55A36A121E71228300DC6BBF /* GuitarCharacter.swift */; };
55A36A181E71228300DC6BBF /* GuitarPadding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55A36A131E71228300DC6BBF /* GuitarPadding.swift */; };
55A36A191E71228300DC6BBF /* GuitarTrimming.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55A36A141E71228300DC6BBF /* GuitarTrimming.swift */; };
55A36A1B1E7124E100DC6BBF /* GuitarRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55A36A1A1E7124E100DC6BBF /* GuitarRegex.swift */; };
55A36A1D1E712B1300DC6BBF /* GuitarRegexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55A36A1C1E712B1300DC6BBF /* GuitarRegexTests.swift */; };
55A36A1B1E7124E100DC6BBF /* Guitar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55A36A1A1E7124E100DC6BBF /* Guitar.swift */; };
55A36A1D1E712B1300DC6BBF /* GuitarTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55A36A1C1E712B1300DC6BBF /* GuitarTests.swift */; };
55DA075A1E66AF2200080633 /* GuitarBooleanTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55DA07591E66AF2200080633 /* GuitarBooleanTests.swift */; };
55EC366B1E6BBDAC00726F13 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55EC36631E6BBDAC00726F13 /* AppDelegate.swift */; };
55EC366C1E6BBDAC00726F13 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 55EC36641E6BBDAC00726F13 /* Assets.xcassets */; };
Expand All @@ -27,7 +27,6 @@
55EC367A1E6BBDD500726F13 /* Guitar.h in Headers */ = {isa = PBXBuildFile; fileRef = 55EC36781E6BBDD400726F13 /* Guitar.h */; settings = {ATTRIBUTES = (Public, ); }; };
55EC367D1E6BBDD500726F13 /* Guitar.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55EC36761E6BBDD400726F13 /* Guitar.framework */; };
55EC367F1E6BBDD500726F13 /* Guitar.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 55EC36761E6BBDD400726F13 /* Guitar.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
55EC36841E6BBDDD00726F13 /* Guitar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55EC36831E6BBDDD00726F13 /* Guitar.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -81,8 +80,8 @@
55A36A121E71228300DC6BBF /* GuitarCharacter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GuitarCharacter.swift; path = ../../Sources/GuitarCharacter.swift; sourceTree = "<group>"; };
55A36A131E71228300DC6BBF /* GuitarPadding.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GuitarPadding.swift; path = ../../Sources/GuitarPadding.swift; sourceTree = "<group>"; };
55A36A141E71228300DC6BBF /* GuitarTrimming.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GuitarTrimming.swift; path = ../../Sources/GuitarTrimming.swift; sourceTree = "<group>"; };
55A36A1A1E7124E100DC6BBF /* GuitarRegex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GuitarRegex.swift; path = ../../Sources/GuitarRegex.swift; sourceTree = "<group>"; };
55A36A1C1E712B1300DC6BBF /* GuitarRegexTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GuitarRegexTests.swift; sourceTree = "<group>"; };
55A36A1A1E7124E100DC6BBF /* Guitar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Guitar.swift; path = ../../Sources/Guitar.swift; sourceTree = "<group>"; };
55A36A1C1E712B1300DC6BBF /* GuitarTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GuitarTests.swift; sourceTree = "<group>"; };
55DA07571E66AF2200080633 /* GuitarExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GuitarExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
55DA07591E66AF2200080633 /* GuitarBooleanTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuitarBooleanTests.swift; sourceTree = "<group>"; };
55DA075B1E66AF2200080633 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand All @@ -95,7 +94,6 @@
55EC36761E6BBDD400726F13 /* Guitar.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Guitar.framework; sourceTree = BUILT_PRODUCTS_DIR; };
55EC36781E6BBDD400726F13 /* Guitar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Guitar.h; sourceTree = "<group>"; };
55EC36791E6BBDD400726F13 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
55EC36831E6BBDDD00726F13 /* Guitar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Guitar.swift; path = ../../Sources/Guitar.swift; sourceTree = "<group>"; };
8EDB77C11E0A516B00B13A61 /* GuitarExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GuitarExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -128,11 +126,11 @@
55DA07581E66AF2200080633 /* GuitarExampleTests */ = {
isa = PBXGroup;
children = (
55A36A1C1E712B1300DC6BBF /* GuitarTests.swift */,
55DA07591E66AF2200080633 /* GuitarBooleanTests.swift */,
554046B21E67BDAB009B317A /* GuitarCaseTests.swift */,
554046B61E67D925009B317A /* GuitarCharacterTests.swift */,
554046B81E67E6F2009B317A /* GuitarPaddingTests.swift */,
55A36A1C1E712B1300DC6BBF /* GuitarRegexTests.swift */,
554046BA1E67FC78009B317A /* GuitarTrimmingTests.swift */,
55DA075B1E66AF2200080633 /* Info.plist */,
);
Expand All @@ -155,12 +153,11 @@
55EC36771E6BBDD400726F13 /* Guitar */ = {
isa = PBXGroup;
children = (
55EC36831E6BBDDD00726F13 /* Guitar.swift */,
55A36A1A1E7124E100DC6BBF /* Guitar.swift */,
55A36A101E71228300DC6BBF /* GuitarBoolean.swift */,
55A36A111E71228300DC6BBF /* GuitarCase.swift */,
55A36A121E71228300DC6BBF /* GuitarCharacter.swift */,
55A36A131E71228300DC6BBF /* GuitarPadding.swift */,
55A36A1A1E7124E100DC6BBF /* GuitarRegex.swift */,
55A36A141E71228300DC6BBF /* GuitarTrimming.swift */,
55EC36781E6BBDD400726F13 /* Guitar.h */,
55EC36791E6BBDD400726F13 /* Info.plist */,
Expand Down Expand Up @@ -362,7 +359,7 @@
554046B71E67D925009B317A /* GuitarCharacterTests.swift in Sources */,
554046B31E67BDAB009B317A /* GuitarCaseTests.swift in Sources */,
554046B91E67E6F2009B317A /* GuitarPaddingTests.swift in Sources */,
55A36A1D1E712B1300DC6BBF /* GuitarRegexTests.swift in Sources */,
55A36A1D1E712B1300DC6BBF /* GuitarTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -372,8 +369,7 @@
files = (
55A36A151E71228300DC6BBF /* GuitarBoolean.swift in Sources */,
55A36A161E71228300DC6BBF /* GuitarCase.swift in Sources */,
55EC36841E6BBDDD00726F13 /* Guitar.swift in Sources */,
55A36A1B1E7124E100DC6BBF /* GuitarRegex.swift in Sources */,
55A36A1B1E7124E100DC6BBF /* Guitar.swift in Sources */,
55A36A191E71228300DC6BBF /* GuitarTrimming.swift in Sources */,
55A36A181E71228300DC6BBF /* GuitarPadding.swift in Sources */,
55A36A171E71228300DC6BBF /* GuitarCharacter.swift in Sources */,
Expand Down
38 changes: 0 additions & 38 deletions GuitarExample/GuitarExampleTests/GuitarRegexTests.swift

This file was deleted.

37 changes: 37 additions & 0 deletions GuitarExample/GuitarExampleTests/GuitarTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// GuitarTests.swift
// GuitarExample
//
// Created by Sabintsev, Arthur on 3/9/17.
// Copyright © 2017 Arthur Ariel Sabintsev. All rights reserved.
//

import XCTest
@testable import Guitar

class GuitarTests: XCTestCase {

func testEmailMatching() {
XCTAssertEqual(Guitar(chord: Guitar.Chord.email).evaluate(string: "This is one email address: [email protected]. This is another [[email protected]].").count, 2)
}

func testAlphanumericMatching() {
let string = "Hello World, and Hello Guitar Users! ^_^"
let newString = Guitar(chord: Guitar.Chord.nonAlphanumeric).replaceOccurences(in: string, with: "*")
XCTAssertEqual(newString, "Hello World* and Hello Guitar Users* ***")
}

func testIsValidEmail() {
XCTAssertTrue(Guitar.isValidEmail(email: "[email protected]"))
XCTAssertTrue(Guitar.isValidEmail(email: "[email protected]"))
XCTAssertFalse(Guitar.isValidEmail(email: "arthur.sabintsev@example"))
XCTAssertFalse(Guitar.isValidEmail(email: "[email protected]"))
}

func testSanitize() {
let string = "Hello, World! This is Arthur. My email is [email protected]! Who misses Obj-C []?"
let newString = Guitar.sanitze(string: string)
XCTAssertEqual(newString, "Hello World This is Arthur My email is arthur sabintsev com Who misses Obj C ")
}

}
Loading

0 comments on commit ec0ce79

Please sign in to comment.