Skip to content

Commit

Permalink
Added logger
Browse files Browse the repository at this point in the history
Added logger
Better readme
  • Loading branch information
Majd Sabah committed Oct 8, 2018
1 parent a6c94aa commit b8a39df
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 10 deletions.
32 changes: 27 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,53 @@
# SwiftyVIN 1.0
# SwiftyVIN 1.2

A Swift version of VIN validations using Swift 4.2

## Getting Started

Just after intallation

```
import SwiftyVIN
```

Create SwiftyVIN object

```
let swiftyVin: SwiftyVIN = SwiftyVIN("")
```

Then
Then validate

```
swiftyVin.isValid()
```

## Debug mode

To enable debug mode

```
SwiftyVINLogger.shared.debugMode = true
```


### Installing

A step by step series of examples that tell you how to get a development env running
Add the following inside your podfile

Say what the step will be
```
use_frameworks!
pod 'SwiftyVIN'
```

Then

```
Give the example
pod install
```

## Running the tests
Expand Down
4 changes: 2 additions & 2 deletions SwiftyVIN.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'SwiftyVIN'
s.version = '1.1'
s.version = '1.2'
s.summary = 'Swift version of VIN validation'
s.description = <<-DESC
Swift version of VIN validation using swift 4.2
Expand All @@ -21,7 +21,7 @@ Pod::Spec.new do |s|
s.author = { 'Majd Sabah' => '[email protected]' }
s.source = { :git => 'https://github.com/sbhmajd/SwiftyVIN.git', :tag => s.version.to_s }

s.ios.deployment_target = '12.0'
s.ios.deployment_target = '11.0'
s.source_files = 'SwiftyVIN/**/*.swift'

end
8 changes: 6 additions & 2 deletions SwiftyVIN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
C0781A8F216B7DEA0018ED49 /* SwiftyVINLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0781A8E216B7DEA0018ED49 /* SwiftyVINLogger.swift */; };
C0FA25FA216A341800E0733D /* SwiftyVIN.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0FA25F0216A341800E0733D /* SwiftyVIN.framework */; };
C0FA25FF216A341800E0733D /* SwiftyVINTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0FA25FE216A341800E0733D /* SwiftyVINTests.swift */; };
C0FA2601216A341800E0733D /* SwiftyVIN.h in Headers */ = {isa = PBXBuildFile; fileRef = C0FA25F3216A341800E0733D /* SwiftyVIN.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand All @@ -26,6 +27,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
C0781A8E216B7DEA0018ED49 /* SwiftyVINLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftyVINLogger.swift; sourceTree = "<group>"; };
C0FA25F0216A341800E0733D /* SwiftyVIN.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftyVIN.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C0FA25F3216A341800E0733D /* SwiftyVIN.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftyVIN.h; sourceTree = "<group>"; };
C0FA25F4216A341800E0733D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -98,6 +100,7 @@
isa = PBXGroup;
children = (
C0FA260D216A361700E0733D /* SwiftyVIN.swift */,
C0781A8E216B7DEA0018ED49 /* SwiftyVINLogger.swift */,
C0FA260B216A35A800E0733D /* VINConstants.swift */,
);
path = Source;
Expand Down Expand Up @@ -223,6 +226,7 @@
C0FA2611216A448D00E0733D /* String.swift in Sources */,
C0FA260C216A35A800E0733D /* VINConstants.swift in Sources */,
C0FA260E216A361700E0733D /* SwiftyVIN.swift in Sources */,
C0781A8F216B7DEA0018ED49 /* SwiftyVINLogger.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -380,7 +384,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = SwiftyVIN/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -408,7 +412,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = SwiftyVIN/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
22 changes: 21 additions & 1 deletion SwiftyVIN/Source/SwiftyVIN.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public struct SwiftyVIN {

private(set) var vinString: String

init(_ vinString: String) {
public init(_ vinString: String) {

self.vinString = vinString.uppercased()

Expand All @@ -33,30 +33,50 @@ public struct SwiftyVIN {

if !SwiftyVIN.validVINLength(vinString) {

if SwiftyVINLogger.shared.debugMode {
print("InvalidVINLength")
}

return false

}

if !SwiftyVIN.validVINCharacters(vinString) {

if SwiftyVINLogger.shared.debugMode {
print("InvalidVINCharacters")
}

return false

}

if !SwiftyVIN.validVINCharacter(vinString, at: VINConstants.tenthCharIndex) {

if SwiftyVINLogger.shared.debugMode {
print("InvalidVINCharacterAtTenthChar")
}

return false

}

if !SwiftyVIN.validVINCheckDigit(vinString) {

if SwiftyVINLogger.shared.debugMode {
print("InvalidVINCheckDigit")
}

return false

}

if !SwiftyVIN.validVINRepeatedCharacters(vinString) {

if SwiftyVINLogger.shared.debugMode {
print("InvalidVINRepeatedCharacters")
}

return false

}
Expand Down
19 changes: 19 additions & 0 deletions SwiftyVIN/Source/SwiftyVINLogger.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// SwiftyVINLogger.swift
// SwiftyVIN
//
// Created by Majd Sabah on 10/8/18.
// Copyright © 2018 Majd Sabah. All rights reserved.
//

import Foundation

public class SwiftyVINLogger {

/// The shared swifty VIN logger for the system.
public static let shared = SwiftyVINLogger()

/// The debug mode flag 'true' means will show log, 'false' means will show nothing.
public var debugMode: Bool = false

}
3 changes: 3 additions & 0 deletions SwiftyVINTests/SwiftyVINTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import XCTest
class SwiftyVINTests: XCTestCase {

override func setUp() {

// Put setup code here. This method is called before the invocation of each test method in the class.
SwiftyVINLogger.shared.debugMode = true

}

override func tearDown() {
Expand Down

0 comments on commit b8a39df

Please sign in to comment.