Skip to content

Commit

Permalink
Merge pull request #102 from bustoutsolutions/directory-reorg
Browse files Browse the repository at this point in the history
Separate SiestaUI module & directory reorg
  • Loading branch information
pcantrell committed Aug 24, 2016
2 parents 8f05738 + 2b93d15 commit ca3e2f9
Show file tree
Hide file tree
Showing 46 changed files with 513 additions and 174 deletions.
6 changes: 5 additions & 1 deletion .jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ module: Siesta
author: Bust Out Solutions
author_url: http://bustoutsolutions.com
github_url: https://github.com/bustoutsolutions/siesta
exclude: ["**/*-ObjC.swift", "**/*Deprecations.swift"]
exclude:
- "**/*-ObjC.swift"
- "**/*Deprecations.swift"
- "Source/Support/Siesta-ObjC.swift" # until Cocoadocs gets latest jazzy
- "Source/Support/Ω_Deprecations.swift" # until Cocoadocs gets latest jazzy

copyright: '© 2016 [Bust Out Solutions](http://bustoutsolutions.com) under [open source license](https://github.com/bustoutsolutions/siesta/blob/master/LICENSE).'

Expand Down
2 changes: 1 addition & 1 deletion Examples/GithubBrowser/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ platform :ios, '9.0'
target 'GithubBrowser' do
use_frameworks!

pod 'Siesta', path: '../..'
pod 'Siesta/UI', path: '../..'
pod 'SwiftyJSON'
end
10 changes: 5 additions & 5 deletions Examples/GithubBrowser/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
PODS:
- Siesta (1.0-beta.9):
- Siesta/Core (= 1.0-beta.9)
- Siesta/Core (1.0-beta.9)
- Siesta/UI (1.0-beta.9):
- Siesta/Core
- SwiftyJSON (2.3.2)

DEPENDENCIES:
- Siesta (from `../..`)
- Siesta/UI (from `../..`)
- SwiftyJSON

EXTERNAL SOURCES:
Siesta:
:path: "../.."

SPEC CHECKSUMS:
Siesta: 2c1e487b36d88060477eb0458d43a38d8b0bd959
Siesta: 6405fa1f80105e1614c42a37dcd79806f99bf23c
SwiftyJSON: 04ccea08915aa0109039157c7974cf0298da292a

PODFILE CHECKSUM: 1b049ab49e1e4cfa3e646e34135423a20b163fb4
PODFILE CHECKSUM: 185541f66e3c53d1269ded59a72f9c99e6a2d105

COCOAPODS: 1.1.0.beta.1
9 changes: 7 additions & 2 deletions Siesta.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,15 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/bustoutsolutions/siesta.git", :tag => "1.0-beta.9" }

s.subspec "Core" do |s|
s.source_files = "Source/**/*"
s.source_files = "Source/Siesta/**/*"
s.exclude_files = "**/Info*.plist"
end

s.subspec "UI" do |s|
s.source_files = "Source/SiestaUI/**/*"
s.dependency "Siesta/Core"
s.exclude_files = "**/Info*.plist"
s.ios.resources = "Source/**/*.xib"
s.osx.exclude_files = "Source/UI"
end

s.subspec "Alamofire" do |s|
Expand Down
321 changes: 295 additions & 26 deletions Siesta.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions Siesta.xcodeproj/xcshareddata/xcschemes/Siesta iOS.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@
ReferencedContainer = "container:Siesta.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DAC0B37D1D651CB500D25C44"
BuildableName = "SiestaUI.framework"
BlueprintName = "SiestaUI iOS"
ReferencedContainer = "container:Siesta.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
Expand Down
2 changes: 1 addition & 1 deletion Source/Info-macOS.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 Bust Out Solutions. All rights reserved.</string>
<string>Copyright © 2016 Bust Out Solutions, under MIT license</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Pipeline.swift
// PipelineConfiguration.swift
// Siesta
//
// Created by Paul on 2016/6/3.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Processing.swift
// PipelineProcessing.swift
// Siesta
//
// Created by Paul on 2016/8/7.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
96 changes: 2 additions & 94 deletions Source/Resource.swift → Source/Siesta/Resource/Resource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public final class Resource: NSObject

internal var observers = [ObserverEntry]()

// MARK: Configuration

