-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b68d9fd
commit d00f8c6
Showing
42 changed files
with
2,401 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Xcode | ||
# | ||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | ||
|
||
## Build generated | ||
*.xcodeproj | ||
build/ | ||
DerivedData/ | ||
|
||
## Various settings | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata/ | ||
|
||
## Other | ||
*.moved-aside | ||
*.xccheckout | ||
*.xcscmblueprint | ||
|
||
## Obj-C/Swift specific | ||
*.hmap | ||
*.ipa | ||
*.dSYM.zip | ||
*.dSYM | ||
|
||
## Playgrounds | ||
timeline.xctimeline | ||
playground.xcworkspace | ||
|
||
# Swift Package Manager | ||
# | ||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. | ||
# Packages/ | ||
Package.pins | ||
Package.resolved | ||
.build/ | ||
|
||
# CocoaPods | ||
# | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
# | ||
# Pods/ | ||
|
||
# Carthage | ||
# | ||
# Add this line if you want to avoid checking in source code from Carthage dependencies. | ||
# Carthage/Checkouts | ||
|
||
Carthage/Build | ||
|
||
# fastlane | ||
# | ||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the | ||
# screenshots whenever they are needed. | ||
# For more information about the recommended setup visit: | ||
# https://docs.fastlane.tools/best-practices/source-control/#source-control | ||
|
||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots/**/*.png | ||
fastlane/test_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
4.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
disabled_rules: # rule identifiers to exclude from running | ||
- line_length | ||
- identifier_name | ||
- type_name | ||
- large_tuple | ||
function_body_length: 50 | ||
type_name: | ||
max_length: 60 | ||
type_body_length: 400 | ||
file_length: 630 | ||
nesting: | ||
type_level: 2 | ||
function_parameter_count: 6 | ||
cyclomatic_complexity: 20 | ||
included: | ||
- Package.swift | ||
- Sources | ||
- Tests | ||
custom_rules: | ||
vertical_whitespace_return: | ||
includes: "*.swift" | ||
name: "Space above Return" | ||
regex: '\S[^{\s:|in]\n[\t ]+return' | ||
message: "Vertical whitespace required above return statement." | ||
vertical_whitespace_closing_braces: | ||
includes: "*.swift" | ||
regex: '\n[ \t]*\n[ \t]*[)}\]]' | ||
name: "Vertical Whitespace before Closing Braces" | ||
message: "Don't include vertical whitespace (empty line) before closing braces." | ||
severity: warning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
os: | ||
- linux | ||
- osx | ||
language: generic | ||
sudo: required | ||
dist: trusty | ||
osx_image: xcode10.1 | ||
services: docker | ||
|
||
before_install: | ||
- if [ $TRAVIS_OS_NAME == "linux" ]; then | ||
SWIFT_VERSION=$(<.swift-version); | ||
docker pull swift:${SWIFT_VERSION}; | ||
docker pull mongo:3.6.8; | ||
docker run -d -p 27017:27017 mongo:3.6.8; | ||
elif [ $TRAVIS_OS_NAME == "osx" ]; then | ||
rvm use 2.5.1 --install --binary --fuzzy; | ||
ruby --version; | ||
gem install bundler; | ||
bundle --version; | ||
brew update; | ||
brew install mongo-c-driver; | ||
brew install mongodb; | ||
brew services start mongodb; | ||
brew outdated swiftlint || brew upgrade swiftlint; | ||
fi | ||
|
||
install: | ||
- if [ $TRAVIS_OS_NAME == "osx" ]; then | ||
bundle install --jobs=3 --retry=3 --deployment; | ||
fi | ||
|
||
script: | ||
- if [ $TRAVIS_OS_NAME == "osx" ]; then | ||
swift --version; | ||
swift build; | ||
swift build -c release; | ||
swift test; | ||
swiftlint; | ||
else | ||
args="apt-get update | ||
&& apt-get -y install cmake | ||
&& git clone -b r1.13 https://github.com/mongodb/mongo-c-driver /tmp/libmongoc | ||
&& pushd /tmp/libmongoc | ||
&& cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr | ||
&& make -j8 install | ||
&& popd | ||
&& swift build | ||
&& swift build -c release | ||
&& swift test"; | ||
docker run --rm --net=host -v $(pwd):/app --workdir /app swift:${SWIFT_VERSION} bash -c "${args}"; | ||
fi | ||
|
||
notifications: | ||
email: | ||
on_success: never | ||
on_failure: change |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source "https://rubygems.org" | ||
|
||
gem 'bundler' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
bundler | ||
|
||
BUNDLED WITH | ||
1.17.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Asensei | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// BSONCoder.swift | ||
// FluentMongo | ||
// | ||
// Created by Valerio Mazzeo on 28/12/2018. | ||
// Copyright © 2018 Asensei Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import MongoSwift | ||
|
||
public protocol BSONCoder { | ||
|
||
static var encoder: BSONEncoder { get } | ||
|
||
static var decoder: BSONDecoder { get } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// BSONEncoder+BSONValue.swift | ||
// FluentMongo | ||
// | ||
// Created by Valerio Mazzeo on 11/12/2018. | ||
// Copyright © 2018 Asensei Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import MongoSwift | ||
|
||
public extension BSONEncoder { | ||
|
||
public func encodeBSONValue<T: Encodable>(_ value: T) throws -> BSONValue { | ||
switch value { | ||
case let value as BSONValue: | ||
return value | ||
default: | ||
// We can only use BSONEncoder to encode top-level data | ||
let wrappedData = ["value": value] | ||
let document: Document = try self.encode(wrappedData) | ||
|
||
return document["value"] ?? BSONNull() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// Document+Nested.swift | ||
// FluentMongo | ||
// | ||
// Created by Valerio Mazzeo on 06/12/2018. | ||
// Copyright © 2018 Asensei Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import MongoSwift | ||
|
||
// Review when https://jira.mongodb.org/browse/SWIFT-273 will be fixed. | ||
public extension Document { | ||
public subscript(keys: [String]) -> BSONValue? { | ||
get { | ||
guard !keys.isEmpty else { | ||
return nil | ||
} | ||
|
||
var value: BSONValue? = self | ||
|
||
for key in keys { | ||
value = (value as? Document)?[key] | ||
} | ||
|
||
return value | ||
} | ||
set { | ||
func setNewValue(for keys: [String], in document: inout Document) { | ||
guard !keys.isEmpty else { | ||
return | ||
} | ||
|
||
guard keys.count > 1 else { | ||
document[keys[0]] = newValue | ||
|
||
return | ||
} | ||
|
||
var path = keys | ||
let component = path.removeFirst() | ||
var next = document[component] as? Document ?? Document() | ||
setNewValue(for: path, in: &next) | ||
document[component] = next | ||
} | ||
|
||
setNewValue(for: keys, in: &self) | ||
} | ||
} | ||
|
||
public subscript(keys: String...) -> BSONValue? { | ||
get { | ||
return self[keys] | ||
} | ||
set { | ||
self[keys] = newValue | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// FluentMongoModel.swift | ||
// FluentMongo | ||
// | ||
// Created by Valerio Mazzeo on 06/12/2018. | ||
// Copyright © 2018 Asensei Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Fluent | ||
|
||
public protocol FluentMongoModel { | ||
|
||
associatedtype ID: Fluent.ID | ||
|
||
var _id: ID? { get set } | ||
} | ||
|
||
public extension FluentMongoModel where Self: Model { | ||
public static var idKey: WritableKeyPath<Self, ID?> { | ||
return \._id | ||
} | ||
} |
Oops, something went wrong.