Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #100 from readium/2.0.0-alpha.1
Browse files Browse the repository at this point in the history
2.0.0-alpha.1
  • Loading branch information
mickael-menu authored Aug 11, 2020
2 parents 6aacb3e + c77b663 commit ef446a7
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 9 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS

This file was deleted.

2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ cache:

before_install:
- brew update
- brew outdated carthage || brew upgrade carthage
- carthage bootstrap --verbose --no-use-binaries --platform iOS --cache-builds

script:
- xcodebuild clean build -quiet
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [2.0.0-alpha.1]

### Added

* The new [Format API](https://github.com/readium/architecture/blob/master/proposals/001-format-api.md) simplifies the detection of file formats, including known publication formats such as EPUB and PDF.
Expand All @@ -27,4 +29,4 @@ All notable changes to this project will be documented in this file.
* Dependencies to format-related third-party libraries such as ZIP, XML and PDF are being consolidated into `r2-shared-swift`. Therefore, `r2-shared-swift` now depends on Fuzi and ZIPFoundation. This change will improve maintainability by isolating third-party code and allow (work in progress) to substitute the default libraries with custom ones.

[unreleased]: https://github.com/readium/r2-shared-swift/compare/master...HEAD
[x.x.x]: https://github.com/readium/r2-shared-swift/compare/1.4.3...x.x.x
[2.0.0-alpha.1]: https://github.com/readium/r2-shared-swift/compare/1.4.3...2.0.0-alpha.1
8 changes: 5 additions & 3 deletions R2Shared.podspec
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
Pod::Spec.new do |s|

s.name = 'R2Shared'
s.version = '1.4.3'
s.version = '2.0.0-alpha.1'
s.license = 'BSD 3-Clause License'
s.summary = 'R2 Shared'
s.homepage = 'http://readium.github.io'
s.author = { "Aferdita Muriqi" => "[email protected]" }
s.source = { :git => 'https://github.com/readium/r2-shared-swift.git', :tag => '1.4.3' }
s.exclude_files = ["**/Info*.plist"]
s.source = { :git => 'https://github.com/readium/r2-shared-swift.git', :tag => '2.0.0-alpha.1' }
s.exclude_files = ["**/Info*.plist", "r2-shared-swift/Toolkit/Archive/ZIPFoundation.swift"]
s.requires_arc = true
s.resources = ['r2-shared-swift/Resources/**']
s.source_files = "r2-shared-swift/**/*.{m,h,swift}"
s.platform = :ios
s.ios.deployment_target = "10.0"
s.frameworks = 'CoreServices'
s.libraries = 'xml2'
s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }

s.dependency 'Fuzi'
s.dependency 'Minizip'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install R2Shared with Carthage:
2. Update your Cartfile to include the following:

```ruby
github "readium/r2-shared-swift" ~> 1.2.7
github "readium/r2-shared-swift" "develop"
```

