The runtime value editing package
Runsquito
Runsquito is the runtime value editing package.
Screenshot
Installation
Swift Pacakge Manager
dependencies: [
.package(name: "Runsquito", path: "https://github.com/chaltteok-studio/runsquito-ios", from: "1.1.0")
]
How to use
Basic usage
Runsquito is runtime value storage.
Runsquito serve default storage. but you can create and manage it self.
To use Runsquito, you should add a Slot into Runsquito.
ValueSlotis decribe under theSlotsection.
try Runsquito.default.addSlot(
ValueSlot<Bool>(description: "This slot is test flag."),
for: "test-slot"
)
And add items to serve presets of value.
try Runsquito.default.addItem(
ValueItem(true, description: "Test slot value `true`."),
for: "test-slot-true",
in: "test-slot"
)
try Runsquito.default.addItem(
ValueItem(false, description: "Test slot value `false`."),
for: "test-slot-false",
in: "test-slot"
)
Then the slot with key “test-slot” has items true and false.
This work perform recommand once like AppDelegate.
⚠️ Point to note is Type. Slot and Item has the Type of value. So all operations of Runsquito perform validation.
If you add or set value that it’s type doesn’t match to Slot, function throw RunsquitoError.typeMismatch.
If you add any slots, you can get value of slot anywhere.
Runquito.default.value(Bool.self, for: "test-slot")
RunsquitoKit
If you use Runsquito only programmatically, you only need import Runsquito module. and you can make your own view. For your application’s feature flags, test & QA helper, etc…
If you need Runsquito value edit views, use RunsquitoKit.
RunsquitoKit has a public ViewController named RunsquitoViewController.
public final class RunsquitoViewController : UINavigationController {
public init(runsquito: Runsquito = .default)
}
It serve default features that manage Runsquito. like Screenshot section’s GIF.
Slot
Slot is the protocol that manage current value and presets of value.
Runsquito serve three Slot protocol adopt classes.
-
ValueSlotValueSlotis basic slot. It can handle all value of type. but it can’t edit. -
ParseableSlotParseableSlotis basic editable slot. It can handleParseableadopt value of type.Parseableis protocol for editing. It force implement two functions.encode&decode.public protocol Parseable { static func encode(_ value: Self) throws -> Data static func decode(_ data: Data) throws -> Self }
Primitive type
Int,Float,Double,String,Boolalready adopt that.If you want to use your own parser, you can implement it through adapt
Parseableprotocol to your models. or define new class that adoptSlot&Editableprotocols. -
CodableSlotCodableSlotis custom editable slot. It design for json codable models.If you use
Codablemodels, you can useCodableSlotto edit value throughRunsquitoeasyly.
Item
Item is value preset of slot.
Basically you could use ValueItem struct.
I’m getting ready FileItem for instantiate value by read file from bundle.
Contribution
Any ideas, issues, opinions are welcome.
License
Runsquito is available under the MIT license.