/// Configuration when there is no request method.
public var configuration: Configuration
{ return configuration(forRequestMethod: .GET) }
Expand Down Expand Up @@ -150,100 +152,6 @@ public final class Resource: NSObject
initializeDataFromCache()
}

// MARK: URL navigation

/**
Returns the resource with the given string appended to the path of this resource’s URL, with a joining slash
inserted if necessary.
Use this method for hierarchical resource navigation. The typical use case is constructing a resource URL from
path components and IDs:
let resource = service.resource("/widgets")
resource.child("123").child("details")
//→ /widgets/123/details
This method _always_ returns a subpath of the receiving resource. It does not apply any special
interpretation to strings such `./`, `//` or `?` that have significance in other URL-related
situations. Special characters are escaped when necessary, and otherwise ignored. See
[`ResourcePathsSpec`](https://bustoutsolutions.github.io/siesta/specs/#ResourcePathsSpec)
for details.
- SeeAlso: `relative(_:)`
*/
@warn_unused_result
public func child(subpath: String) -> Resource
{
return service.resource(absoluteURL: url.URLByAppendingPathComponent(subpath))
}

/**
Returns the resource with the given URL, using this resource’s URL as the base if it is a relative URL.
This method interprets strings such as `.`, `..`, and a leading `/` or `//` as relative URLs. It resolves its
parameter much like an `href` attribute in an HTML document. Refer to
[`ResourcePathsSpec`](https://bustoutsolutions.github.io/siesta/specs/#ResourcePathsSpec)
for details.
- SeeAlso:
- `optionalRelative(_:)`
- `child(_:)`
*/
@warn_unused_result
public func relative(href: String) -> Resource
{
return service.resource(absoluteURL: NSURL(string: href, relativeToURL: url))
}

/**
Returns `relative(href)` if `href` is present, and nil if `href` is nil.
This convenience method is useful for resolving URLs returned as part of a JSON response body:
let href = resource.jsonDict["owner"] as? String // href is an optional
if let ownerResource = resource.optionalRelative(href) {
// ...
}
*/
@warn_unused_result
public func optionalRelative(href: String?) -> Resource?
{
if let href = href
{ return relative(href) }
else
{ return nil }
}

/**
Returns this resource with the given parameter added or changed in the query string.
If `value` is an empty string, the parameter goes in the query string with no value (e.g. `?foo`).
If `value` is nil, the parameter is removed.
There is no support for parameters with an equal sign but an empty value (e.g. `?foo=`).
There is also no support for repeated keys in the query string (e.g. `?foo=1&foo=2`).
If you need to circumvent either of these restrictions, you can create the query string yourself and pass
it to `relative(_:)` instead of using `withParam(_:_:)`.
Note that `Service` gives out unique `Resource` instances according to the full URL in string form, and thus
considers query string parameter order significant. Therefore, to ensure that you get the same `Resource`
instance no matter the order in which you specify parameters, `withParam(_:_:)` sorts all parameters by name.
Note that _only_ `withParam(_:_:)` does this sorting; if you use other methods to create query strings, it is
up to you to canonicalize your parameter order.
*/
@warn_unused_result
@objc(withParam:value:)
public func withParam(name: String, _ value: String?) -> Resource
{
return service.resource(absoluteURL:
url.alterQuery
{
var params = $0
params[name] = value
return params
})
}

// MARK: Requests

/**
Expand Down
106 changes: 106 additions & 0 deletions Source/Siesta/Resource/ResourceNavigation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
//
// ResourceNavigation.swift
// Siesta
//
// Created by Paul on 2016/8/16.
// Copyright © 2016 Bust Out Solutions. All rights reserved.
//

import Foundation

extension Resource
{
// MARK: URL navigation

/**
Returns the resource with the given string appended to the path of this resource’s URL, with a joining slash
inserted if necessary.
Use this method for hierarchical resource navigation. The typical use case is constructing a resource URL from
path components and IDs:
let resource = service.resource("/widgets")
resource.child("123").child("details")
//→ /widgets/123/details
This method _always_ returns a subpath of the receiving resource. It does not apply any special
interpretation to strings such `./`, `//` or `?` that have significance in other URL-related
situations. Special characters are escaped when necessary, and otherwise ignored. See
[`ResourcePathsSpec`](https://bustoutsolutions.github.io/siesta/specs/#ResourcePathsSpec)
for details.
- SeeAlso: `relative(_:)`
*/
@warn_unused_result
public func child(subpath: String) -> Resource
{
return service.resource(absoluteURL: url.URLByAppendingPathComponent(subpath))
}

/**
Returns the resource with the given URL, using this resource’s URL as the base if it is a relative URL.
This method interprets strings such as `.`, `..`, and a leading `/` or `//` as relative URLs. It resolves its
parameter much like an `href` attribute in an HTML document. Refer to
[`ResourcePathsSpec`](https://bustoutsolutions.github.io/siesta/specs/#ResourcePathsSpec)
for details.
- SeeAlso:
- `optionalRelative(_:)`
- `child(_:)`
*/
@warn_unused_result
public func relative(href: String) -> Resource
{
return service.resource(absoluteURL: NSURL(string: href, relativeToURL: url))
}

/**
Returns `relative(href)` if `href` is present, and nil if `href` is nil.
This convenience method is useful for resolving URLs returned as part of a JSON response body:
let href = resource.jsonDict["owner"] as? String // href is an optional
if let ownerResource = resource.optionalRelative(href) {
// ...
}
*/
@warn_unused_result
public func optionalRelative(href: String?) -> Resource?
{
if let href = href
{ return relative(href) }
else
{ return nil }
}

/**
Returns this resource with the given parameter added or changed in the query string.
If `value` is an empty string, the parameter goes in the query string with no value (e.g. `?foo`).
If `value` is nil, the parameter is removed.
There is no support for parameters with an equal sign but an empty value (e.g. `?foo=`).
There is also no support for repeated keys in the query string (e.g. `?foo=1&foo=2`).
If you need to circumvent either of these restrictions, you can create the query string yourself and pass
it to `relative(_:)` instead of using `withParam(_:_:)`.
Note that `Service` gives out unique `Resource` instances according to the full URL in string form, and thus
considers query string parameter order significant. Therefore, to ensure that you get the same `Resource`
instance no matter the order in which you specify parameters, `withParam(_:_:)` sorts all parameters by name.
Note that _only_ `withParam(_:_:)` does this sorting; if you use other methods to create query strings, it is
up to you to canonicalize your parameter order.
*/
@warn_unused_result
@objc(withParam:value:)
public func withParam(name: String, _ value: String?) -> Resource
{
return service.resource(absoluteURL:
url.alterQuery
{
var params = $0
params[name] = value
return params
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,6 @@ public enum ResourceEvent: CustomStringConvertible
}
}

internal static let all = [ObserverAdded, Requested, RequestCancelled, NotModified, Error,
NewData(.Network), NewData(.Cache), NewData(.LocalOverride), NewData(.Wipe)]

internal static func fromDescription(description: String) -> ResourceEvent?
{
let matching = all.filter { $0.description == description }
return (matching.count == 1) ? matching[0] : nil
}

/// Possible sources of `ResourceEvent.NewData`.
public enum NewDataSource
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -299,38 +299,6 @@ public extension Resource
}
}

#if !os(OSX)
extension ResourceStatusOverlay: _objc_ResourceObserver
{
public func resourceChanged(resource: Resource, event eventString: String)
{
if let event = ResourceEvent.fromDescription(eventString)
{ resourceChanged(resource, event: event) }
}
}

extension ResourceStatusOverlay
{
@objc(displayPriority)
public var _objc_displayPriority: [String]
{
get {
return displayPriority.map { $0.rawValue }
}

set {
displayPriority = newValue.flatMap
{
let condition = ResourceStatusOverlay.StateRule(rawValue: $0)
if condition == nil
{ Swift.print("WARNING: ignoring unknown ResourceStatusOverlay.StateRule \"\($0)\"") }
return condition
}
}
}
}
#endif

public extension Resource
{
private func _objc_wrapRequest(
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions Source/Siesta/Support/SiestaUI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// SiestaUI.h
// Siesta
//
// Created by Paul on 2015/6/14.
// Copyright © 2016 Bust Out Solutions. All rights reserved.
//

#import <Foundation/Foundation.h>

//! Project version number for SiestaUI.
FOUNDATION_EXPORT double SiestaUIVersionNumber;

//! Project version string for SiestaUI.
FOUNDATION_EXPORT const unsigned char SiestaUIVersionString[];

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ca3e2f9

Please sign in to comment.