Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
EnesKaraosman committed Aug 12, 2024
1 parent 79e1c77 commit 9caa372
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 103 deletions.
121 changes: 19 additions & 102 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
- [X] Create Example SwiftUI project to demonstrate package usage for previews
- [X] Provide a way to customize lorem in different categories (like creditCard, phoneNumber, name, price etc..) (works for auto generated init)
- [ ] Provide a way to customize loreming for the supported built-in types (to completely determine what to receive for the lorem data)
- [ ] Improve diagnostic
- [ ] Implement unit test

---
Expand All @@ -38,116 +37,34 @@ Then use `StructName.lorem()` or `ClassName.lorem()` or `EnumName.lorem()`. Basi


```swift
import LoremSwiftify

@LoremSwiftify
class Book {
let name: String
let published: Date
let author: Author

init(name: String, published: Date, author: Author) {
self.name = name
self.published = published
self.author = author
}

extension ContentView {
@LoremSwiftify
class Author {
let name: String
let surname: String
var nickName: String?
let age: Int

init(_ name: String, surname: String, nickName: String? = nil, age: Int) {
self.name = name
self.surname = surname
self.nickName = nickName
self.age = age
}
}
// Expands
extension Book.Author: LoremIpsumize {
public static func lorem() -> Self {
Book.Author(
_: .lorem(),
surname: .lorem(),
nickName: nil,
age: .lorem()
) as! Self
}
}
}
// Expands
extension Book: LoremIpsumize {
public static func lorem() -> Self {
Book(
name: .lorem(),
published: .lorem(),
author: .lorem()
) as! Self
}
}

print(Book.lorem())
struct Display {
let developers: [Developer]

@LoremSwiftify
struct Hotel {
@Lorem(.string(.name))
let name: String

@Lorem(.string(.phoneNumber))
let phoneNumber: String
@LoremSwiftify
struct Developer: Identifiable {
let id: String = UUID().uuidString

@Lorem(.url(.website))
let website: URL
@Lorem(.string(.name))
let name: String

let rooms: [Room]
@Lorem(.string(.email))
let email: String

@LoremSwiftify
struct Room {
let id: UUID
let capacity: Capacity
@Lorem(.string(.phoneNumber))
let phoneNumber: String

@Lorem(.url(.image))
let image: URL
@Lorem(.url(.image))
let imageURL: URL

@LoremSwiftify
enum Capacity: Int {
case one = 1
case two = 2
case three = 3
case four = 4
}
// Expands
extension Hotel.Room.Capacity: LoremIpsumize {
public static func lorem() -> Self {
Hotel.Room.Capacity.one
}
}
}
// Expands
extension Hotel.Room: LoremIpsumize {
public static func lorem() -> Self {
Hotel.Room(
id: .lorem(),
capacity: .lorem(),
image: .lorem(.url(.image))
)
@Lorem(.url(.website))
let profileURL: URL
}
}
}
// Expands
extension Hotel: LoremIpsumize {
public static func lorem() -> Self {
Hotel(
name: .lorem(.string(.name)),
phoneNumber: .lorem(.string(.phoneNumber)),
website: .lorem(.url(.website)),
rooms: .lorem()
)
}
}

print(Hotel.lorem())
#Preview {
ContentView(display: .lorem())
}
```
2 changes: 1 addition & 1 deletion Tests/LoremSwiftsumizeTests/TestUtils/MacroTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import LoremSwiftifyMacros
class MacroTestCase: XCTestCase {
override func invokeTest() {
#if canImport(LoremSwiftifyMacros)
withMacroTesting(isRecording: false, macros: ["LoremSwiftifyMacros": LoremSwiftifyMacro.self]) {
withMacroTesting(record: false, macros: ["LoremSwiftifyMacros": LoremSwiftifyMacro.self]) {
super.invokeTest()
}
#else
Expand Down

0 comments on commit 9caa372

Please sign in to comment.