Skip to content

Commit 57e4247

Browse files
stephencelismbrandonw
authored andcommitted
🎁 NonEmpty
0 parents  commit 57e4247

39 files changed

+2086
-0
lines changed

.circleci/config.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: 2
2+
3+
jobs:
4+
build:
5+
macos:
6+
xcode: "9.3.0"
7+
8+
steps:
9+
- checkout
10+
11+
- run:
12+
name: Mac Info
13+
command: system_profiler SPSoftwareDataType
14+
15+
- run:
16+
name: Simulator Info
17+
command: instruments -s devices
18+
19+
- run:
20+
name: Run iOS tests
21+
command: make test-ios
22+
environment:
23+
SNAPSHOT_ARTIFACTS: $CIRCLE_ARTIFACTS
24+
25+
- run:
26+
name: Run macOS tests
27+
command: make test-macos
28+
environment:
29+
SNAPSHOT_ARTIFACTS: $CIRCLE_ARTIFACTS
30+
31+
- run:
32+
name: Run Swift tests
33+
command: make test-swift
34+
environment:
35+
SNAPSHOT_ARTIFACTS: $CIRCLE_ARTIFACTS

.gitignore

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Xcode
2+
#
3+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4+
5+
## Build generated
6+
build/
7+
DerivedData/
8+
9+
## Various settings
10+
*.pbxuser
11+
!default.pbxuser
12+
*.mode1v3
13+
!default.mode1v3
14+
*.mode2v3
15+
!default.mode2v3
16+
*.perspectivev3
17+
!default.perspectivev3
18+
xcuserdata/
19+
20+
## Other
21+
*.moved-aside
22+
*.xccheckout
23+
*.xcscmblueprint
24+
25+
## Obj-C/Swift specific
26+
*.hmap
27+
*.ipa
28+
*.dSYM.zip
29+
*.dSYM
30+
31+
## Playgrounds
32+
timeline.xctimeline
33+
playground.xcworkspace
34+
35+
# Swift Package Manager
36+
#
37+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
38+
# Packages/
39+
# Package.pins
40+
.build/
41+
42+
# CocoaPods
43+
#
44+
# We recommend against adding the Pods directory to your .gitignore. However
45+
# you should judge for yourself, the pros and cons are mentioned at:
46+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
47+
#
48+
# Pods/
49+
50+
# Carthage
51+
#
52+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
53+
# Carthage/Checkouts
54+
55+
Carthage/Build
56+
57+
# fastlane
58+
#
59+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
60+
# screenshots whenever they are needed.
61+
# For more information about the recommended setup visit:
62+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
63+
64+
fastlane/report.xml
65+
fastlane/Preview.html
66+
fastlane/screenshots
67+
fastlane/test_output
68+
69+
.DS_Store

.sourcery-templates/LinuxMain.stencil

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import XCTest
2+
3+
{{ argument.testimports }}
4+
{% for type in types.classes|based:"XCTestCase" %}
5+
{% if not type.annotations.disableTests %}extension {{ type.name }} {
6+
static var allTests: [(String, ({{ type.name }}) -> () throws -> Void)] = [
7+
{% for method in type.methods %}{% if method.parameters.count == 0 and method.shortName|hasPrefix:"test" %} ("{{ method.shortName }}", {{ method.shortName }}){% if not forloop.last %},{% endif %}
8+
{% endif %}{% endfor %}]
9+
}
10+
{% endif %}{% endfor %}
11+
12+
// swiftlint:disable trailing_comma
13+
XCTMain([
14+
{% for type in types.classes|based:"XCTestCase" %}{% if not type.annotations.disableTests %} testCase({{ type.name }}.allTests),
15+
{% endif %}{% endfor %}])
16+
// swiftlint:enable trailing_comma

.swift-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.1

.travis.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
os:
2+
- linux
3+
env:
4+
language: generic
5+
sudo: required
6+
dist: trusty
7+
install:
8+
- if [ $TRAVIS_OS_NAME = linux ]; then
9+
eval "$(curl -sL https://swiftenv.fuller.li/install.sh)";
10+
fi
11+
script:
12+
- swift test

CODE_OF_CONDUCT.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
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.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
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.
28+
29+
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.
30+
31+
## Scope
32+
33+
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.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. 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.
38+
39+
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.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

