Skip to content

Commit

Permalink
Merge branch 'release/0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos committed Sep 28, 2018
2 parents ca8798f + c8b6953 commit 34171fb
Show file tree
Hide file tree
Showing 13 changed files with 232 additions and 19 deletions.
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
*.xcscmblueprint
xcuserdata

archive
build
/archive
/build

/Carthage

/fastlane/report.xml
/fastlane/test_output
4 changes: 2 additions & 2 deletions Framework/Sources/Categories/NSBundle+SRGNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Convenience macro for localized strings associated with the framework.
*/
#define SRGNetworkLocalizedString(key, comment) [[NSBundle srg_networkBundle] localizedStringForKey:(key) value:@"" table:nil]
#define SRGNetworkLocalizedString(key, comment) [NSBundle.srg_networkBundle localizedStringForKey:(key) value:@"" table:nil]

@interface NSBundle (SRGNetwork)

/**
* The framework resource bundle.
*/
+ (NSBundle *)srg_networkBundle;
@property (class, nonatomic, readonly) NSBundle *srg_networkBundle;

@end

Expand Down
2 changes: 1 addition & 1 deletion Framework/Sources/Categories/NSBundle+SRGNetwork.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ + (NSBundle *)srg_networkBundle
static NSBundle *s_bundle;
static dispatch_once_t s_onceToken;
dispatch_once(&s_onceToken, ^{
NSString *bundlePath = [[NSBundle bundleForClass:[SRGNetworkRequest class]].bundlePath stringByAppendingPathComponent:@"SRGNetwork.bundle"];
NSString *bundlePath = [[NSBundle bundleForClass:SRGNetworkRequest.class].bundlePath stringByAppendingPathComponent:@"SRGNetwork.bundle"];
s_bundle = [NSBundle bundleWithPath:bundlePath];
NSAssert(s_bundle, @"Please add SRGNetwork.bundle to your project resources");
});
Expand Down
2 changes: 1 addition & 1 deletion Framework/Sources/SRGNetwork.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

NSString *SRGNetworkMarketingVersion(void)
{
return [NSBundle srg_networkBundle].infoDictionary[@"CFBundleShortVersionString"];
return NSBundle.srg_networkBundle.infoDictionary[@"CFBundleShortVersionString"];
}
6 changes: 3 additions & 3 deletions Framework/Sources/SRGNetworkRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ - (instancetype)initWithURLRequest:(NSURLRequest *)request session:(NSURLSession
return;
}

if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
if ([response isKindOfClass:NSHTTPURLResponse.class]) {
NSHTTPURLResponse *HTTPURLResponse = (NSHTTPURLResponse *)response;
NSInteger HTTPStatusCode = HTTPURLResponse.statusCode;

Expand Down Expand Up @@ -73,7 +73,7 @@ - (instancetype)initWithJSONDictionaryURLRequest:(NSURLRequest *)request session
}

id JSONDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];
if (! JSONDictionary || ! [JSONDictionary isKindOfClass:[NSDictionary class]]) {
if (! JSONDictionary || ! [JSONDictionary isKindOfClass:NSDictionary.class]) {
completionBlock(nil, response, [NSError errorWithDomain:SRGNetworkErrorDomain
code:SRGNetworkErrorInvalidData
userInfo:@{ NSLocalizedDescriptionKey : SRGNetworkLocalizedString(@"The data is invalid.", @"Error message returned when a server response data is incorrect.") }]);
Expand All @@ -93,7 +93,7 @@ - (instancetype)initWithJSONArrayURLRequest:(NSURLRequest *)request session:(NSU
}

id JSONArray = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];
if (! JSONArray || ! [JSONArray isKindOfClass:[NSArray class]]) {
if (! JSONArray || ! [JSONArray isKindOfClass:NSArray.class]) {
completionBlock(nil, response, [NSError errorWithDomain:SRGNetworkErrorDomain
code:SRGNetworkErrorInvalidData
userInfo:@{ NSLocalizedDescriptionKey : SRGNetworkLocalizedString(@"The data is invalid.", @"Error message returned when a server response data is incorrect.") }]);
Expand Down
18 changes: 13 additions & 5 deletions SRGNetwork.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
6F26A7602153BD4D005B775C /* NSHTTPURLResponse_NetworkTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 6F26A75F2153BD4D005B775C /* NSHTTPURLResponse_NetworkTestCase.m */; };
6F6A09F72101BD11004568BD /* SRGNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6F8A942320FF21EB00AA6434 /* SRGNetwork.framework */; };
6F6A0A012101BEB7004568BD /* NetworkRequestTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 6F6A09FF2101BEB7004568BD /* NetworkRequestTestCase.m */; };
6F8A94432100566F00AA6434 /* SRGNetworkRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F8A943B2100566F00AA6434 /* SRGNetworkRequest.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -41,6 +42,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
6F26A75F2153BD4D005B775C /* NSHTTPURLResponse_NetworkTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSHTTPURLResponse_NetworkTestCase.m; sourceTree = "<group>"; };
6F6A09F22101BD11004568BD /* SRGNetwork-tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SRGNetwork-tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
6F6A09FF2101BEB7004568BD /* NetworkRequestTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NetworkRequestTestCase.m; sourceTree = "<group>"; };
6F6A0A002101BEB7004568BD /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -103,6 +105,7 @@
isa = PBXGroup;
children = (
6F6A09FF2101BEB7004568BD /* NetworkRequestTestCase.m */,
6F26A75F2153BD4D005B775C /* NSHTTPURLResponse_NetworkTestCase.m */,
);
path = Sources;
sourceTree = "<group>";
Expand Down Expand Up @@ -247,7 +250,7 @@
6F8A941A20FF21EB00AA6434 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0940;
LastUpgradeCheck = 1000;
ORGANIZATIONNAME = "SRG SSR";
TargetAttributes = {
6F6A09F12101BD11004568BD = {
Expand Down Expand Up @@ -315,6 +318,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6F26A7602153BD4D005B775C /* NSHTTPURLResponse_NetworkTestCase.m in Sources */,
6F6A0A012101BEB7004568BD /* NetworkRequestTestCase.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -405,6 +409,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
Expand Down Expand Up @@ -456,7 +461,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MARKETING_VERSION = 0.2;
MARKETING_VERSION = 0.2.1;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -468,6 +473,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
Expand Down Expand Up @@ -513,7 +519,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MARKETING_VERSION = 0.2;
MARKETING_VERSION = 0.2.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -569,6 +575,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
Expand Down Expand Up @@ -620,7 +627,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MARKETING_VERSION = 0.2;
MARKETING_VERSION = 0.2.1;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -672,6 +679,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
Expand Down Expand Up @@ -717,7 +725,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MARKETING_VERSION = 0.2;
MARKETING_VERSION = 0.2.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -29,7 +29,9 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
skipped = "NO"
parallelizable = "YES"
testExecutionOrdering = "random">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6F6A09F12101BD11004568BD"
Expand Down
38 changes: 38 additions & 0 deletions Tests/Sources/NSHTTPURLResponse_NetworkTestCase.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Copyright (c) SRG SSR. All rights reserved.
//
// License information is available from the LICENSE file.
//

#import "NSHTTPURLResponse+SRGNetwork.h"

#import <XCTest/XCTest.h>

@interface NSHTTPURLResponse_NetworkTestCase : XCTestCase

@end

@implementation NSHTTPURLResponse_NetworkTestCase

#pragma mark Tests

- (void)testLocalizedStringForStatusCode
{
NSArray *statusCodes = @[ @100, @101, @102,
@200, @201, @202, @203, @204, @205, @206, @207, @208, @226,
@300, @301, @302, @303, @304, @305, @306, @307, @308,
@400, @401, @402, @403, @404, @405, @406, @407, @408, @409, @410, @411, @412, @413, @414, @415, @416, @417, @418, @421, @422, @423, @424, @426, @428, @429, @431, @451,
@500, @501, @502, @503, @504, @505, @506, @507, @508, @510, @511,
@103, @420, @450, @498, @499, @509, @530, @598, @599,
@440, @449, @451,
@444, @495, @496, @497, @499,
@520, @521, @522, @523, @524, @525, @526, @527];

for (NSNumber *statusCode in statusCodes) {
NSString *message = [NSHTTPURLResponse srg_localizedStringForStatusCode:statusCode.integerValue];
NSLog(@"%@: %@", statusCode, message);
XCTAssertNotNil(message);
}
}

@end
46 changes: 46 additions & 0 deletions docs/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
41 changes: 41 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## Introduction

Thank you for very much for your interest in contributing to our project! As a public service company, we want to shape a product that better matches our user needs and desires. Ideas or direct contributions are therefore warmly welcome and will be considered with great care, provided they fulfill a few requirements listed in this document. Please read it first before you decide to contribute.

### Why guidelines?

Our development team is small, our ability to quickly evaluate a need or a code submission is therefore critical. Please follow the present contributing guidelines so that we can efficiently consider your proposal. You should also read or our [code of conduct](CODE_OF_CONDUCT.md), providing a few guidelines to keep interactions as respectful as possible.

### Contributions we are looking for

Any kind of contribution is welcome, as long as it improves the overall quality of our product, for example:

* Requests for new features or ideas.
* Bug reports or fixes.
* Documentation improvements.
* Translation improvements.

Contributions can either take the form of simple issues where you describe the problem you face or what you would like to see in our products. If you feel up to the challenge, you can even submit code in the form of pull requests which our team will review.

### Contributions we are not looking for

Requests which are too vague or not related to our product will not be taken into account. We also have no editorial influence, any issue related to the content available on our platform will simply be closed.

## Contributing

You can use issues to report bugs, submit ideas or request features. People with a programming background can also submit changes directly via pull requests. Creating issues or pull requests requires you to own or [open](https://github.com/join) a GitHub account.

If you are not sure about the likelihood of a change you propose to be accepted, please open an issue first. We can discuss it there, especially whether it is compatible with our product or not. This way you can avoid creating an entire pull request we will never be able to merge.

Templates are available when you want to contribute:

* [Issues](https://github.com/SRGSSR/playsrg-ios/issues/new): Please follow our issue template. You can omit information which does not make sense but, in general, the more details you can provide, the better. This ensures we can quickly reproduce the problem you are facing, increasing the likelihood we can fix it.
* [Pull requests](https://github.com/SRGSSR/playsrg-ios/compare): Please follow our code conventions, test your code well, and write unit tests when this makes sense. We will review your work and, if successful, merge it back into the main development branch.

## Code conventions

We currently have no formal code conventions, but we try to keep our codebase consistent. In general, having a look at the code itself should be enough for you to discover how you should write your changes.

## Code review

Pull requests, once complete, can be submitted for review by our team. Depending on the complexity of the involved changes, a few iterations might be needed. Once a pull request has been approved, it will be rebased, merged back into the development trunk and delivered with the next release.
8 changes: 5 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ A simple network library.

## Compatibility

The library is suitable for applications running on iOS 9 and above. The project is meant to be opened with the latest Xcode version (currently Xcode 9).
The library is suitable for applications running on iOS 9 and above. The project is meant to be opened with the latest Xcode version (currently Xcode 10).

## Contributing

If you want to contribute to the project, have a look at our [contributing guide](CONTRIBUTING.md).

## Installation

Expand All @@ -20,8 +24,6 @@ The library can be added to a project using [Carthage](https://github.com/Cartha
github "SRGSSR/srgnetwork-ios"
```

Until Carthage 0.30, only dynamic frameworks could be integrated. Starting with Carthage 0.30, though, frameworks can be integrated statically as well, which avoids slow application startups usually associated with the use of too many dynamic frameworks.

For more information about Carthage and its use, refer to the [official documentation](https://github.com/Carthage/Carthage).

### Dependencies
Expand Down
42 changes: 42 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md
# can also be listed using the `fastlane actions` command

# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`

# This is the minimum version number required.
fastlane_version "1.95.0"

default_platform :ios

platform :ios do
before_all do |lane|
ensure_git_status_clean
end

desc "Run library tests"
lane :test do
scan(
scheme: "SRGNetwork",
clean: true
)
end

after_all do |lane|
reset_git_repo(skip_clean: true)
end

error do |lane, exception|
clean_build_artifacts
reset_git_repo(skip_clean: true, force: true)
end
end


# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
# All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md

# fastlane reports which actions are used
# No personal data is recorded. Learn more at https://github.com/fastlane/enhancer
Loading

0 comments on commit 34171fb

Please sign in to comment.