Skip to content

Commit

Permalink
[master] - Release v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Daltron committed Sep 25, 2018
1 parent 8107c10 commit 7da54bd
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 69 deletions.
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

3 changes: 2 additions & 1 deletion AlamoRecord.podspec
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = 'AlamoRecord'
s.version = '1.2.2'
s.version = '1.3.0'
s.summary = 'An elegant Alamofire wrapper inspired by ActiveRecord.'
s.description = <<-DESC
AlamoRecord is a powerful yet simple framework that eliminates the often complex networking layer that exists between your networking framework and your application. AlamoRecord uses the power of AlamoFire, AlamofireObjectMapper and the concepts behind the ActiveRecord pattern to create a networking layer that makes interacting with your API easier than ever.
Expand All @@ -11,6 +11,7 @@ AlamoRecord is a powerful yet simple framework that eliminates the often complex
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Tunespeak' => 'daltonhint4@gmail.com' }
s.source = { :git => 'https://github.com/tunespeak/AlamoRecord.git', :tag => s.version.to_s }
s.swift_version = '4.2'

s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.11'
Expand Down
24 changes: 12 additions & 12 deletions AlamoRecord/Classes/AlamoRecordObject.swift
Expand Up @@ -20,23 +20,23 @@ import Alamofire
import AlamofireObjectMapper
import ObjectMapper

