{"id":18676349,"url":"https://github.com/nonchalant/factoryprovider","last_synced_at":"2025-04-12T02:13:04.282Z","repository":{"id":56911055,"uuid":"136208220","full_name":"Nonchalant/FactoryProvider","owner":"Nonchalant","description":":factory: Generate boilerplate of factory Swift framework :factory:","archived":false,"fork":false,"pushed_at":"2018-10-23T07:20:21.000Z","size":74,"stargazers_count":31,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T02:12:56.955Z","etag":null,"topics":["automation","cli","factory","swift-package-manager","xcode"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nonchalant.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-05T16:54:21.000Z","updated_at":"2025-02-04T10:36:11.000Z","dependencies_parsed_at":"2022-08-21T03:20:11.005Z","dependency_job_id":null,"html_url":"https://github.com/Nonchalant/FactoryProvider","commit_stats":null,"previous_names":["nonchalant/factoryfactory"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nonchalant%2FFactoryProvider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nonchalant%2FFactoryProvider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nonchalant%2FFactoryProvider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nonchalant%2FFactoryProvider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nonchalant","download_url":"https://codeload.github.com/Nonchalant/FactoryProvider/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505925,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","cli","factory","swift-package-manager","xcode"],"created_at":"2024-11-07T09:28:54.337Z","updated_at":"2025-04-12T02:13:04.243Z","avatar_url":"https://github.com/Nonchalant.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :factory: FactoryProvider :factory:\n\n[![Build Status](https://travis-ci.com/Nonchalant/FactoryProvider.svg?branch=master)](https://travis-ci.com/Nonchalant/FactoryProvider)\n[![Version](http://img.shields.io/cocoapods/v/FactoryProvider.svg?style=flat)](http://cocoadocs.org/pods/FactoryProvider)\n[![Platform](http://img.shields.io/cocoapods/p/FactoryProvider.svg?style=flat)](http://cocoadocs.org/pods/FactoryProvider)\n[![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://raw.githubusercontent.com/Nonchalant/FactoryProvider/master/LICENSE.md)\n[![GitHub release](https://img.shields.io/github/release/Nonchalant/FactoryProvider.svg)](https://github.com/Nonchalant/FactoryProvider/releases)\n![Xcode](https://img.shields.io/badge/Xcode-10.svg)\n![Swift](https://img.shields.io/badge/Swift-4.2.svg)\n[![Swift Package Manager](https://img.shields.io/badge/Swift%20Package%20Manager-4.0.0-brightgreen.svg)](https://github.com/apple/swift-package-manager)\n\nGenerate boilerplate of factory Swift framework.\n\n\n## Requirements\n\n- **Swift 4+**\n- **Xcode 9+**\n\n\n## Platforms\n\nFactoryProvider works on the following platforms:\n\n- **iOS 8+**\n- **Mac OSX 10.9+**\n- **watchOS 2+**\n- **tvOS 9+**\n\n\n## Supports\n\n- **Enum**\n- **Struct**\n\n\n## FactoryProvider\n\n### 1. Installation\n\n#### CocoaPods\n\nFactoryProvider runtime is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your test target in your Podfile:\n\n```Ruby\npod \"FactoryProvider\"\n```\n\nAnd add the following `Run script` build phase to your test target's `Build Phases`:\n\n```Bash\n\"${PODS_ROOT}/FactoryProvider/generate\" --config .factory.yml\n```\n\nAfter running once, locate `Factories.generated.swift` and drag it into your Xcode test target group.\n\n#### .factory.yml\n\n```yml\nincludes: # paths of file or directory to generate\n  - Input/SubInput1\n  - Input/SubInput2/Source.swift\nexcludes: # paths of file or directory not to generate\n  - Input/SubInput1/SubSubInput\n  - Input/SubInput2/Source.swift\ntestables: # testable targets\n  - target1\n  - target2\noutput: output/Factories.generated.swift # path of generated file\n```\n\n### 2. Usage\n\nYou can get a instance to call `Factory\u003cTypeName\u003e.provide()`. Each properties are set to default value.\n\n```swift\nstruct Climber {\n    let name: String\n    let age: Int\n}\n\nlet climber = Factory\u003cClimber\u003e.provide()\n// Climber(name: \"\", age: 0)\n\n let optClimber = Factory\u003cClimber?\u003e.provide()\n// Optional(Climber(name: \"\", age: 0))\n\n let arrayClimber = Factory\u003c[Climber]\u003e.provide()\n// [Climber(name: \"\", age: 0)]\n```\n\n### 3. Lens\n\n`Factory\u003cTypeName\u003e.provide()` provides fixed instance. You can modify each property by Lens.\n\n#### Get\n\n```swift\nlet name = Factory\u003cClimber\u003e.provide().name or Lens\u003cClimber\u003e.name().get(Factory\u003cClimber\u003e.provide())\n// \"\"\n```\n\n#### Set\n\n```swift\nimport FactoryProvider\n\nlet climber = Factory\u003cClimber\u003e.provide() |\u003e Lens\u003cClimber\u003e.name() *~ \"Climber\"\n// Climber(name: \"Climber\", age: 0)\n```\n\n#### Modify\n\n```swift\nimport FactoryProvider\n\nlet name = Factory\u003cClimber\u003e.provide() |\u003e Lens\u003cClimber\u003e.name() *~ { \"Climber\" |\u003e { $0 + $0 } }()\n// Climber(name: \"ClimberClimber\", age: 0)\n```\n\n#### Compose\n\n```swift\nimport FactoryProvider\n\nstruct Climber {\n    let id: Id\n    let name: String\n    \n    struct Id {\n        let value: String\n    }\n}\n\nlet climber1 = Factory\u003cClimber\u003e.provide()\n// Climber(id: Id(value: \"\"), name: \"\")\n\nlet climber2 = climber1 |\u003e Lens\u003cClimber\u003e.id() * Lens\u003cClimber.Id\u003e.value() *~ \"id\"\n// Climber(id: Id(value: \"id\"), name: \"\")\n```\n\n## Notice\n\n### Generics\n\nIf you want to contains type using generics, you should use `0.4.1`.\n\n```Ruby\npod \"FactoryProvider\", '~\u003e 0.4.1'\n```\n\n\n## Libraries\n\n* [Commander](https://github.com/kylef/Commander)\n* [PathKit](https://github.com/kylef/PathKit)\n* [SourceKitten](https://github.com/jpsim/SourceKitten)\n* [StencilSwiftKit](https://github.com/SwiftGen/StencilSwiftKit)\n* [MirrorDiffKit](https://github.com/Kuniwak/MirrorDiffKit)\n\n\n## License\n\nFactoryProvider is available under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnonchalant%2Ffactoryprovider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnonchalant%2Ffactoryprovider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnonchalant%2Ffactoryprovider/lists"}