Skip to content

Commit

Permalink
Fridge 0.8.9
Browse files Browse the repository at this point in the history
 - Make Freezer and Grabber private (#32)
 - Rework README (#30)
 - Updated Guides, README and added separate Fridge diagram quick manual
 - Updated broken links across the documentation. Fixed incorrect graph display in diagram file
 - Removed unneeded debug outputs (#29)

Closes #29
Closes #30
Closes #32
  • Loading branch information
vexy committed May 20, 2022
1 parent 96a663b commit 14e8f2e
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 23 deletions.
46 changes: 46 additions & 0 deletions Guides/Fridge.diagram.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Fridge architecture
Diagram below can be used to depict the structural layout of the Fridge library.

```mermaid
graph TD
A[Fridge] --> B
B{Struct}
B --> E(Encodable)
B --> D(Decodable)
E --> |identifier|freeze
D --> |URL|F[grab]
D --> |identifier|G[unfreeze]
```

## Network interface perspective
You can observer `Fridge` interface from the point of network in following way:

```mermaid
graph TD
N[Network] ==> 1(Fridge)
1 --> |url|grab
```

By providing `url` or `urlRequest` objects (and conforming your struct to `Encodable`) you can `grab` network objects easily.

Keywords:
**`url`**, **`grab`**

## Storage interface perspective
```mermaid
graph TD
S[Storage] ==> F
F{Fridge}
F --> |identifier|U(unfreeze)
F --> |identifier|R(freeze)
B[BSON]
U --> B
R --> B
```

Keywords:
**`identifier`**, **`freeze`**, **`unfreeze`**

---
Copyright (c) by Vexy 2022
Effective since: `2022-03-13`
4 changes: 2 additions & 2 deletions Guides/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ In short, following guide describes **how to**:
- [load/store an object](#data-handling)
- [handle errors](#error-handling)


Checkout architecture overview in separate [diagram](Guides/Fridge.diagram.md) file.
For more information, you can always check provided, `in-code` documentation.

---
Expand Down Expand Up @@ -96,4 +96,4 @@ If your store identifier cannot be found `Fridge` will throw an Error. Check the
## ⛔️ Error Handling
Each of the Fridge method, is internally marked with `throws` keyword. Here's what you can deal with:

// list all errors here
// list all errors here
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
</h1>

<p align="center">
<b>Fridge</b> - perhaps the silliest <code>Swift5 async/await</code> fetch-and-store implementation you'll ever see !<br>
Let your fancy <code>struct</code>(s) raise and shine again, allowing you to focus on 💬 🥊🤖⭐️🗝 <i>stuff</i>.<br><br>
<code>Fridge</code> - <b>Lightweight</b>, <b>asnyc</b> and <i>extreeemely simple</i> to use fetch or store mechanism.</b>
<br>
Let your fancy <code>struct</code>(s) raise and shine again, while focusing on 💬 🥊🤖⭐️🗝 <i>other important stuff</i>.<br><br>
</p>
<br><br>

<p align="center">
<a href="https://stackexchange.com/users/215166"><img src="https://stackexchange.com/users/flair/215166.png?theme=clean" width="208" height="58" alt="profile for Vexy on Stack Exchange, a network of free, community-driven Q&amp;A sites" title="profile for Vexy on Stack Exchange, a network of free, community-driven Q&amp;A sites">
</a>
</p>
<br>
<table style="width:100%">
<!-- <tr>
<th># HEADERS HIDDEN #</th>
Expand Down Expand Up @@ -47,10 +44,6 @@
<img src="https://img.shields.io/github/languages/code-size/vexy/fridge?color=g">
</p>
<br><br>
<p align="center">
<code>Fridge</code> - <b>Lightweight</b>, <b>fast</b> and extreeemely <b>simple to use fetch or store mechanism.</b><br>
</p>
<br><br>

# 💠 Library interface
`Fridge` is a freezing device ❄️. It has to keep things cool enough, exposing following icy interface:
Expand Down Expand Up @@ -100,7 +93,7 @@ Aside from discovering how to remove that _shocking build error_ from the 👆 c
- (**COMMING SOON**) _fine grain_ fetch or store process
- dirtly little secrets about the Fridge

Oh yeah, `Fridge` can ofer way way more, _but it's alllll in the **Docs** _ 🥴
Oh yeah, `Fridge` can ofer way way more, _but it's alllll in the **Docs**_. Even the [architecture](Guides/Fridge.diagram.md) diagrams... ∰ 🥴

# Installation
Using `Swift Package Manager` is by far the sexiest way to install silly `Fridge`.
Expand Down Expand Up @@ -168,8 +161,20 @@ Don't be affraid to start any [discussions](https://github.com/vexy/Fridge/discu
[Issues](https://github.com/vexy/Fridge/issues) section is a good way to start, if you stumble upon the way.

---
(**FRIDGE IS UNDER ACTIVE DEVELOPMENT ALMOST REACHING v1.0**)
Fridge **BETA** release : *v0.8.8 ( UTC2022-03-03 )*

<p align="center">
<b>Fridge</b> - perhaps the silliest <code>Swift5 async/await</code> fetch-and-store implementation you'll ever see !<br>
</p>


**FRIDGE IS UNDER ACTIVE DEVELOPMENT ALMOST REACHING v1.0**
Fridge **BETA** release : *v0.8.9 ( UTC2022-05-20 )*

Copyright © 2016 Veljko Tekelerović | MIT license
**PGP:** `6302 D860 B74C BD34 6482 DBA2 5187 66D0 8213 DBC0`
**PGP:** `6302D860 B74CBD34 6482DBA2 518766D0 8213DBC0`

<p align="center">
<a href="https://stackexchange.com/users/215166"><img src="https://stackexchange.com/users/flair/215166.png?theme=clean" width="208" height="58" alt="profile for Vexy on Stack Exchange, a network of free, community-driven Q&amp;A sites" title="profile for Vexy on Stack Exchange, a network of free, community-driven Q&amp;A sites">
</a>
</p>
<br>
3 changes: 0 additions & 3 deletions Sources/Fridge/BSONConverter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
//import SwiftBSON
import BSONCoder

/// Utility class providing write/read BSON functionality
Expand All @@ -23,15 +22,13 @@ final class BSONConverter {
let rawBSONData = try BSONEncoder().encode(object).toData() //will throw further

// now flush the data to a file
print("Writing to: \(_rawFilePath)")
try rawBSONData.write(to: _rawFilePath)
}

/// Reads object from compartment data storage and returns Foundation counterpart
func read<T: Decodable>() throws -> T { //} -> BSONDoc {
// prepare input stream
let rawBSONData = try Data(contentsOf: _rawFilePath)
print("Reading from: \(_rawFilePath)")

let realObject = try BSONDecoder().decode(T.self, from: rawBSONData)
return realObject
Expand Down
3 changes: 1 addition & 2 deletions Sources/Fridge/Freezer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import Foundation

// MARK: -
final class Freezer {
final internal class Freezer {
/// Freezes an object into Fridge persistant storage. Any new object will overwrite previously stored object
func freeze<T: Encodable>(object: T, identifier: String) throws { //async ?
do {
Expand Down Expand Up @@ -59,7 +59,6 @@ final class Freezer {
let storedObject: T = try reader.read()
return storedObject
} catch {
print("THROW HAPPENED")
throw FreezingErrors.dataReadingError
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Fridge/Grabber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Foundation

@available(macOS 12.0, *)
@available(iOS 15.0, *)
final class Grabber {
final internal class Grabber {
func grab<D: Decodable>(from url: URL) async throws -> D {
do {
let (data, _) = try await URLSession.shared.data(from: url)
Expand Down

0 comments on commit 14e8f2e

Please sign in to comment.