open class AlamoRecordObject<U: URLProtocol, E: AlamoRecordError>: NSObject, Mappable {
open class AlamoRecordObject<U: URLProtocol, E: AlamoRecordError, IDType>: NSObject, Mappable {

/// Key to encode/decode the id variable
private let idKey: String = "id"

/// The RequestManager that is tied to all instances of this class
open class var requestManager: RequestManager<U, E> {
open class var requestManager: RequestManager<U, E, IDType> {
fatalError("requestManager must be overriden in your AlamoRecordObject subclass")
}

/// The RequestManager that is tied to this instance
open var requestManager: RequestManager<U, E> {
open var requestManager: RequestManager<U, E, IDType> {
return type(of: self).requestManager
}

/// The id of this instance. This can be a String or an Int.
open var id: Any!
/// The id of this instance. This should be a String or an Int.
open var id: IDType!

/// The root of all instances of this class. This is used when making URL's that relate to a component of this class.
// Example: '/comment/id' --> '/\(Comment.root)/id'
Expand Down Expand Up @@ -188,7 +188,7 @@ open class AlamoRecordObject<U: URLProtocol, E: AlamoRecordError>: NSObject, Map
- parameter failure: The block to execute if the request fails
*/
@discardableResult
open class func find<T: AlamoRecordObject>(id: Any,
open class func find<T: AlamoRecordObject>(id: IDType,
parameters: Parameters? = nil,
encoding: ParameterEncoding = URLEncoding.default,
headers: HTTPHeaders? = nil,
Expand Down Expand Up @@ -237,7 +237,7 @@ open class AlamoRecordObject<U: URLProtocol, E: AlamoRecordError>: NSObject, Map
- parameter failure: The block to execute if the request fails
*/
@discardableResult
open class func update<T: AlamoRecordObject>(id: Any,
open class func update<T: AlamoRecordObject>(id: IDType,
parameters: Parameters? = nil,
encoding: ParameterEncoding = URLEncoding.default,
headers: HTTPHeaders? = nil,
Expand All @@ -263,7 +263,7 @@ open class AlamoRecordObject<U: URLProtocol, E: AlamoRecordError>: NSObject, Map
- parameter failure: The block to execute if the request fails
*/
@discardableResult
open class func update(id: Any,
open class func update(id: IDType,
parameters: Parameters? = nil,
encoding: ParameterEncoding = URLEncoding.default,
headers: HTTPHeaders? = nil,
Expand Down Expand Up @@ -335,7 +335,7 @@ open class AlamoRecordObject<U: URLProtocol, E: AlamoRecordError>: NSObject, Map
- parameter failure: The block to execute if the request fails
*/
@discardableResult
open class func destroy(id: Any,
open class func destroy(id: IDType,
parameters: Parameters? = nil,
encoding: ParameterEncoding = URLEncoding.default,
headers: HTTPHeaders? = nil,
Expand Down Expand Up @@ -365,7 +365,7 @@ open class AlamoRecordObject<U: URLProtocol, E: AlamoRecordError>: NSObject, Map
The URL to use when making a find request for all objects of this instance
- parameter id: The id of the object to find
*/
open class func urlForFind(_ id: Any) -> U {
open class func urlForFind(_ id: IDType) -> U {
return U(url: "\(pluralRoot)/\(id)")
}

Expand All @@ -377,7 +377,7 @@ open class AlamoRecordObject<U: URLProtocol, E: AlamoRecordError>: NSObject, Map
The URL to use when making an update request for all objects of this instance
- parameter id: The id of the object to update
*/
open class func urlForUpdate(_ id: Any) -> U {
open class func urlForUpdate(_ id: IDType) -> U {
return U(url: "\(pluralRoot)/\(id)")
}

Expand All @@ -389,7 +389,7 @@ open class AlamoRecordObject<U: URLProtocol, E: AlamoRecordError>: NSObject, Map
The URL to use when making a destroy request for all objects this instance
- parameter id: The id of the object to destroy
*/
open class func urlForDestroy(_ id: Any) -> U {
open class func urlForDestroy(_ id: IDType) -> U {
return U(url: "\(pluralRoot)/\(id)")
}

Expand Down
2 changes: 1 addition & 1 deletion AlamoRecord/Classes/Logger.swift
Expand Up @@ -55,7 +55,7 @@ class Logger: NSObject {
let statusCode = responseObject.statusCode
let statusCodeString = statusCodeStrings[statusCode]
let duration = String(response.timeline.totalDuration)
let trimmedDuration = duration.substring(to: duration.index(duration.startIndex, offsetBy: 4))
let trimmedDuration = String(duration[duration.startIndex..<duration.index(duration.startIndex, offsetBy: 4)])
print("\(emoji(for: statusCode)) \(loggerPrefix) \(method) \(urlString) (\(statusCode) \(statusCodeString!)) \(trimmedDuration) seconds")
}
}
Expand Down
14 changes: 7 additions & 7 deletions AlamoRecord/Classes/RequestManager.swift
Expand Up @@ -20,7 +20,7 @@ import Alamofire
import AlamofireObjectMapper
import ObjectMapper

open class RequestManager<U: URLProtocol, E: AlamoRecordError>: NSObject {
open class RequestManager<U: URLProtocol, E: AlamoRecordError, IDType>: NSObject {

public typealias Parameters = [String: Any]

Expand Down Expand Up @@ -205,7 +205,7 @@ open class RequestManager<U: URLProtocol, E: AlamoRecordError>: NSObject {
- parameter failure: The block to execute if the request fails
*/
@discardableResult
public func findObject<T: AlamoRecordObject<U, E>>(id: Any,
public func findObject<T: AlamoRecordObject<U, E, IDType>>(id: IDType,
parameters: Parameters? = nil,
keyPath: String? = nil,
encoding: ParameterEncoding = URLEncoding.default,
Expand Down Expand Up @@ -233,7 +233,7 @@ open class RequestManager<U: URLProtocol, E: AlamoRecordError>: NSObject {
- parameter failure: The block to execute if the request fails
*/
@discardableResult
public func findObject<T: AlamoRecordObject<U, E>>(url: U,
public func findObject<T: AlamoRecordObject<U, E, IDType>>(url: U,
parameters: Parameters? = nil,
keyPath: String? = nil,
encoding: ParameterEncoding = URLEncoding.default,
Expand Down Expand Up @@ -290,7 +290,7 @@ open class RequestManager<U: URLProtocol, E: AlamoRecordError>: NSObject {
- parameter failure: The block to execute if the request fails
*/
@discardableResult
public func createObject<T: AlamoRecordObject<U, E>>(parameters: Parameters? = nil,
public func createObject<T: AlamoRecordObject<U, E, IDType>>(parameters: Parameters? = nil,
keyPath: String? = nil,
encoding: ParameterEncoding = URLEncoding.default,
headers: HTTPHeaders? = nil,
Expand All @@ -317,7 +317,7 @@ open class RequestManager<U: URLProtocol, E: AlamoRecordError>: NSObject {
- parameter failure: The block to execute if the request fails
*/
@discardableResult
public func createObject<T: AlamoRecordObject<U, E>>(url: U,
public func createObject<T: AlamoRecordObject<U, E, IDType>>(url: U,
parameters: Parameters? = nil,
keyPath: String? = nil,
encoding: ParameterEncoding = URLEncoding.default,
Expand Down Expand Up @@ -371,7 +371,7 @@ open class RequestManager<U: URLProtocol, E: AlamoRecordError>: NSObject {
- parameter failure: The block to execute if the request fails
*/
@discardableResult
public func updateObject<T: AlamoRecordObject<U, E>>(id: Any,
public func updateObject<T: AlamoRecordObject<U, E, IDType>>(id: IDType,
parameters: Parameters? = nil,
keyPath: String? = nil,
encoding: ParameterEncoding = URLEncoding.default,
Expand Down Expand Up @@ -399,7 +399,7 @@ open class RequestManager<U: URLProtocol, E: AlamoRecordError>: NSObject {
- parameter failure: The block to execute if the request fails
*/
@discardableResult
public func updateObject<T: AlamoRecordObject<U, E>>(url: U,
public func updateObject<T: AlamoRecordObject<U, E, IDType>>(url: U,
parameters: Parameters? = nil,
keyPath: String? = nil,
encoding: ParameterEncoding = URLEncoding.default,
Expand Down
30 changes: 23 additions & 7 deletions Example/AlamoRecord.xcodeproj/project.pbxproj
Expand Up @@ -335,18 +335,18 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0820;
LastUpgradeCheck = 1000;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
5C6346FA1F0B076B00158A80 = {
CreatedOnToolsVersion = 8.3.2;
LastSwiftMigration = 0830;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
TestTargetID = 607FACCF1AFB9204008FA782;
};
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0820;
LastSwiftMigration = 1000;
};
};
};
Expand Down Expand Up @@ -579,7 +579,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AlamoRecord_Example.app/AlamoRecord_Example";
};
name = Debug;
Expand All @@ -597,7 +597,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.daltron.Tests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AlamoRecord_Example.app/AlamoRecord_Example";
};
name = Release;
Expand All @@ -610,14 +610,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -657,14 +665,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -700,7 +716,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -715,7 +731,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Example/AlamoRecord/AppDelegate.swift
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

if let _ = NSClassFromString("XCTest") {
Expand Down
4 changes: 2 additions & 2 deletions Example/AlamoRecord/Comment.swift
Expand Up @@ -9,9 +9,9 @@
import ObjectMapper
import UIKit

class Comment: AlamoRecordObject<ApplicationURL, ApplicationError> {
class Comment: AlamoRecordObject<ApplicationURL, ApplicationError, Int> {

class override var requestManager: RequestManager<ApplicationURL, ApplicationError> {
class override var requestManager: ApplicationRequestManager {
return ApplicationRequestManager.default
}

Expand Down
4 changes: 2 additions & 2 deletions Example/AlamoRecord/CommentsView.swift
Expand Up @@ -26,11 +26,11 @@ class CommentsView: UIView {
tableView = UITableView(frame: .zero, style: .plain)
tableView.backgroundColor = .darkWhite
tableView.separatorStyle = .none
tableView.rowHeight = UITableViewAutomaticDimension
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 50.0
tableView.dataSource = self
tableView.delegate = self
tableView.contentInset = UIEdgeInsetsMake(0, 0, 10, 0)
tableView.contentInset = UIEdgeInsets.init(top: 0, left: 0, bottom: 10, right: 0)
addSubview(tableView)

tableView.snp.makeConstraints { (make) in
Expand Down
4 changes: 2 additions & 2 deletions Example/AlamoRecord/PostsView.swift
Expand Up @@ -29,11 +29,11 @@ class PostsView: UIView {
tableView = UITableView(frame: .zero, style: .plain)
tableView.backgroundColor = .darkWhite
tableView.separatorStyle = .none
tableView.rowHeight = UITableViewAutomaticDimension
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 50.0
tableView.dataSource = self
tableView.delegate = self
tableView.contentInset = UIEdgeInsetsMake(0, 0, 10, 0)
tableView.contentInset = UIEdgeInsets.init(top: 0, left: 0, bottom: 10, right: 0)
addSubview(tableView)

tableView.snp.makeConstraints { (make) in
Expand Down

0 comments on commit 7da54bd

Please sign in to comment.