Skip to content

Commit

Permalink
Merge pull request #11 from Oni-zerone/feature/Promise-wrapper
Browse files Browse the repository at this point in the history
Feature/promise wrapper
  • Loading branch information
Oni-zerone committed Mar 4, 2019
2 parents 98cd852 + b7f1da5 commit 9745ba7
Show file tree
Hide file tree
Showing 21 changed files with 935 additions and 233 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -34,5 +34,5 @@ Carthage/Build
# Note: if you ignore the Pods directory, make sure to uncomment
# `pod install` in .travis.yml
#
# Pods/
Pods/
IDEWorkspaceChecks.plist
1 change: 1 addition & 0 deletions Example/Podfile
Expand Up @@ -2,6 +2,7 @@ use_frameworks!

target 'PunkAPI_Example' do
pod 'PunkAPI', :path => '../'
pod 'PunkAPI/PromiseKit', :path => '../'

target 'PunkAPI_Tests' do
inherit! :search_paths
Expand Down
26 changes: 23 additions & 3 deletions Example/Podfile.lock
@@ -1,16 +1,36 @@
PODS:
- PunkAPI (0.1.0)
- PromiseKit (6.8.3):
- PromiseKit/CorePromise (= 6.8.3)
- PromiseKit/Foundation (= 6.8.3)
- PromiseKit/UIKit (= 6.8.3)
- PromiseKit/CorePromise (6.8.3)
- PromiseKit/Foundation (6.8.3):
- PromiseKit/CorePromise
- PromiseKit/UIKit (6.8.3):
- PromiseKit/CorePromise
- PunkAPI (0.1.0):
- PunkAPI/API (= 0.1.0)
- PunkAPI/API (0.1.0)
- PunkAPI/PromiseKit (0.1.0):
- PromiseKit (~> 6.7)
- PunkAPI/API

DEPENDENCIES:
- PunkAPI (from `../`)
- PunkAPI/PromiseKit (from `../`)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- PromiseKit

EXTERNAL SOURCES:
PunkAPI:
:path: "../"

SPEC CHECKSUMS:
PunkAPI: c9891a38a2efa7a052f02d02decceb58ca87b5ed
PromiseKit: 94c6e781838c5bf4717677d0d882b0e7250c80fc
PunkAPI: d1f879329a85f6a16bdfd8c478c9da163df49b59

PODFILE CHECKSUM: 77a7edfbda92bc42f026175f2a4105df175a2c99
PODFILE CHECKSUM: d9ed4e87e5248c7d10fc446b945660d3abddaee1

COCOAPODS: 1.5.3
20 changes: 19 additions & 1 deletion Example/Pods/Local Podspecs/PunkAPI.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 23 additions & 3 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

855 changes: 642 additions & 213 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Example/Pods/Target Support Files/PunkAPI/PunkAPI.xcconfig

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Example/PunkAPI.xcodeproj/project.pbxproj
Expand Up @@ -15,6 +15,7 @@
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
9761024E222B328F00C3BD6B /* BeersRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9761024D222B328F00C3BD6B /* BeersRequestTests.swift */; };
97610250222C431300C3BD6B /* PunkAPIInterfaceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9761024F222C431300C3BD6B /* PunkAPIInterfaceTests.swift */; };
9761025C222DD5BB00C3BD6B /* PunkAPIPromiseInterfaceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9761025B222DD5BB00C3BD6B /* PunkAPIPromiseInterfaceTests.swift */; };
9767CBF7221993F900E684C4 /* BeerParsingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9767CBF6221993F800E684C4 /* BeerParsingTests.swift */; };
9767CBFA2219958F00E684C4 /* BeerStubs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9767CBF82219958800E684C4 /* BeerStubs.swift */; };
9767CC092222B63700E684C4 /* URLBuildTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9767CC072222B60F00E684C4 /* URLBuildTests.swift */; };
Expand Down Expand Up @@ -52,6 +53,7 @@
613B14F018C28CF1557EC3D5 /* Pods-PunkAPI_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PunkAPI_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PunkAPI_Tests/Pods-PunkAPI_Tests.debug.xcconfig"; sourceTree = "<group>"; };
9761024D222B328F00C3BD6B /* BeersRequestTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BeersRequestTests.swift; sourceTree = "<group>"; };
9761024F222C431300C3BD6B /* PunkAPIInterfaceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PunkAPIInterfaceTests.swift; sourceTree = "<group>"; };
9761025B222DD5BB00C3BD6B /* PunkAPIPromiseInterfaceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PunkAPIPromiseInterfaceTests.swift; sourceTree = "<group>"; };
9767CBF6221993F800E684C4 /* BeerParsingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BeerParsingTests.swift; sourceTree = "<group>"; };
9767CBF82219958800E684C4 /* BeerStubs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BeerStubs.swift; sourceTree = "<group>"; };
9767CC072222B60F00E684C4 /* URLBuildTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLBuildTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -195,6 +197,7 @@
9767CC25222B286F00E684C4 /* BeersRequestParametersTests.swift */,
9767CC0A2222BB1E00E684C4 /* MockSession.swift */,
9767CC0E2223550E00E684C4 /* ConfigurationTests.swift */,
9761025B222DD5BB00C3BD6B /* PunkAPIPromiseInterfaceTests.swift */,
);
name = Request;
sourceTree = "<group>";
Expand Down Expand Up @@ -392,12 +395,14 @@
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-PunkAPI_Example/Pods-PunkAPI_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/PromiseKit/PromiseKit.framework",
"${BUILT_PRODUCTS_DIR}/PunkAPI/PunkAPI.framework",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
);
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PromiseKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PunkAPI.framework",
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -421,6 +426,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9761025C222DD5BB00C3BD6B /* PunkAPIPromiseInterfaceTests.swift in Sources */,
9767CC0D2222BDD000E684C4 /* BeerRequestTests.swift in Sources */,
97610250222C431300C3BD6B /* PunkAPIInterfaceTests.swift in Sources */,
9767CC27222B299300E684C4 /* BeersRequestParametersTests.swift in Sources */,
Expand Down
12 changes: 11 additions & 1 deletion Example/PunkAPI/Base.lproj/Main.storyboard
Expand Up @@ -29,20 +29,30 @@
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wZl-Yl-g7E">
<rect key="frame" x="66" y="244" width="243" height="30"/>
<state key="normal" title="Button"/>
<state key="normal" title="Load Beers"/>
<connections>
<action selector="loadBeerAction:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="tT1-Ms-trY"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Tld-2V-AAW">
<rect key="frame" x="66" y="314" width="243" height="30"/>
<state key="normal" title="Random Beer"/>
<connections>
<action selector="loadRandomBeer:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="WhQ-1w-chG"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="wZl-Yl-g7E" firstAttribute="top" secondItem="bXF-hH-fze" secondAttribute="bottom" constant="50" id="21X-jS-OkY"/>
<constraint firstItem="Tld-2V-AAW" firstAttribute="top" secondItem="wZl-Yl-g7E" secondAttribute="bottom" constant="40" id="JSZ-TN-oqA"/>
<constraint firstItem="Tld-2V-AAW" firstAttribute="leading" secondItem="wZl-Yl-g7E" secondAttribute="leading" id="Oom-kL-y35"/>
<constraint firstItem="wZl-Yl-g7E" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" constant="50" id="P1g-cb-Ja9"/>
<constraint firstItem="bXF-hH-fze" firstAttribute="centerY" secondItem="kh9-bI-dsS" secondAttribute="centerY" constant="-150" id="Qba-Fg-tb6"/>
<constraint firstItem="wZl-Yl-g7E" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="cAa-3I-nKq"/>
<constraint firstAttribute="trailingMargin" secondItem="bXF-hH-fze" secondAttribute="trailing" constant="10" id="ca9-Wr-Djz"/>
<constraint firstItem="bXF-hH-fze" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" constant="10" id="qCi-lc-gUJ"/>
<constraint firstItem="Tld-2V-AAW" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="yqk-45-CK9"/>
</constraints>
</view>
<connections>
Expand Down
12 changes: 12 additions & 0 deletions Example/PunkAPI/ViewController.swift
Expand Up @@ -8,6 +8,7 @@

import UIKit
import PunkAPI
import PromiseKit

class ViewController: UIViewController {

Expand Down Expand Up @@ -46,4 +47,15 @@ class ViewController: UIViewController {
}
}
}

@IBAction func loadRandomBeer(_ sender: Any) {

let request = RandomBeerRequest()
PunkAPI().get(request)
.done { [weak self] beers in
self?.label.text = beers.first?.name
}.catch { [weak self] error in
self?.label.text = error.localizedDescription
}
}
}

0 comments on commit 9745ba7

Please sign in to comment.