Development.xcconfig

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
OTHER_SWIFT_FLAGS=$(inherited) -Xfrontend -warn-long-expression-type-checking=100
2+
IPHONEOS_DEPLOYMENT_TARGET=8.0
3+
MACOSX_DEPLOYMENT_TARGET=10.9

Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM norionomura/swift:412
2+
3+
WORKDIR /package
4+
5+
COPY . ./
6+
7+
RUN swift package resolve
8+
RUN swift package clean
9+
CMD swift test --parallel

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Point-Free, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
imports = \
2+
@testable import NonEmptyTests;
3+
4+
xcodeproj:
5+
swift package generate-xcodeproj --xcconfig-overrides=Development.xcconfig
6+
7+
linux-main:
8+
sourcery \
9+
--sources ./Tests/ \
10+
--templates ./.sourcery-templates/ \
11+
--output ./Tests/ \
12+
--args testimports='$(imports)' \
13+
&& mv ./Tests/LinuxMain.generated.swift ./Tests/LinuxMain.swift
14+
15+
test-linux: linux-main
16+
docker build --tag nonempty-testing . \
17+
&& docker run --rm nonempty-testing
18+
19+
test-macos:
20+
set -o pipefail && \
21+
xcodebuild test \
22+
-scheme NonEmpty-Package \
23+
-destination platform="macOS" \
24+
| xcpretty
25+
26+
test-ios:
27+
set -o pipefail && \
28+
xcodebuild test \
29+
-scheme NonEmpty-Package \
30+
-destination platform="iOS Simulator,name=iPhone 8,OS=11.3" \
31+
| xcpretty
32+
33+
test-swift:
34+
swift test
35+
36+
test-all: test-linux test-mac test-ios

NonEmpty.playground/Contents.swift

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import NonEmpty
2+
3+
let xs = NonEmptyArray(42, 1, 3, 2)
4+
5+
xs
6+
.sorted()
7+
.map(NonEmptyString.init)
8+
.joined(separator: ",")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<playground version='5.0' target-platform='macos' executeOnSourceChanges='false'>
3+
<timeline fileName='timeline.xctimeline'/>
4+
</playground>

NonEmpty.podspec

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Pod::Spec.new do |s|
2+
s.name = "NonEmpty"
3+
s.version = "0.1.0"
4+
s.summary = "A compile-time guarantee that a collection contains a value."
5+
6+
s.description = <<-DESC
7+
We often work with collections that should never be empty, but the type system makes no such guarantees, so we're forced to handle that empty case, often with if and guard statements. NonEmpty is a lightweight type that can transform any collection type into a non-empty version.
8+
DESC
9+
10+
s.homepage = "https://github.com/pointfreeco/swift-nonempty"
11+
12+
s.license = "MIT"
13+
14+
s.authors = {
15+
"Stephen Celis" => "[email protected]",
16+
"Brandon Williams" => "[email protected]"
17+
}
18+
s.social_media_url = "https://twitter.com/pointfreeco"
19+
20+
s.source = {
21+
:git => "https://github.com/pointfreeco/swift-nonempty.git",
22+
:tag => "0.1.0"
23+
}
24+
25+
s.ios.deployment_target = "8.0"
26+
s.osx.deployment_target = "10.9"
27+
s.tvos.deployment_target = "9.0"
28+
s.watchos.deployment_target = "2.0"
29+
30+
s.source_files = "Sources", "Sources/**/*.swift"
31+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<plist version="1.0">
3+
<dict>
4+
<key>CFBundleDevelopmentRegion</key>
5+
<string>en</string>
6+
<key>CFBundleExecutable</key>
7+
<string>$(EXECUTABLE_NAME)</string>
8+
<key>CFBundleIdentifier</key>
9+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
10+
<key>CFBundleInfoDictionaryVersion</key>
11+
<string>6.0</string>
12+
<key>CFBundleName</key>
13+
<string>$(PRODUCT_NAME)</string>
14+
<key>CFBundlePackageType</key>
15+
<string>BNDL</string>
16+
<key>CFBundleShortVersionString</key>
17+
<string>1.0</string>
18+
<key>CFBundleSignature</key>
19+
<string>????</string>
20+
<key>CFBundleVersion</key>
21+
<string>$(CURRENT_PROJECT_VERSION)</string>
22+
<key>NSPrincipalClass</key>
23+
<string></string>
24+
</dict>
25+
</plist>
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<plist version="1.0">
3+
<dict>
4+
<key>CFBundleDevelopmentRegion</key>
5+
<string>en</string>
6+
<key>CFBundleExecutable</key>
7+
<string>$(EXECUTABLE_NAME)</string>
8+
<key>CFBundleIdentifier</key>
9+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
10+
<key>CFBundleInfoDictionaryVersion</key>
11+
<string>6.0</string>
12+
<key>CFBundleName</key>
13+
<string>$(PRODUCT_NAME)</string>
14+
<key>CFBundlePackageType</key>
15+
<string>FMWK</string>
16+
<key>CFBundleShortVersionString</key>
17+
<string>1.0</string>
18+
<key>CFBundleSignature</key>
19+
<string>????</string>
20+
<key>CFBundleVersion</key>
21+
<string>$(CURRENT_PROJECT_VERSION)</string>
22+
<key>NSPrincipalClass</key>
23+
<string></string>
24+
</dict>
25+
</plist>

0 commit comments

Comments
 (0)