Skip to content

Commit

Permalink
make properties public, documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
xremix committed Jun 26, 2017
1 parent d052f0d commit 3a67b68
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 11 deletions.
47 changes: 44 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,49 @@
# SwiftGS1Barcode
A GS1 Barcode Library and Parser for Swift Edit
A GS1 Barcode Library and Parser written in Swift

[![Language](https://img.shields.io/badge/language-swift%203-1b7cb9.svg)](https://img.shields.io/badge/language-swift%203-1b7cb9.svg)
[![iOS](https://img.shields.io/badge/iOS-9.0%2B-1b7cb9.svg)](https://img.shields.io/badge/iOS-9.0%2B-1b7cb9.svg)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/xremix/SwiftGS1Barcode/master/LICENSE)

## Usage
Parsing is as simple as
```
let gs1Barcode = "01101234670417283002\u{1D}1721103110S123456"
let barcode = GS1Barcode(raw: gs1Barcode)
print(barcode.gtin)
print(barcode.amount)
print(barcode.expirationDate)
print(barcode.lotNumber)
```

### Available Properties
Currently only the following properties are available and do get parsed

- `GTIN`
- `lotNumber`
- `expirationDate`
- `serialNumber`
- `amount`

Other properties can be extended pretty easily. *You* can contribute yourself, or open an [issue](https://github.com/xremix/SwiftGS1Barcode/issues/new).


## Installation
### CocoaPods
You can install the library to you project using [CocoaPods](https://cocoapods.org). Add the following code to your `Podfile`:
```
pod 'SwiftGS1Barcode'
```
Alternative you can also add the direct Github URL:
```
pod 'SwiftGS1Barcode', :git => 'https://github.com/xremix/SwiftGS1Barcode', :branch => 'master'
```

### Manually
You can add the project as a git `submodule`. Simply drag the `SwiftGS1Barcode.xcodeproj` file into your Xcode project.
* Don't forget to add the framework in your application target *

## CocoaPod
https://github.com/xremix/SwiftGS1Barcode

## Deployment Steps
- Run Unit Tests
Expand Down
2 changes: 1 addition & 1 deletion SwiftGS1Barcode.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'SwiftGS1Barcode'
s.version = '0.1.2'
s.version = '0.1.3'
s.summary = 'A GS1 Barcode Library and Parser for Swift'

s.description = <<-DESC
Expand Down
17 changes: 11 additions & 6 deletions SwiftGS1Barcode/GS1Barcode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ struct GS1Nodes{
}

public class GS1Barcode: NSObject, Barcode {
var raw: String?
public var raw: String?
var nodes = GS1Nodes()

var gtin: String?{ get {return nodes.gtinNode.value} }
var lotNumber: String?{ get {return nodes.lotNumberNode.value} }
var expirationDate: NSDate?{ get {return nodes.expirationDateNode.dateValue} }
var serialNumber: String?{ get {return nodes.serialNumberNode.value} }
var amount: Int?{ get {return nodes.amountNode.intValue} }
public var gtin: String?{ get {return nodes.gtinNode.value} }
public var lotNumber: String?{ get {return nodes.lotNumberNode.value} }
public var expirationDate: NSDate?{ get {return nodes.expirationDateNode.dateValue} }
public var serialNumber: String?{ get {return nodes.serialNumberNode.value} }
public var amount: Int?{ get {return nodes.amountNode.intValue} }

required override public init() {
super.init()
Expand All @@ -64,6 +64,11 @@ public class GS1Barcode: NSObject, Barcode {
self.raw = raw
_ = parse()
}

// TODO implement validateGS1QuantityRule?
// TODO implement hasQuantityTag?
// TODO implement isLot

func validate() -> Bool {
return gtin != nil
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftGS1Barcode/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.1.2</string>
<string>0.1.3</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down

0 comments on commit 3a67b68

Please sign in to comment.