Skip to main content

A tool that looks to convert structs to class entities in swift

Project description

Creache

A poorly named tool

Purpose

The goal of this tool is to convert Swift struct types into class types that can be used with Realm Swift.

Convert files formatted like this:

struct User {
    var name: String!
    var age: Int
    var isHappy: Bool

    enum CodingKeys: String, CodingKey {
        case name, age
        case isHappy = "is_happy"
    }

    init(from decoder: Decoder) throws {
        let container = try container.decode(keyedBy: CodingKeys.self)

        name = try container.decode(String.self, forKey: .name)
        age = try container.decode(Int.self, forKey: .age)
        isHappy = try container.decode(Bool.self, forKey: .isHappy)
    }
}

to this

class User_Entity {
    @dynamic var name: String! = ''
    @dynamic var age: Int! = 0
    @dynamic var isHappy: Bool! = false
}

Features

  • Automatically rename struct to class and append `Entity to the new type
  • Automatically generate a new entity file in the directy in which this script is called
  • Automatically strip everything away thaat isn't a variable declaration

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

creache-1.3000000000000003.tar.gz (3.6 kB view details)

Uploaded Source

File details

Details for the file creache-1.3000000000000003.tar.gz.

File metadata

  • Download URL: creache-1.3000000000000003.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for creache-1.3000000000000003.tar.gz
Algorithm Hash digest
SHA256 1586ddb61fc268c0acdb1b0d88884a7a2442e749cc9434c38d24b5cdce38822d
MD5 1d312606c10a8885fd0a06739cae0c27
BLAKE2b-256 6c6b039985e37f7cd97d525af138934e7e362fb2ea5fc07cb50ecdcdd7b7806a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page