Skip to content

Commit

Permalink
Merge pull request #1 from SwifterSwift/master
Browse files Browse the repository at this point in the history
Update from main repo
  • Loading branch information
alokc83 authored Aug 24, 2018
2 parents a5cf22c + 9eb6259 commit 8ec62ae
Show file tree
Hide file tree
Showing 204 changed files with 15,716 additions and 11,315 deletions.
1 change: 1 addition & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ coverage:
changes: true

ignore:
- "Sources/Extensions/Deprecated/*"
- "Sources/Extensions/*/Deprecated/*"
- "Tests/**/*"
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

# Set default charset
[*.{js,py,swift,m,json}]
charset = utf-8

# 4 space indentation
[*.swift]
indent_style = space
indent_size = 4
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
<!--- Please go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] I checked the [**Contributing Guidelines**](https://github.com/SwifterSwift/SwifterSwift/blob/master/CONTRIBUTING.md) before creating this request.
- [ ] New extensions are written in Swift 3.
- [ ] New extensions are written in Swift 4.
- [ ] New extensions support iOS 8.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+.
- [ ] I have added tests for new extensions, and they passed.
- [ ] All extensions have a **clear** comments explaining their functionality, all parameters and return type in English.
- [ ] All extensions are declared as **public**.
- [ ] I have added a [changelog](https://github.com/SwifterSwift/SwifterSwift/blob/master/CHANGELOG_GUIDELINES.md) entry describing my changes.
11 changes: 5 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Xcode
## Xcode
.DS_Store

## Build generated
Expand Down Expand Up @@ -31,15 +31,14 @@ xcuserdata/
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
## Swift Package Manager
.build/

# CocoaPods
## CocoaPods
Pods/

# Carthage
## Carthage
Carthage/Build

# Jazzy docs
############
## Jazzy docs
docs/
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.1
3 changes: 3 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
disabled_rules:
- line_length
- file_length
38 changes: 31 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
osx_image: xcode8.3
language: objective-c
osx_image: xcode9.4

env:
global:
- PROJECT='SwifterSwift.xcodeproj'
- IOS_SCHEME='SwifterSwift-iOS'
- TVOS_SCHEME='SwifterSwift-tvOS'
- WATCHOS_SCHEME='SwifterSwift-watchOS'
- MACOS_SCHEME='SwifterSwift-macOS'
- IOS_DESTINATION='platform=iOS Simulator,name=iPhone X'
- TVOS_DESTINATION='platform=tvOS Simulator,name=Apple TV 4K (at 1080p)'
- WATCHOS_DESTINATION='name=Apple Watch - 42mm'
- MACOS_DESTINATION='platform=OS X'


before_install:
- brew update
- brew outdated xctool || brew upgrade xctool
- gem install xcpretty
script: sh Tests/build.sh /tmp/SwifterSwift
after_success:
- bash <(curl -s https://codecov.io/bash) -D /tmp/SwifterSwift
- bundle install
- brew update
- brew outdated xctool || brew upgrade xctool
script:
- set -o pipefail
- swift --version
- xcodebuild clean build test -project "$PROJECT" -scheme "$IOS_SCHEME" -destination "$IOS_DESTINATION" | XCPRETTY_JSON_FILE_OUTPUT="xcodebuild-ios.json" xcpretty -f `xcpretty-json-formatter`
- bash <(curl -s https://codecov.io/bash) -cF ios -J 'SwifterSwift'
- xcodebuild clean build test -project "$PROJECT" -scheme "$TVOS_SCHEME" -destination "$TVOS_DESTINATION" | XCPRETTY_JSON_FILE_OUTPUT="xcodebuild-tvos.json" xcpretty -f `xcpretty-json-formatter`
- bash <(curl -s https://codecov.io/bash) -cF tvos -J 'SwifterSwift'
- xcodebuild clean build test -project "$PROJECT" -scheme "$MACOS_SCHEME" -destination "$MACOS_DESTINATION" | XCPRETTY_JSON_FILE_OUTPUT="xcodebuild-macos.json" xcpretty -f `xcpretty-json-formatter`
- bash <(curl -s https://codecov.io/bash) -cF osx -J 'SwifterSwift'
- xcodebuild clean build -project "$PROJECT" -scheme "$WATCHOS_SCHEME" -destination "$WATCHOS_DESTINATION" | XCPRETTY_JSON_FILE_OUTPUT="xcodebuild-watchos.json" xcpretty -f `xcpretty-json-formatter`
- swiftlint lint
- bundle exec danger --verbose
- pod lib lint
564 changes: 533 additions & 31 deletions CHANGELOG.md

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions CHANGELOG_GUIDELINES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Changelog Guidelines

Here you can find the general guidelines for maintaining the Changelog (or adding new entries). We follow the guidelines from [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) with few additions.

## Guiding Principles
- Changelogs are for humans, not machines.
- There should be an entry for every single version.
- The same types of changes should be grouped.
- Versions and sections should be linkable.
- The latest version comes first.
- The release date of each versions is displayed.
- Mention whether you follow Semantic Versioning.

... with the following **SwifterSwift** specific additions:
- Keep an unreleased section at the top.
- Each release title should link to release's page.
- Add PR number and a GitHub tag at the end of each entry.
- Each breaking change entry should have **Breaking Change** label at the beginning of this entry.
- **Breaking Change** entries should be placed at the top of the section it's in.
- Entries under each category should be grouped by the type they extend.

## Types of changes
- **Added** for new features.
- **Changed** for changes in existing functionality.
- **Deprecated** for soon-to-be removed features.
- **Removed** for now removed features.
- **Fixed** for any bug fixes.
- **Security** in case of vulnerabilities.

---

## Example:


# [v4.1.0](https://github.com/SwifterSwift/SwifterSwift/releases/tag/4.1.0)

### Added

- **UIDatePicker**
- Added `textColor` property to set and get text color of UIDatePicker. [#335](https://github.com/SwifterSwift/SwifterSwift/pull/335) by [@omaralbeik](https://github.com/omaralbeik).
- **Continuous Integration**
- Added **Danger** to continuous integration. [#252](https://github.com/SwifterSwift/SwifterSwift/pull/252) by [SD10](https://github.com/SD10).


### Changed

- **Date**
- **Breaking Change** The property `weekday` is now a get-only property. [#313](https://github.com/SwifterSwift/SwifterSwift/pull/313) by [kaphacius](https://github.com/kaphacius).

- **Array**
- `shuffle` and `shuffled` are no more constrained to Equatable. [#327](https://github.com/SwifterSwift/SwifterSwift/pull/327) by [LucianoPAlmeida](https://github.com/LucianoPAlmeida).


### Deprecated

- **String**
- `reversed() -> String` is deprecated in favor of Swift 4 new `reversed() -> ReversedCollection<String>`. [#305](https://github.com/SwifterSwift/SwifterSwift/pull/305) by [LucianoPAlmeida](https://github.com/LucianoPAlmeida).
- **Date**
- `isInThisWeek` has been renamed to `isInCurrentWeek`.


### Removed

- **UIViewController**
- **Breaking Change** Removed `navigationBar` that was causing iOS apps to crash, thanks to drewpitchford for reporting in [#243](https://github.com/SwifterSwift/SwifterSwift/issues/243). by [drewpitchford](https://github.com/drewpitchford)


### Fixed

- **Tests**
- Fixed a bug where `XCTAssertNotNil` could not handle optionals. [#188](https://github.com/SwifterSwift/SwifterSwift/pull/188). by [omaralbeik](https://github.com/omaralbeik)
74 changes: 60 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ This document contains information and guidelines about contributing to this pro
- [Asking Questions](#asking-questions)
- [Ways to Contribute](#ways-to-contribute)
- [Adding new Extensions](#adding-new-extensions)
- [Adding Tests](#adding-tests)
- [Adding documentation](#adding-documentation)
- [Adding changelog entries](#adding-changelog-entries)
- [Reporting Issues](#reporting-issues)


---


Expand All @@ -20,6 +23,7 @@ For any usage questions that are not specific to the project itself, please ask
By doing so, you'll be more likely to quickly solve your problem, and you'll allow anyone else with the same question to find the answer.
This also allows us to focus on improving the project for others.


---


Expand All @@ -32,42 +36,51 @@ You can contribute to the project in a variety of ways:
- Add missing unit tests 😅
- Fixing or reporting bugs 😱

If you're new to Open Source or Swift the SwifterSwift community is a great place to get involved
If you're new to Open Source or Swift the SwifterSwift community is a great place to get involved.

**Your contribution is always welcomed, no contribution is too small.**


---


## Adding new Extensions

Please refer to the following rules before submitting a pull request with your new extensions:

- Add your contributions to [**master branch** ](https://github.com/SwifterSwift/SwifterSwift/tree/master):
- Make sure no similar extension already exist in SwifterSwift.
- Add your contributions to [**master branch**](https://github.com/SwifterSwift/SwifterSwift/tree/master):
- by doing this we can merge new pull-requests into **master** branch as soon as they are accepted, and add them to the next releases once they are fully tested.
- Mention the original source of extension source (if possible) as a comment inside extension:

```swift
public extension SomeType {

public name: SomeType {
// https://stackoverflow.com/somepage
// .. code
}

}
```

- A pull request should only add one extension at a time.
- Do not use an existing SwifterSwift extension inside another SwifterSwift extension. All extensions should be able to be copied and pasted and work immediately without having to copy another extension.
- All extensions should follow [Swift API Design Guidelines](https://developer.apple.com/videos/play/wwdc2016/403/)
- Always declare extensions as **public**.
- All extensions names should be as clear as possible.
- All extensions should be well documented. see [Adding documentation](#adding-documentation)
- Avoid using custom classes and objects the goal for this library is to extend the standards types available natively in Swift, iOS, macOS, watchOS and tvOS.
- extensions could be:
- enums
- Properties & static properties
- Methods & static methods
- Avoid using custom classes and objects the goal for this library is to extend the standards types available natively in Swift, iOS, macOS, watchOS, tvOS and Linux.
- Extensions could be:
- Enums
- Instance properties & type properties
- Instance methods & type methods
- Initializers
- Files are named based on the type that the contained extensions extend (example: all String extensions are found in "**StringExtensions.swift**" file)
- extensions are ordered inside files in the following order:
- Structs
- All extensions should be tested. See [Adding Tests](#adding-tests) to know more.
- Files are named based on the type that the contained extensions extend.
- (example: all String extensions are found in "**StringExtensions.swift**" file)
- Extensions and tests are ordered inside files in the following order:

```swift
// MARK: - enums
Expand All @@ -85,10 +98,25 @@ public extension SomeType {}
public extension SomeType {}
```

- Please add each extension in its appropriate place in the file.

---

## Adding Tests

Please follow these guidelines before submitting a pull request with new tests:

- Every extended SwifterSwift type should have one specific subclass of XCTestCase.
- There should be a one to one relationship between methods/properties and their backing tests.
- Tests should be named using the same API of the extension it backs.
- (example: `DateExtensions` method `isBetween` is named `testIsBetween`)
- All test files are named based on the extensions which it tests.
- (example: all String extensions tests are found in "**StringExtensionsTests.swift**" file)
- The subclass should be marked as final.
- All extensions files and test files have a one to one relationship.
- (example: all tests for "**StringExtensions.swift**" are found in the "**StringExtensionsTests.swift**" file)
- SwifterSwift source files should not be added to the test target directly, but you should rather import SwifterSwift into the test target by using: @testable import SwifterSwift
- Tests are ordered inside files in the same order as extensions. See [Adding new Extensions](#adding-new-extensions) to know more.

---

## Adding documentation

Expand Down Expand Up @@ -168,15 +196,25 @@ In Xcode select a method and press `command` + `alt` + `/` to create a documenta

---


## Adding changelog entries

The [Changelog](https://github.com/SwifterSwift/SwifterSwift/blob/master/CHANGELOG.md) is a file which contains a curated, chronologically ordered list of notable changes for each version of a project. Please make sure to add a changelog entry describing your contribution to it every time there is a notable change.

The [Changelog Guidelines](https://github.com/SwifterSwift/SwifterSwift/blob/master/CHANGELOG_GUIDELINES.md) contains instructions for maintaining (or adding new entries) to the Changelog.


---


## Reporting Issues
A great way to contribute to the project is to send a detailed issue when you encounter an problem.
A great way to contribute to the project is to send a detailed issue when you encounter a problem.
We always appreciate a well-written, thorough bug report.

Check that the project issues database doesn't already include that problem or suggestion before submitting an issue.
Check that the project [issues page](https://github.com/SwifterSwift/SwifterSwift/issues) doesn't already include that problem or suggestion before submitting an issue.
If you find a match, add a quick "**+1**" or "**I have this problem too**".
Doing this helps prioritize the most common problems and requests.


**When reporting issues, please include the following:**

- What did you do?
Expand All @@ -190,3 +228,11 @@ Doing this helps prioritize the most common problems and requests.
- Demo Project (if available)

This information will help us review and fix your issue faster.


---


## [No Brown M&M's](http://en.wikipedia.org/wiki/Van_Halen#Contract_riders)

If you made it all the way to the end, bravo dear user, we love you. You can include the 🚀 emoji in the top of your ticket to signal to us that you did in fact read this file and are trying to conform to it as best as possible: `:rocket:`.
51 changes: 51 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
message('Thank you for submitting a pull request to SwifterSwift. The team will review your submission as soon as possible.')

# Checks for modified source files
source_changes_exist = !git.modified_files.grep(/Sources/).empty?

# Checks for changelog entry
no_changelog_entry = !git.modified_files.include?("CHANGELOG.md")

# Checks for tests
no_test_changes = git.modified_files.grep(/Tests/).empty?

if source_changes_exist && no_test_changes
warn('Consider adding tests for new extensions or updating existing tests for a modified SwifterSwift extension')
end

if source_changes_exist && no_changelog_entry
warn('The source files have been modified. Please consider adding a CHANGELOG entry if necessary.')
end

swiftlint.lint_files

# Checks if pull request is labeled as [WIP]
warn('This pull request is marked as Work in Progress. DO NOT MERGE!') if github.pr_title.include? "[WIP]"

# Xcode summary
def summary(platform:)
xcode_summary.report "xcodebuild-#{platform}.json"
end

def label_tests_summary(label:, platform:)
file_name = "xcodebuild-#{platform}.json"
json = File.read(file_name)
data = JSON.parse(json)
data["tests_summary_messages"].each { |message|
if !message.empty?
message.insert(1, " " + label + ":")
end
}
File.open(file_name,"w") do |f|
f.puts JSON.pretty_generate(data)
end
end

label_tests_summary(label: "iOS", platform: "ios")
label_tests_summary(label: "tvOS", platform: "tvos")
label_tests_summary(label: "macOS", platform: "macos")

summary(platform: "ios")
summary(platform: "tvos")
summary(platform: "macos")
summary(platform: "watchos")
Loading

0 comments on commit 8ec62ae

Please sign in to comment.