Skip to content

Commit

Permalink
#155 Add docs for [Input][FileReader|LineReader|FolderBrowser]Tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
njoubert-cleverage committed Jan 2, 2025
1 parent 745db03 commit 75a89e5
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 3 deletions.
9 changes: 6 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@
- [YamlWriterTask]
- File
- [FileMoverTask]
- [FileReaderTask]
- [FileReaderTask](reference/tasks/file_reader_task.md)
- [FileRemoverTask]
- [FileWriterTask]
- [FolderBrowserTask]
- [InputFolderBrowserTask]
- [FolderBrowserTask](reference/tasks/folder_browser_task.md)
- [InputFileReaderTask](reference/tasks/input_file_reader_task.md)
- [InputFolderBrowserTask](reference/tasks/input_folder_browser_task.md)
- [InputLineReaderTask](reference/tasks/input_line_reader_task.md)
- [LineReaderTask](reference/tasks/line_reader_task.md)
- Flow manipulation
- [AggregateIterableTask](reference/tasks/aggregate_iterable_task.md)
- [InputAggregatorTask](reference/tasks/input_aggregator_task.md)
Expand Down
40 changes: 40 additions & 0 deletions docs/reference/tasks/file_reader_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FileReaderTask
=============

Reads a file and return raw content as a string

Task reference
--------------

* **Service**: `CleverAge\ProcessBundle\Task\File\FileReaderTask`

Accepted inputs
---------------

Input is ignored

Possible outputs
----------------

`string`: raw content of the file.
Underlying method is [file_get_contents](https://www.php.net/manual/en/function.file-get-contents.php).

Options
-------

| Code | Type | Required | Default | Description |
|------------|----------|:---------:|----------|------------------------------------------|
| `filename` | `string` | **X** | | Path of the file to read from (absolute) |

Example
-------

```yaml
# Task configuration level
code:
service: '@CleverAge\ProcessBundle\Task\File\FileReaderTask'
options:
filename: 'path/to/file.txt'
```
43 changes: 43 additions & 0 deletions docs/reference/tasks/folder_browser_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FolderBrowserTask
=============

Reads a folder and iterate on each file, returning absolute path as string.

Task reference
--------------

* **Service**: `CleverAge\ProcessBundle\Task\File\FolderBrowserTask`
* **Iterable task**

Accepted inputs
---------------

Input is ignored

Possible outputs
----------------

`string`: absolute path of the file.
Underlying method is [Symfony Finder component](https://symfony.com/doc/current/components/finder.html).

Options
-------

| Code | Type | Required | Default | Description |
|-------------------|-------------------------------|:---------:|---------------------------|------------------------------------|
| `folder_path` | `string` | **X** | | Path of the directory to read from |
| `name_pattern` | `null` or `string` or `array` | | null | Restrict files using a pattern |
| `empty_log_level` | `string` | | Psr\Log\LogLevel::WARNING | From Psr\Log\LogLevel constants |

Example
-------

```yaml
# Task configuration level
code:
service: '@CleverAge\ProcessBundle\Task\File\FolderBrowserTask'
options:
folder_path: '%kernel.project_dir%/var/data'
```
41 changes: 41 additions & 0 deletions docs/reference/tasks/input_file_reader_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
InputFileReaderTask
=============

Reads a file and return raw content as a string

Task reference
--------------

* **Service**: `CleverAge\ProcessBundle\Task\File\InputFileReaderTask`

Accepted inputs
---------------

`string`: file path

Possible outputs
----------------

`string`: raw content of the file.
Underlying method is [file_get_contents](https://www.php.net/manual/en/function.file-get-contents.php).

Options
-------

None

Example
-------

```yaml
# Task configuration level
entry:
service: '@CleverAge\ProcessBundle\Task\File\FolderBrowserTask'
options:
folder_path: '%kernel.project_dir%/var/data'
outputs: read
read:
service: '@CleverAge\ProcessBundle\Task\File\InputFileReaderTask'
```
47 changes: 47 additions & 0 deletions docs/reference/tasks/input_folder_browser_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
InputFolderBrowserTask
=============

Reads a folder and iterate on each file, returning absolute path as string.

Task reference
--------------

* **Service**: `CleverAge\ProcessBundle\Task\File\InputFolderBrowserTask`
* **Iterable task**

Accepted inputs
---------------

`string`: folder path

Possible outputs
----------------

`string`: absolute path of the file.
Underlying method is [Symfony Finder component](https://symfony.com/doc/current/components/finder.html).

Options
-------

| Code | Type | Required | Default | Description |
|--------------------|----------|:---------:|---------|---------------------------------------|
| `base_folder_path` | `string` | | | Concatenated with input `folder_path` |

Example
-------

```yaml
# Task configuration level
entry:
service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
options:
output: '/var/data'
outputs: directory
directory:
service: '@CleverAge\ProcessBundle\Task\File\InputFolderBrowserTask'
options:
base_folder_path: '%kernel.project_dir%'
outputs: read
```
42 changes: 42 additions & 0 deletions docs/reference/tasks/input_line_reader_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
InputLineReaderTask
=============

Reads a file and iterate on each line, returning content as string. Skips empty lines.

Task reference
--------------

* **Service**: `CleverAge\ProcessBundle\Task\File\InputLineReaderTask`
* **Iterable task**

Accepted inputs
---------------

`string`: file path

Possible outputs
----------------

`string`: foreach line, it will return content as string.
Underlying method is [SplFileObject](https://www.php.net/manual/en/class.splfileobject.php).

Options
-------

None

Example
-------

```yaml
# Task configuration level
entry:
service: '@CleverAge\ProcessBundle\Task\File\FolderBrowserTask'
options:
folder_path: '%kernel.project_dir%/var/data'
outputs: read
read:
service: '@CleverAge\ProcessBundle\Task\File\InputLineReaderTask'
```
41 changes: 41 additions & 0 deletions docs/reference/tasks/line_reader_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
LineReaderTask
=============

Reads a file and iterate on each line, returning content as string. Skips empty lines.

Task reference
--------------

* **Service**: `CleverAge\ProcessBundle\Task\File\LineReaderTask`
* **Iterable task**

Accepted inputs
---------------

Input is ignored

Possible outputs
----------------

`string`: foreach line, it will return content as string.
Underlying method is [SplFileObject](https://www.php.net/manual/en/class.splfileobject.php).

Options
-------

| Code | Type | Required | Default | Description |
|------------|----------|:---------:|----------|------------------------------------------|
| `filename` | `string` | **X** | | Path of the file to read from (absolute) |

Example
-------

```yaml
# Task configuration level
code:
service: '@CleverAge\ProcessBundle\Task\File\LineReaderTask'
options:
filename: 'path/to/file.txt'
```

0 comments on commit 75a89e5

Please sign in to comment.