3. Run `carthage update` and
Expand Down Expand Up @@ -52,7 +52,7 @@ R2Shared with CocoaPods:
use_frameworks!
target 'YourAppTargetName' do
pod 'R2Shared', :git => 'https://github.com/readium/r2-shared-swift.git', '~> 1.2.7'
pod 'R2Shared', :git => 'https://github.com/readium/r2-shared-swift.git', :branch => 'develop'
end
```

Expand Down
20 changes: 20 additions & 0 deletions r2-shared-swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
CA9E6BA4223A657900ECF6E4 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA9E6BA3223A657900ECF6E4 /* JSON.swift */; };
CA9E6BA9223A749900ECF6E4 /* Publication+EPUB.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA9E6BA8223A749900ECF6E4 /* Publication+EPUB.swift */; };
CA9E6BAE223A76C600ECF6E4 /* Publication+OPDS.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA9E6BAD223A76C600ECF6E4 /* Publication+OPDS.swift */; };
CAAABA9D24D7F248004A4466 /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAAABA9C24D7F248004A4466 /* URL.swift */; };
CAAABAA024D7F2DC004A4466 /* URLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAAABA9F24D7F2DC004A4466 /* URLTests.swift */; };
CAAF80CA2456D7370024D7AE /* AudioSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAAF80C92456D7370024D7AE /* AudioSession.swift */; };
CAB88C92224E766E00D36C99 /* LocatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAB88C91224E766E00D36C99 /* LocatorTests.swift */; };
CABBB2E52237ADEB004EB039 /* Feed.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3B1879F1FA33D4D00BB46BF /* Feed.swift */; };
Expand Down Expand Up @@ -244,6 +246,8 @@
CA9E6BA6223A67D300ECF6E4 /* Publication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Publication.swift; sourceTree = "<group>"; };
CA9E6BA8223A749900ECF6E4 /* Publication+EPUB.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Publication+EPUB.swift"; sourceTree = "<group>"; };
CA9E6BAD223A76C600ECF6E4 /* Publication+OPDS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Publication+OPDS.swift"; sourceTree = "<group>"; };
CAAABA9C24D7F248004A4466 /* URL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URL.swift; sourceTree = "<group>"; };
CAAABA9F24D7F2DC004A4466 /* URLTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLTests.swift; sourceTree = "<group>"; };
CAAF80C92456D7370024D7AE /* AudioSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioSession.swift; sourceTree = "<group>"; };
CAB88C91224E766E00D36C99 /* LocatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocatorTests.swift; sourceTree = "<group>"; };
CABBB2F32237BF42004EB039 /* OPDSPriceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OPDSPriceTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -403,6 +407,7 @@
CA252DDE2447A5AE0005067C /* Toolkit */ = {
isa = PBXGroup;
children = (
CAAABA9E24D7F2CD004A4466 /* Extensions */,
CA252DDF2447A5B40005067C /* Archive */,
CA7116EE2455935100C029FD /* DocumentTypesTests.swift */,
);
Expand Down Expand Up @@ -566,6 +571,7 @@
CA68BDCD24407750009A6BAA /* StringEncoding.swift */,
CAD0FEC1244310BB0053C998 /* Array.swift */,
CAD1EE6F245AC29B00C1E684 /* String.swift */,
CAAABA9C24D7F248004A4466 /* URL.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -622,6 +628,14 @@
path = OPDS;
sourceTree = "<group>";
};
CAAABA9E24D7F2CD004A4466 /* Extensions */ = {
isa = PBXGroup;
children = (
CAAABA9F24D7F2DC004A4466 /* URLTests.swift */,
);
path = Extensions;
sourceTree = "<group>";
};
CAC34F04221C61BD002C452E /* DRM */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -854,6 +868,7 @@
CA16A8742233004A00E66255 /* PropertiesTests.swift in Sources */,
CA16A8802233BE6900E66255 /* EncryptionTests.swift in Sources */,
CA5F8EFB2404142C00926120 /* EPUBLayoutTests.swift in Sources */,
CAAABAA024D7F2DC004A4466 /* URLTests.swift in Sources */,
CA6F27742469E4DA0065B405 /* FileFetcherTests.swift in Sources */,
CA40C07A21FF25F80069A50E /* JSON.swift in Sources */,
CA68BDD12440E123009A6BAA /* FormatSnifferTests.swift in Sources */,
Expand Down Expand Up @@ -956,6 +971,7 @@
CABBB2E72237ADEB004EB039 /* Facet.swift in Sources */,
CA16A8822233FE3200E66255 /* Metadata.swift in Sources */,
CA68BDC924406C10009A6BAA /* FormatSniffer.swift in Sources */,
CAAABA9D24D7F248004A4466 /* URL.swift in Sources */,
CA3386E12404FAD000FDCBBA /* Encryption.swift in Sources */,
CAF4EAE52237ABC700A17DA1 /* MediaOverlays.swift in Sources */,
CA3386EE24056ADB00FDCBBA /* Locator+HTML.swift in Sources */,
Expand Down Expand Up @@ -1180,10 +1196,12 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2";
INFOPLIST_FILE = "r2-shared-swift/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = "-lxml2";
PRODUCT_BUNDLE_IDENTIFIER = "org.readium.r2-shared-swift";
PRODUCT_NAME = R2Shared;
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1212,10 +1230,12 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2";
INFOPLIST_FILE = "r2-shared-swift/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = "-lxml2";
PRODUCT_BUNDLE_IDENTIFIER = "org.readium.r2-shared-swift";
PRODUCT_NAME = R2Shared;
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
7 changes: 5 additions & 2 deletions r2-shared-swift/Format/FormatSnifferContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ final class FormatSnifferFileContent: FormatSnifferContent, Loggable {

let file: URL

init(file: URL) {
assert(file.isFileURL || file.scheme == nil)
init?(file: URL) {
guard file.isFileURL || file.scheme == nil else {
return nil
}

self.file = file
}

Expand Down
27 changes: 27 additions & 0 deletions r2-shared-swift/Toolkit/Extensions/URL.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// URL.swift
// r2-shared-swift
//
// Created by Mickaël Menu on 03/08/2020.
//
// Copyright 2020 Readium Foundation. All rights reserved.
// Use of this source code is governed by a BSD-style license which is detailed
// in the LICENSE file present in the project repository where this source code is maintained.
//

import Foundation

extension URL {

/// Adds the given `newScheme` to the URL, but only if the URL doesn't already have one.
public func addingSchemeIfMissing(_ newScheme: String) -> URL {
guard scheme == nil else {
return self
}

var components = URLComponents(url: self, resolvingAgainstBaseURL: true)
components?.scheme = newScheme
return components?.url ?? self
}

}
28 changes: 28 additions & 0 deletions r2-shared-swiftTests/Toolkit/Extensions/URLTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// URLTests.swift
// r2-shared-swift
//
// Created by Mickaël Menu on 03/08/2020.
//
// Copyright 2020 Readium Foundation. All rights reserved.
// Use of this source code is governed by a BSD-style license which is detailed
// in the LICENSE file present in the project repository where this source code is maintained.
//

import XCTest
@testable import R2Shared

class URLTests: XCTestCase {

func testAddingSchemeIfMissing() {
XCTAssertEqual(
URL(string: "//www.google.com/path")!.addingSchemeIfMissing("test"),
URL(string: "test://www.google.com/path")!
)
XCTAssertEqual(
URL(string: "http://www.google.com/path")!.addingSchemeIfMissing("test"),
URL(string: "http://www.google.com/path")!
)
}

}

0 comments on commit ef446a7

Please sign in to comment.