Skip to content

Commit 4c473a8

Browse files
Merge pull request #121
Added guidelines for creating feeds
2 parents e35e14b + f6a145e commit 4c473a8

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Creating Feeds
2+
3+
This guide uses the `JSON Lines` feed as an example.
4+
When creating a new feed, follow these steps by analogy. Do not modify the actual Json Lines feed.
5+
6+
### Core functionality
7+
8+
1. Decide on the feed type and format (for example, `JSON Lines`).
9+
2. Add the format to `Enums\FeedFormatEnum`:
10+
- The enum key must be in PascalCase (e.g., `JsonLines`).
11+
- The enum value must be the feed format in camelCase (e.g., `jsonl`).
12+
3. Create a converter in `src/Converters` using the `stubs/converter.stub` template. In that stub:
13+
- Replace `DummyNamespace` with `DragonCode\LaravelFeed\Converters`.
14+
- Replace `DummyClass` with the feed class name, e.g., `JsonLinesConverter`. The `Converter` suffix is required.
15+
- The file name must match the class name, e.g., `JsonLinesConverter.php`.
16+
4. Register your converter in `\DragonCode\LaravelFeed\Helpers\ConverterHelper::get` by analogy with the existing entries.
17+
18+
### Tests
19+
20+
1. Create example feeds under `workbench/app/Feeds`, mirroring the Json Lines example.
21+
2. Reference the newly created feed classes in `workbench/database/seeders/FeedSeeder.php`.
22+
3. Create four tests — `DefaultTest`, `InfoTest`, `RootInfoTest`, and `RootTest` — inside `tests/Feature/Feeds/Formats/*`, following the JsonLines tests as a template.
23+
4. When calling `expectFeedSnapshot` in your tests, pass the reference to your feed class and the corresponding format from `FeedFormatEnum`.
24+
5. Add a new expectation extension in `tests/Expectations.php` to validate the feed.
25+
6. Update the `expectFeedSnapshot` helper in `tests/Helpers/expects.php` to handle your new type by calling the extension method you created.
26+
7. Run the tests with `php vendor/bin/pest --filter JsonLines`, replacing `JsonLines` with the name of the folder where your tests live.
27+
8. Fix any failing tests.
28+
29+
### Adding the feed to the documentation
30+
31+
1. Add a new label in `docs/labels.list`. The key used in the `ref` parameter must follow the `format-*` pattern, where `*` is the feed format in camelCase (e.g., `jsonl`).
32+
2. Include this label in `docs/topics/supported-formats.topic`.
33+
3. Add the label to the `information` chapter in `docs/topics/elements.topic`.

0 commit comments

Comments
 (0)