Skip to content

Commit

Permalink
Merge pull request #91 from marcelofabri/bye-argo
Browse files Browse the repository at this point in the history
Removing Argo
  • Loading branch information
hffmnn committed Aug 12, 2016
2 parents 83f7db6 + 4ab6083 commit b76e6bc
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 91 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "Carthage/Checkouts/Argo"]
path = Carthage/Checkouts/Argo
url = https://github.com/thoughtbot/Argo.git
[submodule "Carthage/Checkouts/Nimble"]
path = Carthage/Checkouts/Nimble
url = https://github.com/Quick/Nimble.git
Expand Down
1 change: 0 additions & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Core
github "antitypical/Result" ~> 2.0
github "thoughtbot/Argo" ~> 3.0

# ReactiveCocoa
github "ReactiveCocoa/ReactiveCocoa" ~> 4.0
7 changes: 3 additions & 4 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
github "thoughtbot/Argo" "v3.0.1"
github "Quick/Nimble" "v4.0.1"
github "Quick/Nimble" "v4.1.0"
github "AliSoftware/OHHTTPStubs" "4.8.0"
github "Quick/Quick" "v0.9.2"
github "antitypical/Result" "2.0.0"
github "antitypical/Result" "2.1.3"
github "jspahrsummers/xcconfigs" "0.9"
github "ReactiveCocoa/ReactiveCocoa" "v4.1.0"
github "ReactiveCocoa/ReactiveCocoa" "v4.2.2"
1 change: 0 additions & 1 deletion Carthage/Checkouts/Argo
Submodule Argo deleted from be127e
2 changes: 1 addition & 1 deletion Carthage/Checkouts/ReactiveCocoa
Submodule ReactiveCocoa updated 77 files
+1 −1 .gitmodules
+65 −1 .travis.yml
+3 −3 CHANGELOG.md
+2 −3 CONTRIBUTING.md
+1 −1 Cartfile
+3 −3 Cartfile.private
+4 −4 Cartfile.resolved
+1 −1 Carthage/Checkouts/Nimble
+1 −1 Carthage/Checkouts/Quick
+1 −1 Carthage/Checkouts/Result
+1 −1 Carthage/Checkouts/xcconfigs
+5 −4 Documentation/BasicOperators.md
+92 −3 Documentation/DebuggingTechniques.md
+4 −4 Documentation/DesignGuidelines.md
+131 −0 Documentation/DocumentingCode.md
+1 −1 Documentation/FrameworkOverview.md
+46 −8 README.md
+25 −0 ReactiveCocoa.playground/Pages/Sandbox.xcplaygroundpage/Contents.swift
+241 −0 ReactiveCocoa.playground/Pages/Signal.xcplaygroundpage/Contents.swift
+796 −0 ReactiveCocoa.playground/Pages/SignalProducer.xcplaygroundpage/Contents.swift
+10 −0 ReactiveCocoa.playground/Sources/PlaygroundUtility.swift
+8 −0 ReactiveCocoa.playground/contents.xcplayground
+365 −59 ReactiveCocoa.xcodeproj/project.pbxproj
+65 −3 ReactiveCocoa.xcodeproj/xcshareddata/xcschemes/ReactiveCocoa-tvOS.xcscheme
+3 −0 ReactiveCocoa.xcworkspace/contents.xcworkspacedata
+2 −2 ReactiveCocoa/Objective-C/NSControl+RACCommandSupport.h
+1 −1 ReactiveCocoa/Objective-C/NSObject+RACDescription.h
+1 −1 ReactiveCocoa/Objective-C/NSObject+RACDescription.m
+1 −2 ReactiveCocoa/Objective-C/NSObject+RACSelectorSignal.m
+4 −4 ReactiveCocoa/Objective-C/RACCommand.h
+28 −15 ReactiveCocoa/Objective-C/RACCompoundDisposable.m
+0 −17 ReactiveCocoa/Objective-C/RACObjCRuntime.h
+0 −22 ReactiveCocoa/Objective-C/RACObjCRuntime.m
+2 −1 ReactiveCocoa/Objective-C/RACSequence.h
+5 −1 ReactiveCocoa/Objective-C/RACSequence.m
+34 −20 ReactiveCocoa/Objective-C/RACSerialDisposable.m
+12 −21 ReactiveCocoa/Objective-C/RACSignal.m
+0 −1 ReactiveCocoa/Objective-C/RACStream.m
+4 −2 ReactiveCocoa/Objective-C/RACSubject.m
+2 −2 ReactiveCocoa/Objective-C/UIBarButtonItem+RACCommandSupport.h
+2 −2 ReactiveCocoa/Objective-C/UIButton+RACCommandSupport.h
+5 −2 ReactiveCocoa/Objective-C/UIControl+RACSignalSupport.m
+2 −2 ReactiveCocoa/Objective-C/UIRefreshControl+RACCommandSupport.h
+2 −1 ReactiveCocoa/ReactiveCocoa.h
+53 −86 ReactiveCocoa/Swift/Action.swift
+37 −18 ReactiveCocoa/Swift/Atomic.swift
+13 −7 ReactiveCocoa/Swift/Bag.swift
+102 −0 ReactiveCocoa/Swift/CocoaAction.swift
+91 −28 ReactiveCocoa/Swift/Disposable.swift
+91 −0 ReactiveCocoa/Swift/DynamicProperty.swift
+27 −7 ReactiveCocoa/Swift/Event.swift
+122 −0 ReactiveCocoa/Swift/EventLogger.swift
+465 −65 ReactiveCocoa/Swift/Flatten.swift
+37 −8 ReactiveCocoa/Swift/FoundationExtensions.swift
+115 −39 ReactiveCocoa/Swift/ObjectiveCBridging.swift
+48 −6 ReactiveCocoa/Swift/Observer.swift
+177 −109 ReactiveCocoa/Swift/Property.swift
+182 −53 ReactiveCocoa/Swift/Scheduler.swift
+808 −261 ReactiveCocoa/Swift/Signal.swift
+1,013 −301 ReactiveCocoa/Swift/SignalProducer.swift
+4 −4 ReactiveCocoaTests/Objective-C/RACCommandSpec.m
+13 −0 ReactiveCocoaTests/Objective-C/RACSignalSpec.m
+34 −2 ReactiveCocoaTests/Objective-C/RACSubjectSpec.m
+5 −61 ReactiveCocoaTests/Swift/ActionSpec.swift
+85 −0 ReactiveCocoaTests/Swift/CocoaActionSpec.swift
+864 −0 ReactiveCocoaTests/Swift/FlattenSpec.swift
+16 −1 ReactiveCocoaTests/Swift/FoundationExtensionsSpec.swift
+107 −12 ReactiveCocoaTests/Swift/PropertySpec.swift
+5 −3 ReactiveCocoaTests/Swift/SchedulerSpec.swift
+3 −3 ReactiveCocoaTests/Swift/SignalLifetimeSpec.swift
+270 −75 ReactiveCocoaTests/Swift/SignalProducerLiftingSpec.swift
+234 −70 ReactiveCocoaTests/Swift/SignalProducerSpec.swift
+423 −77 ReactiveCocoaTests/Swift/SignalSpec.swift
+27 −0 ReactiveCocoaTests/Swift/TestError.swift
+25 −0 ReactiveCocoaTests/Swift/TestLogger.swift
+52 −0 script/build
+23 −0 script/validate-playground.sh
1 change: 0 additions & 1 deletion Heimdallr.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Pod::Spec.new do |spec|
spec.default_subspec = 'Core'

spec.subspec 'Core' do |subspec|
subspec.dependency 'Argo', '~> 3.0'
subspec.dependency 'Result', '~> 2.0'
subspec.framework = 'Foundation'

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

/* Begin PBXBuildFile section */
DC209CCD1C845F9500C43C75 /* Argo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC209CC51C845F1900C43C75 /* Argo.framework */; };
DC209CCE1C845F9600C43C75 /* Argo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC209CC51C845F1900C43C75 /* Argo.framework */; };
DC209CCF1C845F9700C43C75 /* Argo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC209CC51C845F1900C43C75 /* Argo.framework */; };
DC209CD01C845F9800C43C75 /* Argo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC209CC51C845F1900C43C75 /* Argo.framework */; };
DC209CD31C845FA100C43C75 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC209CCB1C845F1900C43C75 /* Result.framework */; };
DC209CD61C845FA300C43C75 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC209CCB1C845F1900C43C75 /* Result.framework */; };
DC209CD81C845FA400C43C75 /* ReactiveCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC209CCA1C845F1900C43C75 /* ReactiveCocoa.framework */; };
Expand Down Expand Up @@ -244,7 +240,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
DC209CCD1C845F9500C43C75 /* Argo.framework in Frameworks */,
DC209CD31C845FA100C43C75 /* Result.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -264,7 +259,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
DC209CCE1C845F9600C43C75 /* Argo.framework in Frameworks */,
DC209CD61C845FA300C43C75 /* Result.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -284,7 +278,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
DC209CCF1C845F9700C43C75 /* Argo.framework in Frameworks */,
DC209CD81C845FA400C43C75 /* ReactiveCocoa.framework in Frameworks */,
DC209CD91C845FA400C43C75 /* Result.framework in Frameworks */,
);
Expand All @@ -305,7 +298,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
DC209CD01C845F9800C43C75 /* Argo.framework in Frameworks */,
DC209CDB1C845FA400C43C75 /* ReactiveCocoa.framework in Frameworks */,
DC209CDC1C845FA400C43C75 /* Result.framework in Frameworks */,
);
Expand Down
3 changes: 0 additions & 3 deletions Heimdallr.xcworkspace/contents.xcworkspacedata

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

