Skip to content

A Reactor extension which provides steps for working with the filesystem.

License

Notifications You must be signed in to change notification settings

ash-project/reactor_file

Repository files navigation

Logo Light

Logo Dark

Reactor.File

Build Status License: MIT Hex version badge

A Reactor extension that provides steps for working with the local filesytem.

Example

The following example uses Reactor to reverse all the files in the specified directory.

defmodule ReverseFilesInDirectory do
  use Reactor, extensions: [Reactor.File]

  input :directory

  glob :all_files do
    pattern input(:directory), transform: &Path.join(&1, "*")
  end

  map :reverse_files do
    source result(:all_files)

    read_file :read_file do
      path element(:reverse_files)
    end

    step :reverse_content do
      argument :content, result(:read_file)
      run &{:ok, &String.reverse(&1.content)}
    end

    write_file :write_file do
      path element(:reverse_files)
      contents result(:reverse_content)
    end

    return :write_file
  end

  return :reverse_files
end

Reactor.run!(ReverseFilesInDirectory, %{directory: "./to_reverse"})

Installation

If available in Hex, the package can be installed by adding reactor_file to your list of dependencies in mix.exs:

def deps do
  [
    {:reactor_file, "~> 0.18.3"}
  ]
end

Documentation for the latest release is available on HexDocs.

Licence

reactor is licensed under the terms of the MIT license. See the LICENSE file in this repository for details.

About

A Reactor extension which provides steps for working with the filesystem.

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

  •  
  •  

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages