Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4 from devmaximilian/rebrand
Browse files Browse the repository at this point in the history
Renamed project to Forecast
  • Loading branch information
devmaximilian authored Jan 2, 2021
2 parents 2d3a7a0 + 9509293 commit 037d83e
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 50 deletions.
12 changes: 6 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import PackageDescription

let package = Package(
name: "MetobsKit",
name: "Forecast",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
Expand All @@ -14,8 +14,8 @@ let package = Package(
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "MetobsKit",
targets: ["MetobsKit"]),
name: "Forecast",
targets: ["Forecast"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
Expand All @@ -25,10 +25,10 @@ let package = Package(
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "MetobsKit",
name: "Forecast",
dependencies: []),
.testTarget(
name: "MetobsKitTests",
dependencies: ["MetobsKit"]),
name: "ForecastTests",
dependencies: ["Forecast"]),
]
)
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# MetobsKit
# Forecast

This package is a wrapper for the PMP3g API provided by [SMHI](https://smhi.se).

### Usage

Add MetobsKit to your `Package.swift` manifest.
Add Forecast to your `Package.swift` manifest.

```swift
...
/// Append the package to the list of dependencies
dependencies: [
.package(url: "https://github.com/devmaximilian/MetobsKit.git", from: "0.4.0")
.package(url: "https://github.com/devmaximilian/Forecast.git", from: "1.0.0")
],

/// Append the library to the list of target dependencies
targets: [
.target(
name: "MyProject",
dependencies: ["MetobsKit"])
dependencies: ["Forecast"])
]
...
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Service.swift
// ForecastPublisher.swift
//
// Copyright (c) 2019 Maximilian Wendel
//
Expand Down Expand Up @@ -29,6 +29,7 @@ import class Foundation.URLSession
import struct Foundation.URLError
import struct Foundation.Data
import struct Foundation.URL
import func Foundation.pow
import protocol Combine.Publisher
import protocol Combine.Subscriber
import class Combine.PassthroughSubject
Expand Down Expand Up @@ -173,3 +174,14 @@ extension JSONDecoder {
self.dateDecodingStrategy = dateDecodingStrategy
}
}

/// An extension to add the rounded method
extension Double {
/// Rounds the `Double` to a specified precision-level (number of decimals)
/// - Note: This method is present as the forecast service only accepts a maximum of six decimals
/// - Parameter precision: The precision-level to use
fileprivate func rounded(toPrecision precision: Int) -> Double {
let multiplier: Double = pow(10, Double(precision))
return (self * multiplier).rounded() / multiplier
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import struct Foundation.Date


/// A `Forecast` is a collection of `Value`s for a set of `Parameter`s
public struct Forecast: Codable {
/// A timestamp for when the `Forecast` is valid
Expand All @@ -40,6 +41,8 @@ public struct Forecast: Codable {
} ?? .unknown
}

/// Get `Value` for a `Parameter`
/// - Parameter parameter: The `Parameter` to get `Value` for
public subscript(parameter: Parameter) -> Value {
return self.parameters.first { (value) -> Bool in
value.name == parameter
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import struct Foundation.Date


/// An `Observation` is a collection of `Forecast` instances
public struct Observation: Codable {
/// A timestamp for when the `Forecast` was approved
Expand Down
File renamed without changes.
36 changes: 0 additions & 36 deletions Sources/MetobsKit/Utils.swift

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import MetobsKit
import Forecast
import XCTest
import Combine

Expand Down
4 changes: 2 additions & 2 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import XCTest

import MetobsKitTests
import ForecastTests

var tests = [XCTestCaseEntry]()
tests += MetobsKitTests.allTests()
tests += ForecastTests.allTests()
XCTMain(tests)

0 comments on commit 037d83e

Please sign in to comment.