調整 for pod

This commit is contained in:
yume190 2018-05-29 17:14:46 +08:00
parent 700ab3820c
commit 732f8e7f2e
10 changed files with 112 additions and 85 deletions

View File

@ -1,2 +1,2 @@
github "Alamofire/Alamofire" ~> 4.4.0
github "yume190/JSONDecodeKit" ~> 4.0.1
github "yume190/JSONDecodeKit" ~> 4.1.0

View File

@ -1,2 +1,2 @@
github "Alamofire/Alamofire" "4.7.0"
github "yume190/JSONDecodeKit" "4.0.3"
github "Alamofire/Alamofire" "4.7.2"
github "yume190/JSONDecodeKit" "4.1.0"

19
LICENSE Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2017 YumeAlamofire (yume190@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

4
Makefile Normal file
View File

@ -0,0 +1,4 @@
podUpdate:
pod trunk push YumeAlamofire.podspec
podLint:
pod lib lint YumeAlamofire.podspec

View File

@ -1,4 +1,4 @@
// swift-tools-version:4.0
// swift-tools-version:4.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
@ -13,7 +13,7 @@ let package = Package(
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "4.4.0"),
.package(url: "https://github.com/yume190/JSONDecodeKit.git", from: "4.0.1"),
.package(url: "https://github.com/yume190/JSONDecodeKit.git", from: "4.1.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.

View File

@ -1,56 +1,56 @@
////
//// Entryable+Array.swift
//// YumeAlamofire
////
//// Created by Yume on 2018/3/26.
//// Copyright © 2018 Yume. All rights reserved.
////
//
// Entryable+Array.swift
// YumeAlamofire
//import Foundation
//import JSONDecodeKit
//import Alamofire
//
// Created by Yume on 2018/3/26.
// Copyright © 2018 Yume. All rights reserved.
//extension Entryable where ResponseType: Sequence, ResponseType.Element: JSONDecodable {
// public func req(failureHandler: ((Alamofire.DefaultDataResponse) -> Void)? = nil, successHandler: (([ResponseType.Element]) -> Void)?) {
//
import Foundation
import JSONDecodeKit
import Alamofire
extension Entryable where ResponseType: Sequence, ResponseType.Element: JSONDecodable {
public func req(failureHandler: ((Alamofire.DefaultDataResponse) -> Void)? = nil, successHandler: (([ResponseType.Element]) -> Void)?) {
Self.request(entry: self, failureHandler: failureHandler, successHandler: successHandler)
}
private static func decodeAsArray<OutputType:JSONDecodable>(data:Data) throws -> [OutputType] {
return try JSON(data: data,isTraceKeypath:true).array()
}
public static func request(
entry: Self,
responseInfo: @escaping YumeAlamofire.DebugInfoFunction = YumeAlamofire.basicDebugInfo,
failureHandler: ((Alamofire.DefaultDataResponse) -> Void)? = nil,
successHandler: (([ResponseType.Element]) -> Void)?) {
request(
dataRequeset: entry.dataRequest,
responseInfo: responseInfo,
failureHandler: failureHandler,
successHandler: successHandler
)
}
public static func request<OutputType:JSONDecodable>(
dataRequeset:Alamofire.DataRequest,
responseInfo:@escaping YumeAlamofire.DebugInfoFunction = YumeAlamofire.basicDebugInfo,
failureHandler: ((Alamofire.DefaultDataResponse) -> Void)? = nil,
successHandler: (([OutputType]) -> Void)?) {
dataRequeset.response {
res in
guard let target = guardData(res: res) else {
failureHandler?(res)
return
}
do {
try successHandler?(decodeAsArray(data: target.data))
} catch {
failureHandler?(res)
YumeAlamofire.parseErrorHandle(type: OutputType.self, url: res.request?.url, error: error)
}
}
}
}
// Self.request(entry: self, failureHandler: failureHandler, successHandler: successHandler)
// }
//
// private static func decodeAsArray<OutputType:JSONDecodable>(data:Data) throws -> [OutputType] {
// return try JSON(data: data,isTraceKeypath:true).array()
// }
//
// public static func request(
// entry: Self,
// responseInfo: @escaping YumeAlamofire.DebugInfoFunction = YumeAlamofire.basicDebugInfo,
// failureHandler: ((Alamofire.DefaultDataResponse) -> Void)? = nil,
// successHandler: (([ResponseType.Element]) -> Void)?) {
//
// request(
// dataRequeset: entry.dataRequest,
// responseInfo: responseInfo,
// failureHandler: failureHandler,
// successHandler: successHandler
// )
// }
//
// public static func request<OutputType:JSONDecodable>(
// dataRequeset:Alamofire.DataRequest,
// responseInfo:@escaping YumeAlamofire.DebugInfoFunction = YumeAlamofire.basicDebugInfo,
// failureHandler: ((Alamofire.DefaultDataResponse) -> Void)? = nil,
// successHandler: (([OutputType]) -> Void)?) {
// dataRequeset.response {
// res in
// guard let target = guardData(res: res) else {
// failureHandler?(res)
// return
// }
// do {
// try successHandler?(decodeAsArray(data: target.data))
// } catch {
// failureHandler?(res)
// YumeAlamofire.parseErrorHandle(type: OutputType.self, url: res.request?.url, error: error)
// }
// }
// }
//}

View File

@ -1,21 +0,0 @@
//
// JSONArray.swift
// YumeAlamofire
//
// Created by Yume on 2018/1/5.
// Copyright © 2018 Yume. All rights reserved.
//
import Foundation
import JSONDecodeKit
// TODO: wait https://github.com/apple/swift-evolution/blob/master/proposals/0143-conditional-conformances.md implement
//https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Generics.html#//apple_ref/doc/uid/TP40014097-CH26-ID192
//protocol ComparableContainer: Container where Item: Comparable { }
//public protocol MutableCollection : Collection where Self.SubSequence : Collection {
//
// associatedtype SubSequence : Collection = MutableSlice<Self>

22
YumeAlamofire.podspec Normal file
View File

@ -0,0 +1,22 @@
Pod::Spec.new do |s|
s.name = 'YumeAlamofire'
s.version = '4.0.6'
s.license = 'MIT'
s.summary = "A Library combine network request and json decode in POP way"
s.homepage = 'https://github.com/yume190/YumeAlamofire'
s.authors = { 'yume190' => 'yume190@gmail.com' }
s.social_media_url = "https://www.facebook.com/yume190"
s.source = { :git => 'https://github.com/yume190/YumeAlamofire.git', :tag => s.version }
s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.10'
# s.tvos.deployment_target = '9.0'
# s.watchos.deployment_target = '2.0'
s.source_files = ['Sources/YumeAlamofire/*.swift']
s.swift_version = '4.0'
s.static_framework = true
s.dependency "Alamofire", "~> 4.7.2"
s.dependency "JSONDecodeKit", "~> 4.1.0"
end

View File

@ -15,7 +15,6 @@
A8051ED42007194E0010EEE7 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A8F40FF91FF38558000F01E5 /* Alamofire.framework */; };
A8051ED52007194E0010EEE7 /* JSONDecodeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A8F40FF81FF38558000F01E5 /* JSONDecodeKit.framework */; };
A8051ED72007334E0010EEE7 /* Latch.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8051ED62007334E0010EEE7 /* Latch.swift */; };
A8281FAB20737CA800725A91 /* JSONArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8281FA520737CA800725A91 /* JSONArray.swift */; };
A8281FAC20737CA800725A91 /* Entryable+Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8281FA620737CA800725A91 /* Entryable+Codable.swift */; };
A8281FAD20737CA800725A91 /* Entryable+Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8281FA720737CA800725A91 /* Entryable+Array.swift */; };
A8281FAE20737CA800725A91 /* Entryable.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8281FA820737CA800725A91 /* Entryable.swift */; };
@ -24,6 +23,7 @@
A8F40FE81FF3809B000F01E5 /* YumeAlamofire.h in Headers */ = {isa = PBXBuildFile; fileRef = A8F40FE61FF3809B000F01E5 /* YumeAlamofire.h */; settings = {ATTRIBUTES = (Public, ); }; };
A8F40FFA1FF38558000F01E5 /* JSONDecodeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A8F40FF81FF38558000F01E5 /* JSONDecodeKit.framework */; };
A8F40FFB1FF38558000F01E5 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A8F40FF91FF38558000F01E5 /* Alamofire.framework */; };
A8F4886B207B79BB00E1DA7E /* Sample+Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = A862203A206E2DBC00BC55F6 /* Sample+Array.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -56,7 +56,6 @@
A8051EC8200718520010EEE7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A8051ECF200718650010EEE7 /* Sample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sample.swift; sourceTree = "<group>"; };
A8051ED62007334E0010EEE7 /* Latch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Latch.swift; sourceTree = "<group>"; };
A8281FA520737CA800725A91 /* JSONArray.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = JSONArray.swift; path = Sources/YumeAlamofire/JSONArray.swift; sourceTree = SOURCE_ROOT; };
A8281FA620737CA800725A91 /* Entryable+Codable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Entryable+Codable.swift"; path = "Sources/YumeAlamofire/Entryable+Codable.swift"; sourceTree = SOURCE_ROOT; };
A8281FA720737CA800725A91 /* Entryable+Array.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Entryable+Array.swift"; path = "Sources/YumeAlamofire/Entryable+Array.swift"; sourceTree = SOURCE_ROOT; };
A8281FA820737CA800725A91 /* Entryable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Entryable.swift; path = Sources/YumeAlamofire/Entryable.swift; sourceTree = SOURCE_ROOT; };
@ -113,7 +112,6 @@
A8281FA720737CA800725A91 /* Entryable+Array.swift */,
A8281FA620737CA800725A91 /* Entryable+Codable.swift */,
A8281FA920737CA800725A91 /* Entryable+Single.swift */,
A8281FA520737CA800725A91 /* JSONArray.swift */,
A8281FAA20737CA800725A91 /* YumeAlamofire.swift */,
);
name = Lib;
@ -304,9 +302,9 @@
buildActionMask = 2147483647;
files = (
A8281FAE20737CA800725A91 /* Entryable.swift in Sources */,
A8F4886B207B79BB00E1DA7E /* Sample+Array.swift in Sources */,
A8281FAD20737CA800725A91 /* Entryable+Array.swift in Sources */,
A8281FAF20737CA800725A91 /* Entryable+Single.swift in Sources */,
A8281FAB20737CA800725A91 /* JSONArray.swift in Sources */,
A8281FB020737CA800725A91 /* YumeAlamofire.swift in Sources */,
A8281FAC20737CA800725A91 /* Entryable+Codable.swift in Sources */,
);

View File

@ -10,14 +10,15 @@ import Foundation
import Alamofire
import JSONDecodeKit
struct Entry {}
extension Entry {
struct BaseDatas3: Entryable {
typealias ResponseType = [Response]
let key: String
let base: String = ""
var path: String { return "/basedatas/\(key)" }
let base: String = "http://localhost:3000"
var path: String { return "/yume)" }
let sessionManager: Alamofire.SessionManager = Alamofire.SessionManager.default
let method: Alamofire.HTTPMethod = .get
let parameters: Parameters = [:]
@ -38,3 +39,7 @@ extension Entry.BaseDatas3.Response: JSONDecodable {
return try Entry.BaseDatas3.Response(code: json <| "code", message: json <| "message")
}
}
//func abc() {
// Entry.BaseDatas3(key: "").req(successHandler: <#T##(([Entry.BaseDatas3.Response]) -> Void)?##(([Entry.BaseDatas3.Response]) -> Void)?##([Entry.BaseDatas3.Response]) -> Void#>)
//}