77ZDLLUTFQ3L3FELAWZQTOG5DUPINOXV5VYLEYBEONDOW2BSVZJAC defmodule Esperantisto.MixProject douse Mix.Projectdef project do[app: :esperantisto,version: "0.1.0",elixir: "~> 1.11",start_permanent: Mix.env() == :prod,deps: deps()]enddef application do[extra_applications: [:logger],mod: {Esperantisto.Application, []}]enddefp deps do[]endend
defmodule Esperantisto do@moduledoc """Documentation for `Esperantisto`."""@doc """Hello world.## Examplesiex> Esperantisto.hello():world"""def hello do:worldendend
defmodule Esperantisto.Text do@priv_dir Application.app_dir(:esperantisto, "priv/books")def get_files() doFile.ls!(@priv_dir)enddef iter_files() doget_files()|> Stream.map(fn file -> File.stream!(Path.join(@priv_dir, file)) end)|> Stream.map(fn stream -> process_book(stream) end)enddefp process_book(stream) dostream|> Stream.transform(&parse_title/1, fn line, parser ->if parser == nil do{:halt, nil}elsecase parser.(line) do{nil, new_parser} -> {[], new_parser}{value, new_parser} -> {[value], new_parser}endendend)|> Stream.take(50)|> Enum.to_list()enddefp parse_title("Title: " <> title = _line) do{{:title, title}, &parse_author/1}enddefp parse_title(_) do{nil, &parse_title/1}enddefp parse_author("Author: " <> name = _line) do{{:author, name}, &identity/1}enddefp parse_author(_) do{nil, &parse_author/1}enddefp identity(line) do{line, &identity/1}endend
defmodule Esperantisto.Application do# See https://hexdocs.pm/elixir/Application.html# for more information on OTP Applications@moduledoc falseuse Application@impl truedef start(_type, _args) dochildren = [# Starts a worker by calling: Esperantisto.Worker.start_link(arg)# {Esperantisto.Worker, arg}]# See https://hexdocs.pm/elixir/Supervisor.html# for other strategies and supported optionsopts = [strategy: :one_for_one, name: Esperantisto.Supervisor]Supervisor.start_link(children, opts)endend
# Used by "mix format"[inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]]