5 changes: 2 additions & 3 deletions Heimdallr/Core/Heimdallr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,9 @@ public let HeimdallrErrorNotAuthorized = 2
completion(.Failure(error))
}
} else {
switch OAuthError.decode(data!) {
case let .Success(error):
if let data = data, error = OAuthError.decode(data: data) {
completion(.Failure(error.nsError))
default:
} else {
let userInfo = [
NSLocalizedDescriptionKey: NSLocalizedString("Could not authorize grant", comment: ""),
NSLocalizedFailureReasonErrorKey: String(format: NSLocalizedString("Expected error, got: %@.", comment: ""), NSString(data: data!, encoding: NSUTF8StringEncoding) ?? "nil")
Expand Down
45 changes: 21 additions & 24 deletions Heimdallr/Core/OAuthAccessToken.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Argo
import Result

/// An access token is used for authorizing requests to the resource endpoint.
Expand Down Expand Up @@ -56,34 +55,32 @@ public func == (lhs: OAuthAccessToken, rhs: OAuthAccessToken) -> Bool {
&& lhs.refreshToken == rhs.refreshToken
}

extension OAuthAccessToken: Decodable {
public class func create(accessToken: String) -> String -> NSDate? -> String? -> OAuthAccessToken {
return
{ tokenType in
{ expiresAt in
{ refreshToken in
OAuthAccessToken(accessToken: accessToken, tokenType: tokenType, expiresAt: expiresAt, refreshToken: refreshToken)
}
}
extension OAuthAccessToken {
public class func decode(json: [String: AnyObject]) -> OAuthAccessToken? {
func toNSDate(timeIntervalSinceNow: NSTimeInterval?) -> NSDate? {
return timeIntervalSinceNow.map { timeIntervalSinceNow in
return NSDate(timeIntervalSinceNow: timeIntervalSinceNow)
}
}
}

public class func decode(json: JSON) -> Decoded<OAuthAccessToken> {
func toNSDate(timeIntervalSinceNow: NSTimeInterval?) -> Decoded<NSDate?> {
return pure(timeIntervalSinceNow.map { timeIntervalSinceNow in
return NSDate(timeIntervalSinceNow: timeIntervalSinceNow)
} ?? .None)
guard let accessToken = json["access_token"] as? String,
tokenType = json["token_type"] as? String else {
return nil
}

return create
<^> json <| "access_token"
<*> json <| "token_type"
<*> (json <|? "expires_in").flatMap(toNSDate)
<*> json <|? "refresh_token"
let expiresAt = (json["expires_in"] as? NSTimeInterval).flatMap(toNSDate)
let refreshToken = json["refresh_token"] as? String

return OAuthAccessToken(accessToken: accessToken, tokenType: tokenType,
expiresAt: expiresAt, refreshToken: refreshToken)
}

public class func decode(data: NSData) -> Decoded<OAuthAccessToken> {
let json: AnyObject? = try? NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions(rawValue: 0))
return Decoded<AnyObject>.fromOptional(json).flatMap(Argo.decode)
public class func decode(data data: NSData) -> OAuthAccessToken? {
guard let json = try? NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions(rawValue: 0)),
jsonDictionary = json as? [String: AnyObject] else {
return nil
}

return decode(jsonDictionary)
}
}
8 changes: 2 additions & 6 deletions Heimdallr/Core/OAuthAccessTokenDefaultParser.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import Foundation
import Result
import Argo

@objc
public class OAuthAccessTokenDefaultParser: NSObject, OAuthAccessTokenParser {
public func parse(data: NSData) -> Result<OAuthAccessToken, NSError> {

let decoded = OAuthAccessToken.decode(data)

switch decoded {
case .Success(let token):
if let token = OAuthAccessToken.decode(data: data) {
return .Success(token)
case .Failure:
} else {
let error = NSError(domain: HeimdallrErrorDomain, code: HeimdallrErrorInvalidData, userInfo: nil)
return .Failure(error)
}
Expand Down
43 changes: 20 additions & 23 deletions Heimdallr/Core/OAuthError.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Argo

/// See: The OAuth 2.0 Authorization Framework, 5.2 Error Response
/// <https://tools.ietf.org/html/rfc6749#section-5.2>

Expand Down Expand Up @@ -41,10 +39,10 @@ public extension OAuthErrorCode {
}
}

extension OAuthErrorCode: Decodable {
public static func decode(json: JSON) -> Decoded<OAuthErrorCode> {
return String.decode(json).flatMap { code in
return .fromOptional(OAuthErrorCode(rawValue: code))
extension OAuthErrorCode {
public static func decode(json: AnyObject?) -> OAuthErrorCode? {
return json.flatMap { $0 as? String }.flatMap { code in
return OAuthErrorCode(rawValue: code)
}
}
}
Expand Down Expand Up @@ -77,25 +75,24 @@ public extension OAuthError {
}
}

extension OAuthError: Decodable {
public class func create(code: OAuthErrorCode) -> String? -> String? -> OAuthError {
return
{ description in
{ uri in
OAuthError(code: code, description: description, uri: uri)
}
}
}
extension OAuthError {
public class func decode(json: [String: AnyObject]) -> OAuthError? {
guard let code = json["error"].flatMap(OAuthErrorCode.decode) else {
return nil
}

public class func decode(json: JSON) -> Decoded<OAuthError> {
return create
<^> json <| "error"
<*> json <|? "error_description"
<*> json <|? "error_uri"
let description = json["error_description"] as? String
let uri = json["error_uri"] as? String

return OAuthError(code: code, description: description, uri: uri)
}

public class func decode(data: NSData) -> Decoded<OAuthError> {
let json: AnyObject? = try? NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions(rawValue: 0))
return Decoded<AnyObject>.fromOptional(json).flatMap(Argo.decode)
public class func decode(data data: NSData) -> OAuthError? {
guard let json: AnyObject? = try? NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions(rawValue: 0)),
jsonDictionary = json as? [String: AnyObject] else {
return nil
}

return decode(jsonDictionary)
}
}
21 changes: 10 additions & 11 deletions HeimdallrTests/Core/OAuthAccessTokenSpec.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Argo
import Heimdallr
import Nimble
import Quick
Expand Down Expand Up @@ -139,16 +138,16 @@ class OAuthAccessTokenSpec: QuickSpec {
describe("+decode") {
context("without an expiration date") {
it("creates a valid access token") {
let accessToken = OAuthAccessToken.decode(.Object([
"access_token": .String("accessToken"),
"token_type": .String("tokenType")
]))

expect(accessToken.value).toNot(beNil())
expect(accessToken.value?.accessToken).to(equal("accessToken"))
expect(accessToken.value?.tokenType).to(equal("tokenType"))
expect(accessToken.value?.expiresAt).to(beNil())
expect(accessToken.value?.refreshToken).to(beNil())
let accessToken = OAuthAccessToken.decode([
"access_token": "accessToken",
"token_type": "tokenType"
])

expect(accessToken).toNot(beNil())
expect(accessToken?.accessToken).to(equal("accessToken"))
expect(accessToken?.tokenType).to(equal("tokenType"))
expect(accessToken?.expiresAt).to(beNil())
expect(accessToken?.refreshToken).to(beNil())
}
}
}
Expand Down

0 comments on commit b76e6bc

Please sign in to comment.