paulsamuels / SBConstants

MIT License
311 stars 28 forks source link

Query format for YAML file #22

Closed Ashton-W closed 9 years ago

Ashton-W commented 9 years ago

What is the format of the YAML file containing queries?

Perhaps the default query should be moved to YAML for consistency and reference.

paulsamuels commented 9 years ago

Hey

The default is stored in identifiers.yml

It's stored as mappings from xib class to identifier name.

The default looks like

---
segue: identifier
tableViewCell: reuseIdentifier
collectionViewCell: reuseIdentifier
view: restorationIdentifier
? - navigationController
  - viewController
  - tableViewController
  - collectionViewController
: - storyboardIdentifier
  - restorationIdentifier

What actually happens upon parsing in options.rb is both the key and value are enumerated as arrays (converting to an Array if required). This enables a single xib class to have multiple identifiers to look for. It also enables multiple xib class' to have the same identifiers without duplicating it in the yaml.


In the default segue, tableViewCell, collectionViewCell, view are all only looking for one identifier each. There is some duplication for tableViewCell and collectionViewCell and they could be mapped into a dictionary - I must not have been paying attention when I merged that.

Then navigationController, viewController, tableViewController and collectionViewController all look for two identifiers

I'm not a massive fan of yaml syntax but I'm sure at the time I must have tried most other common formats and gone for this one because of it's lack of duplication and bracket noise

Ashton-W commented 9 years ago

Didn't see that file, thanks!