Skip to content

Commit 1440cb9

Browse files
committed
Added UserService, UserServiceProtocol
1 parent a223a09 commit 1440cb9

File tree

6 files changed

+260
-0
lines changed

6 files changed

+260
-0
lines changed

.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at sascha.muellner@gmail.com. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

MultiUser.podspec

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'MultiUser'
3+
s.version = '1.0.0'
4+
s.summary = 'MultiUser handling for applications.'
5+
s.homepage = 'https://github.com/smuellner/MultiUser-for-swift'
6+
s.license = { type: 'Apache', file: 'LICENSE' }
7+
s.author = { 'smuellner' => 'sascha.muellner@gmail.com' }
8+
s.source = { :git => "https://github.com/smuellner/MultiUser-for-swift.git", :tag => s.version.to_s }
9+
10+
s.swift_version = '5.0'
11+
s.source_files = 'Sources/**/*.{swift,h}'
12+
13+
s.ios.deployment_target = '13.0'
14+
s.osx.deployment_target = '10.15'
15+
s.watchos.deployment_target = '6.0'
16+
s.tvos.deployment_target = '13.0'
17+
end

Package.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// swift-tools-version:5.1
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "MultiUser",
8+
platforms: [ .iOS(SupportedPlatform.IOSVersion.v13),
9+
.macOS(SupportedPlatform.MacOSVersion.v10_15),
10+
.tvOS(SupportedPlatform.TVOSVersion.v13),
11+
.watchOS(SupportedPlatform.WatchOSVersion.v6)
12+
],
13+
products: [
14+
// Products define the executables and libraries produced by a package, and make them visible to other packages.
15+
.library(
16+
name: "MultiUser",
17+
targets: ["MultiUser"]),
18+
],
19+
dependencies: [
20+
// Dependencies declare other packages that this package depends on.
21+
// .package(url: /* package url */, from: "1.0.0"),
22+
],
23+
targets: [
24+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
25+
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
26+
.target(
27+
name: "MultiUser",
28+
dependencies: []),
29+
.testTarget(
30+
name: "MultiUserTests",
31+
dependencies: ["MultiUser"]),
32+
]
33+
)
34+

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
### MultiUser handling for swift
2+
3+
MultiUser is **created and maintaned with ❥** by Sascha Muellner.
4+
5+
---
6+
7+
[![Travis CI](https://travis-ci.org/smuellner/MultiUser-for-swift.svg?branch=master)](https://travis-ci.org/smuellner/MultiUser-for-swift)
8+
![Platforms](https://img.shields.io/badge/platform-iOS%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux-lightgrey.svg)
9+
![version](https://img.shields.io/badge/version-1.0-brightgreen.svg)
10+
[![Swift Version](https://img.shields.io/badge/swift-5.1-orange.svg?style=flat)](https://developer.apple.com/swift)
11+
[![SPM compatible](https://img.shields.io/badge/SPM-compatible-orange.svg?style=flat)](https://github.com/apple/swift-package-manager)
12+
[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
13+
14+
15+
## Requirements
16+
17+
The latest version of MultiUser requires:
18+
19+
- Swift 5+
20+
- iOS 13+
21+
- Xcode 11+
22+
23+
## Installation
24+
25+
### Swift Package Manager
26+
Using SPM add the following to your dependencies
27+
28+
``` 'MultiUser', 'master', 'https://github.com/smuellner/MultiUser-for-swift.git' ```
29+
30+
### CocoaPods
31+
Using CocoaPods add the following to your Podfile:
32+
33+
```pod 'MultiUser-for-Swift', '~> 1.0.1'```
34+
35+
### What?
36+
This is a **Swift** package with support for iOS/macOS/tvOS/watchOS that allows to store user releated data for multiple users of an application.
37+
38+
### How to use?
39+
40+
#### Service
41+
42+
The **UserService** cares for the whole user handling and implements the **UserServiceProtocol**.
43+
To allow for access throughout your application place the **UserService** in a shared instance like the Application Delegate or use a dependency injection framework like **Swinject**.
44+
45+
46+
```swift
47+
48+
let userService = UserService()
49+
50+
51+
```
52+
53+
54+
#### User
55+
56+
Retrieve a list of all users:
57+
58+
```swift
59+
60+
let userService = UserService()
61+
62+
print(userService.allUsers)
63+
//
64+
65+
```
66+
67+
68+
Create a user
69+
70+
```swift
71+
72+
let user = userService.createUser()
73+
user.username = ""
74+
user.firstname = ""
75+
user.lastname = ""
76+
77+
userService.saveUser(user)
78+
79+
```
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// UserService.swift
3+
//
4+
//
5+
// Created by Sascha Müllner on 29.02.20.
6+
//
7+
8+
import Foundation
9+
10+
class UserService : UserServiceProtocol {
11+
12+
private var _currentUser :User?
13+
14+
func create() -> User {
15+
let user = User()
16+
return user
17+
}
18+
19+
func save(user: User) {
20+
21+
}
22+
23+
func delete(user: User) {
24+
25+
}
26+
27+
var all: [User] {
28+
get {
29+
return []
30+
}
31+
}
32+
33+
var hasUsers: Bool {
34+
get {
35+
return self.all.count > 0
36+
}
37+
}
38+
39+
var current: User? {
40+
get {
41+
return _currentUser
42+
}
43+
set(user) {
44+
_currentUser = user
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)