diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fd9d8a..c500a92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -# Created with GitHubActions version 0.2.27 +# Created with GitHubActions version 0.3.6 name: CI env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -8,60 +8,33 @@ on: jobs: linux: name: Test on Ubuntu (Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }}) - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 strategy: matrix: - elixir: - - '1.13.4' - - '1.14.5' - - '1.15.8' - - '1.16.3' - - '1.17.3' - - '1.18.0' - otp: - - '22.3' - - '23.3' - - '24.3' - - '25.3' - - '26.2' - - '27.2' - exclude: - - elixir: '1.13.4' + include: + - elixir: '1.18.4' + otp: '28.1' + coverage: true + lint: true + - elixir: '1.18.4' + otp: '27.3' + - elixir: '1.18.4' otp: '26.2' - - elixir: '1.13.4' - otp: '27.2' - - elixir: '1.14.5' - otp: '22.3' - - elixir: '1.14.5' - otp: '27.2' - - elixir: '1.15.8' - otp: '22.3' - - elixir: '1.15.8' - otp: '23.3' - - elixir: '1.15.8' - otp: '27.2' - - elixir: '1.16.3' - otp: '22.3' - - elixir: '1.16.3' - otp: '23.3' - - elixir: '1.16.3' - otp: '27.2' - - elixir: '1.17.3' - otp: '22.3' - - elixir: '1.17.3' - otp: '23.3' + - elixir: '1.18.4' + otp: '25.3' - elixir: '1.17.3' + otp: '25.3' + - elixir: '1.16.3' otp: '24.3' - - elixir: '1.18.0' - otp: '22.3' - - elixir: '1.18.0' - otp: '23.3' - - elixir: '1.18.0' + - elixir: '1.15.8' + otp: '24.3' + - elixir: '1.14.5' otp: '24.3' steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Elixir + id: setup-beam uses: erlef/setup-beam@v1 with: elixir-version: ${{ matrix.elixir }} @@ -70,18 +43,33 @@ jobs: uses: actions/cache@v4 with: path: deps - key: deps-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + key: "deps\ + -${{ runner.os }}\ + -${{ matrix.elixir }}\ + -${{ matrix.otp }}\ + -${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}\ + -${{ steps.setup-beam.outputs.setup-beam-version }}" - name: Restore _build uses: actions/cache@v4 with: path: _build - key: _build-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + key: "_build\ + -${{ runner.os }}\ + -${{ matrix.elixir }}\ + -${{ matrix.otp }}\ + -${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}\ + -${{ steps.setup-beam.outputs.setup-beam-version }}" - name: Restore test/support/plts + if: ${{ matrix.lint }} uses: actions/cache@v4 with: path: test/support/plts - key: test/support/plts-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} - if: ${{ contains(matrix.elixir, '1.18.0') && contains(matrix.otp, '27.2') }} + key: "test/support/plts\ + -${{ runner.os }}\ + -${{ matrix.elixir }}\ + -${{ matrix.otp }}\ + -${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}\ + -${{ steps.setup-beam.outputs.setup-beam-version }}" - name: Get dependencies run: mix deps.get - name: Compile dependencies @@ -89,20 +77,20 @@ jobs: - name: Compile project run: MIX_ENV=test mix compile --warnings-as-errors - name: Check unused dependencies - if: ${{ contains(matrix.elixir, '1.18.0') && contains(matrix.otp, '27.2') }} + if: ${{ matrix.lint }} run: mix deps.unlock --check-unused - name: Check code format - if: ${{ contains(matrix.elixir, '1.18.0') && contains(matrix.otp, '27.2') }} + if: ${{ matrix.lint }} run: mix format --check-formatted - name: Lint code - if: ${{ contains(matrix.elixir, '1.18.0') && contains(matrix.otp, '27.2') }} + if: ${{ matrix.lint }} run: mix credo --strict - name: Run tests + if: ${{ !matrix.coverage }} run: mix test - if: ${{ !(contains(matrix.elixir, '1.18.0') && contains(matrix.otp, '27.2')) }} - name: Run tests with coverage + if: ${{ matrix.coverage }} run: mix coveralls.github - if: ${{ contains(matrix.elixir, '1.18.0') && contains(matrix.otp, '27.2') }} - name: Static code analysis + if: ${{ matrix.lint }} run: mix dialyzer --format github --force-check - if: ${{ contains(matrix.elixir, '1.18.0') && contains(matrix.otp, '27.2') }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 134512d..55db0d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ # Changelog -## 1.1.2 - dev +## 1.2.0 - dev + ++ Changes for Elixir 1.19 ++ Required Elixir version set to `~> 1.14` ++ Clean up `extra_applications` -+ Clean up `extra_applications`. ## 1.1.1 - 2024/11/15 @@ -53,7 +56,7 @@ have been removed from the argument list and moved to the options. + Add `Rewrite.dot_formatter/1/2` to set and get formatters. -+ Add `Rewrite.format/2` and `Rewrite.fromat!/2` to format a project. ++ Add `Rewrite.format/2` and `Rewrite.format!/2` to format a project. + Add `Rewrite.format_source/3` to format a source in a project. diff --git a/lib/rewrite.ex b/lib/rewrite.ex index 8bd52ed..051b801 100644 --- a/lib/rewrite.ex +++ b/lib/rewrite.ex @@ -2,27 +2,27 @@ defmodule Rewrite do @moduledoc """ `Rewrite` is a tool for modifying, adding and removing files in a `Mix` project. - The package is intended for use in `Mix` tasks. `Rewrite` itself uses functions - provided by `Mix`. + The package is intended for use in `Mix` tasks. `Rewrite` itself uses functions + provided by `Mix`. - With `Rewrite.read!/2` you can load the whole project. Then you can modify the - project with a number of functions provided by `Rewrite` and `Rewrite.Source` - without writing any changes back to the file system. All changes are stored in - the source structs. Any version of a source is available in the project. To + With `Rewrite.read!/2` you can load the whole project. Then you can modify the + project with a number of functions provided by `Rewrite` and `Rewrite.Source` + without writing any changes back to the file system. All changes are stored in + the source structs. Any version of a source is available in the project. To write the whole project back to the file system, the `Rewrite.write_all/2` can be used. - Elixir source files can be modified by modifying the AST. For this `Rewrite` + Elixir source files can be modified by modifying the AST. For this `Rewrite` uses the `Sourceror` package to create the AST and to convert it back. The `Sourceror` package also provides all the utilities needed to manipulate the AST. - Sources can also receive a `Rewrite.Issue` to document problems or information - with the source. + Sources can also receive a `Rewrite.Issue` to document problems or information + with the source. - `Rewrite` respects the `.formatter.exs` in the project when rewriting sources. - To do this, the formatter can be read by `Rewrite.DotFormatter` and the - resulting DotFormatter struct can be used in the function to update the + `Rewrite` respects the `.formatter.exs` in the project when rewriting sources. + To do this, the formatter can be read by `Rewrite.DotFormatter` and the + resulting DotFormatter struct can be used in the function to update the sources. """ @@ -58,10 +58,10 @@ defmodule Rewrite do ## Options - * `:filetypes` - a list of modules implementing the behavior - `Rewrite.Filetype`. This list is used to add the `filetype` to the - `sources` of the corresponding files. The list can contain modules - representing a file type or a tuple of `{module(), keyword()}`. Rewrite + * `:filetypes` - a list of modules implementing the behavior + `Rewrite.Filetype`. This list is used to add the `filetype` to the + `sources` of the corresponding files. The list can contain modules + representing a file type or a tuple of `{module(), keyword()}`. Rewrite uses the keyword list from the tuple as the options argument when a file is read. @@ -105,9 +105,9 @@ defmodule Rewrite do * Accepts the same options as `new/1`. - * 'exclude' - a list of paths and/or glob expressions to exclude sources - from the project. The option also accepts a predicate function which is - called for each source path. The exclusion takes place before the file is + * 'exclude' - a list of paths and/or glob expressions to exclude sources + from the project. The option also accepts a predicate function which is + called for each source path. The exclusion takes place before the file is read. """ @spec new!(input() | [input()], opts) :: t() @@ -122,12 +122,12 @@ defmodule Rewrite do ## Options * `:force`, default: `false` - forces the reading of sources. With - `force: true` updates and issues for an already existing source are + `force: true` updates and issues for an already existing source are deleted. - * `:exclude` - a list of paths and/or glob expressions to exclude sources - from the project. The option also accepts a predicate function which is - called for each source path. The exclusion takes place before the file is + * `:exclude` - a list of paths and/or glob expressions to exclude sources + from the project. The option also accepts a predicate function which is + called for each source path. The exclusion takes place before the file is read. """ @spec read!(t(), input() | [input()], opts()) :: t() @@ -258,9 +258,9 @@ defmodule Rewrite do end @doc """ - Deletes the source for the given `path` from the `rewrite`. + Deletes the source for the given `path` from the `rewrite`. - The file system files are not removed, even if the project is written. Use + The file system files are not removed, even if the project is written. Use `rm/2` or `rm!/2` to delete a file and source. If the source is not part of the `rewrite` project the unchanged `rewrite` is @@ -293,7 +293,7 @@ defmodule Rewrite do @doc """ Drops the sources with the given `paths` from the `rewrite` project. - The file system files are not removed, even if the project is written. Use + The file system files are not removed, even if the project is written. Use `rm/2` or `rm!/2` to delete a file and source. If `paths` contains paths that are not in `rewrite`, they're simply ignored. @@ -315,7 +315,7 @@ defmodule Rewrite do end @doc """ - Tries to delete the `source` file in the file system and removes the `source` + Tries to delete the `source` file in the file system and removes the `source` from the `rewrite` project. Returns `{:ok, rewrite}` if successful, or `{:error, error}` if an error @@ -808,7 +808,7 @@ defmodule Rewrite do Returns `{:ok, rewrite}` if all sources are written successfully. - Returns `{:error, reasons, rewrite}` where `rewrite` is updated for all + Returns `{:error, reasons, rewrite}` where `rewrite` is updated for all sources that are written successfully. ## Options @@ -850,9 +850,9 @@ defmodule Rewrite do @doc """ Formats the given `rewrite` project with the given `dot_formatter`. - Uses the formatter from `dot_formatter/2` if no formatter ist set by - `:dot_formatter` in the options. The other options are the same as for - `DotFormatter.read!/2`. + Uses the formatter from `dot_formatter/2` if no formatter ist set by + `:dot_formatter` in the options. The other options are the same as for + `DotFormatter.read!/2`. """ @spec format(t(), opts()) :: {:ok, t()} | {:error, term()} def format(%Rewrite{} = rewrite, opts \\ []) do @@ -874,9 +874,9 @@ defmodule Rewrite do @doc """ Formats a source in a `rewrite` project. - Uses the formatter from `dot_formatter/2` if no formatter ist set by - `:dot_formatter` in the options. The other options are the same as for - `Code.format_string!/2`. + Uses the formatter from `dot_formatter/2` if no formatter ist set by + `:dot_formatter` in the options. The other options are the same as for + `Code.format_string!/2`. """ @spec format_source(t(), Path.t() | Source.t(), keyword()) :: {:ok, t()} | {:error, term()} def format_source(rewrite, file, opts \\ []) @@ -904,7 +904,7 @@ defmodule Rewrite do @doc """ Returns the `DotFormatter` for the given `rewrite` project. - When no formatter is set, the default formatter from + When no formatter is set, the default formatter from `Rewrite.DotFormatter.default/0` is returned. A dot formatter can be set with `dot_formatter/2`. """ @@ -924,11 +924,11 @@ defmodule Rewrite do @doc """ Creates a new `%Source{}` and puts the source to the `%Rewrite{}` project. - The `:filetypes` option of the project is used to create the source. If - options have been specified for the file type, the given options will be + The `:filetypes` option of the project is used to create the source. If + options have been specified for the file type, the given options will be merged into those options. - Use `create_source/4` if the source is not to be inserted directly into the + Use `create_source/4` if the source is not to be inserted directly into the project. """ @spec new_source(t(), Path.t(), String.t(), opts()) :: {:ok, t()} | {:error, Error.t()} @@ -958,12 +958,12 @@ defmodule Rewrite do @doc """ Creates a new `%Source{}` without putting it to the `%Rewrite{}` project. - The `:filetypes` option of the project is used to create the source. If - options have been specified for the file type, the given options will be - merged into those options. If no `path` is given, the default file type is + The `:filetypes` option of the project is used to create the source. If + options have been specified for the file type, the given options will be + merged into those options. If no `path` is given, the default file type is created. - The function does not check whether the `%Rewrite{}` project already has a + The function does not check whether the `%Rewrite{}` project already has a `%Source{}` with the specified path. Use `new_source/4` if the source is to be inserted directly into the project. @@ -1023,14 +1023,13 @@ defmodule Rewrite do end def slice(rewrite) do - sources = rewrite.sources |> Map.values() |> Enum.sort_by(fn source -> source.path end) - length = length(sources) - - {:ok, length, - fn - start, count when start + count == length -> Enum.drop(sources, start) - start, count -> sources |> Enum.drop(start) |> Enum.take(count) - end} + size = map_size(rewrite.sources) + + to_list = fn rewrite -> + rewrite.sources |> Map.values() |> Enum.sort_by(fn source -> source.path end) + end + + {:ok, size, to_list} end def reduce(rewrite, acc, fun) do diff --git a/lib/rewrite/dot_formatter.ex b/lib/rewrite/dot_formatter.ex index 81e49a0..e91158c 100644 --- a/lib/rewrite/dot_formatter.ex +++ b/lib/rewrite/dot_formatter.ex @@ -1076,6 +1076,7 @@ defmodule Rewrite.DotFormatter do fn input -> case Code.format_string!(input, formatter_opts) do [] -> "" + "" -> "" formatted -> IO.iodata_to_binary([formatted, ?\n]) end end @@ -1175,7 +1176,7 @@ defmodule Rewrite.DotFormatter do end end - defp eval_subs(dot_formatter, project, opts) do + defp eval_subs(%DotFormatter{} = dot_formatter, project, opts) do subdirectories = dot_formatter.subdirectories || [] result = @@ -1190,7 +1191,7 @@ defmodule Rewrite.DotFormatter do case result do {:error, _reason} = error -> error - result -> {:ok, %DotFormatter{dot_formatter | subs: result}} + result -> {:ok, %{dot_formatter | subs: result}} end end diff --git a/lib/rewrite/source.ex b/lib/rewrite/source.ex index ffacc27..6db0054 100644 --- a/lib/rewrite/source.ex +++ b/lib/rewrite/source.ex @@ -76,7 +76,7 @@ defmodule Rewrite.Source do * `from` - contains `:file` or `:string` depending on whether the `source` is created from a file or a string. - * `hash` - of the `source`. The `hash` is built from the `content` and + * `hash` - of the `source`. The `hash` is built from the `content` and `path`. * `history` - of the `source`. @@ -85,15 +85,15 @@ defmodule Rewrite.Source do * `owner` - of the `source`. - * `path` - of the `source`. Can be `nil` if the `source` was created by a + * `path` - of the `source`. Can be `nil` if the `source` was created by a `string`. * `private` - a field for user defined data. - * `timestamp` - is set to the timestamp of the last modification of the file + * `timestamp` - is set to the timestamp of the last modification of the file on disk at the time it was read. - If the `source` was created by a `string`, the timestamp is the creation + If the `source` was created by a `string`, the timestamp is the creation time. The timestamp will be updated when the `source` is updated. @@ -101,7 +101,7 @@ defmodule Rewrite.Source do @type t :: %Source{ path: Path.t() | nil, content: String.t(), - hash: String.t(), + hash: non_neg_integer(), history: [{kind(), by(), String.t()}], issues: [{version(), issue()}], filetype: filetype(), @@ -157,9 +157,9 @@ defmodule Rewrite.Source do ## Options - * `:owner` - an association to the module that owns the `source`. + * `:owner` - an association to the module that owns the `source`. - * `:dot_formatter` - a fromatter for the `source`. + * `:dot_formatter` - a formatter for the `source`. * `path` - the path of the `source`. @@ -457,7 +457,7 @@ defmodule Rewrite.Source do ...> ":a" ...> |> Source.Ex.from_string() ...> |> Source.update(:quoted, fn quoted -> - ...> {:__block__, meta, [atom]} = quoted + ...> {:__block__, meta, [atom]} = quoted ...> {:__block__, meta, [{:ok, atom}]} ...> end) iex> source.content @@ -526,20 +526,20 @@ defmodule Rewrite.Source do defp update_timestamp(source), do: %{source | timestamp: now()} - defp do_update(source, :path, path) do - %Source{source | path: path} + defp do_update(%Source{} = source, :path, path) do + %{source | path: path} end - defp do_update(source, :content, content) do - %Source{source | content: content} + defp do_update(%Source{} = source, :content, content) do + %{source | content: content} end - defp update_filetype(%{filetype: nil} = source, _key, _opts), do: source + defp update_filetype(%Source{filetype: nil} = source, _key, _opts), do: source - defp update_filetype(%{filetype: %module{}} = source, key, opts) when is_atom(key) do + defp update_filetype(%Source{filetype: %module{}} = source, key, opts) when is_atom(key) do filetype = module.handle_update(source, key, opts) - %Source{source | filetype: filetype} + %{source | filetype: filetype} end defp update_content(source, nil, _by), do: source @@ -890,7 +890,7 @@ defmodule Rewrite.Source do @doc ~s''' Formats the given `source`. - If the `source` was formatted the `source` gets a new `:history` entry, + If the `source` was formatted the `source` gets a new `:history` entry, otherwise the unchanged `source` is returned. ## Options @@ -900,11 +900,11 @@ defmodule Rewrite.Source do * `dot_formatter` - defaults to `Rewrite.DotFormatter.default/0`. - * Accepts also the same options as `Code.format_string!/2`. - + * Accepts also the same options as `Code.format_string!/2`. + ## Examples - + iex> source = Source.Ex.from_string(""" ...> defmodule Foo do ...> def foo(x), do: bar x @@ -920,7 +920,7 @@ defmodule Rewrite.Source do end """ iex> dot_formatter = DotFormatter.from_formatter_opts(locals_without_parens: [bar: 1]) - iex> {:ok, formatted} = Source.format(source, + iex> {:ok, formatted} = Source.format(source, ...> dot_formatter: dot_formatter, force_do_end_blocks: true ...> ) iex> formatted.content @@ -932,13 +932,13 @@ defmodule Rewrite.Source do end """ ''' - @spec format(t(), opts()) :: {:ok, t()} | {:errror, term()} + @spec format(t(), opts()) :: {:ok, t()} | {:error, term()} def format(%Source{} = source, opts \\ []) do path = Map.get(source, :path) || default_path(source) - dot_fromatter = Keyword.get(opts, :dot_formatter, DotFormatter.default()) + dot_formatter = Keyword.get(opts, :dot_formatter, DotFormatter.default()) by = Keyword.get(opts, :by, Rewrite) - with {:ok, formatted} <- DotFormatter.format_string(dot_fromatter, path, source.content, opts) do + with {:ok, formatted} <- DotFormatter.format_string(dot_formatter, path, source.content, opts) do {:ok, update(source, :content, formatted, by: by)} end end diff --git a/lib/rewrite/source/ex.ex b/lib/rewrite/source/ex.ex index 0c3d666..15e5a02 100644 --- a/lib/rewrite/source/ex.ex +++ b/lib/rewrite/source/ex.ex @@ -15,7 +15,7 @@ defmodule Rewrite.Source.Ex do new code is parsed to a new `:quoted`. That means that `Source.update(source, :quoted, quoted)` also updates the AST. - The resyncing of `:quoted` can be suppressed with the option + The resyncing of `:quoted` can be suppressed with the option `resync_quoted: false`. ## Examples @@ -276,10 +276,10 @@ defmodule Rewrite.Source.Ex do end end - @deprecated "Use the fromatting functionlity provided by Rewrite.DotFormatter instead." + @deprecated "Use the formatting functionlity provided by Rewrite.DotFormatter instead." def put_formatter_opts(source, _opts), do: source - @deprecated "Use the fromatting functionlity provided by Rewrite.DotFormatter instead." + @deprecated "Use the formatting functionlity provided by Rewrite.DotFormatter instead." def format(source, _formatter_opts \\ nil) do dot_formatter = case DotFormatter.read() do diff --git a/mix.exs b/mix.exs index c7fd2eb..847ec62 100644 --- a/mix.exs +++ b/mix.exs @@ -13,12 +13,12 @@ defmodule Rewrite.MixProject do description: description(), dialyzer: dialyzer(), docs: docs(), - elixir: "~> 1.13", + elixir: "~> 1.14", package: package(), - preferred_cli_env: preferred_cli_env(), source_url: @source_url, start_permanent: Mix.env() == :prod, test_coverage: [tool: ExCoveralls], + test_ignore_filters: [~r'test/support/.*', ~r'test/fixtures/.*'], xref: [exclude: [FreedomFormatter.Formatter]] ] end @@ -30,6 +30,19 @@ defmodule Rewrite.MixProject do ] end + def cli do + [ + preferred_envs: [ + carp: :test, + cover: :test, + coveralls: :test, + "coveralls.detail": :test, + "coveralls.html": :test, + "coveralls.github": :test + ] + ] + end + defp description do "An API for rewriting sources in an Elixir project. Powered by sourceror." end @@ -58,17 +71,6 @@ defmodule Rewrite.MixProject do ] end - def preferred_cli_env do - [ - carp: :test, - cover: :test, - coveralls: :test, - "coveralls.detail": :test, - "coveralls.html": :test, - "coveralls.github": :test - ] - end - defp aliases do [ carp: "test --trace --seed 0 --max-failures 1", diff --git a/mix.lock b/mix.lock index 598cc96..6185aa0 100644 --- a/mix.lock +++ b/mix.lock @@ -1,25 +1,25 @@ %{ - "benchee": {:hex, :benchee, "1.3.1", "c786e6a76321121a44229dde3988fc772bca73ea75170a73fd5f4ddf1af95ccf", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "76224c58ea1d0391c8309a8ecbfe27d71062878f59bd41a390266bf4ac1cc56d"}, + "benchee": {:hex, :benchee, "1.4.0", "9f1f96a30ac80bab94faad644b39a9031d5632e517416a8ab0a6b0ac4df124ce", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "299cd10dd8ce51c9ea3ddb74bb150f93d25e968f93e4c1fa31698a8e4fa5d715"}, "benchee_dsl": {:hex, :benchee_dsl, "0.5.3", "f214a33076c79b205780e21a9712f977e1aaf2402acb8b59ff99cd4e9c151499", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}, {:kino, "~> 0.6", [hex: :kino, repo: "hexpm", optional: false]}], "hexpm", "68b829aa4d2782a225dcb0b9652e440b49264b78aa37fe4e120fe784bbfcb466"}, "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, - "credo": {:hex, :credo, "1.7.10", "6e64fe59be8da5e30a1b96273b247b5cf1cc9e336b5fd66302a64b25749ad44d", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "71fbc9a6b8be21d993deca85bf151df023a3097b01e09a2809d460348561d8cd"}, + "credo": {:hex, :credo, "1.7.12", "9e3c20463de4b5f3f23721527fcaf16722ec815e70ff6c60b86412c695d426c1", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8493d45c656c5427d9c729235b99d498bd133421f3e0a683e5c1b561471291e5"}, "deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"}, - "dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.42", "f23d856f41919f17cd06a493923a722d87a2d684f143a1e663c04a2b93100682", [:mix], [], "hexpm", "6915b6ca369b5f7346636a2f41c6a6d78b5af419d61a611079189233358b8b8b"}, + "dialyxir": {:hex, :dialyxir, "1.4.6", "7cca478334bf8307e968664343cbdb432ee95b4b68a9cba95bdabb0ad5bdfd9a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "8cf5615c5cd4c2da6c501faae642839c8405b49f8aa057ad4ae401cb808ef64d"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"}, "erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"}, - "ex_doc": {:hex, :ex_doc, "0.36.1", "4197d034f93e0b89ec79fac56e226107824adcce8d2dd0a26f5ed3a95efc36b1", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d7d26a7cf965dacadcd48f9fa7b5953d7d0cfa3b44fa7a65514427da44eafd89"}, - "excoveralls": {:hex, :excoveralls, "0.18.3", "bca47a24d69a3179951f51f1db6d3ed63bca9017f476fe520eb78602d45f7756", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "746f404fcd09d5029f1b211739afb8fb8575d775b21f6a3908e7ce3e640724c6"}, - "file_system": {:hex, :file_system, "1.0.1", "79e8ceaddb0416f8b8cd02a0127bdbababe7bf4a23d2a395b983c1f8b3f73edd", [:mix], [], "hexpm", "4414d1f38863ddf9120720cd976fce5bdde8e91d8283353f0e31850fa89feb9e"}, + "ex_doc": {:hex, :ex_doc, "0.38.4", "ab48dff7a8af84226bf23baddcdda329f467255d924380a0cf0cee97bb9a9ede", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "f7b62346408a83911c2580154e35613eb314e0278aeea72ed7fedef9c1f165b2"}, + "excoveralls": {:hex, :excoveralls, "0.18.5", "e229d0a65982613332ec30f07940038fe451a2e5b29bce2a5022165f0c9b157e", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "523fe8a15603f86d64852aab2abe8ddbd78e68579c8525ae765facc5eae01562"}, + "file_system": {:hex, :file_system, "1.1.1", "31864f4685b0148f25bd3fbef2b1228457c0c89024ad67f7a81a3ffbc0bbad3a", [:mix], [], "hexpm", "7a15ff97dfe526aeefb090a7a9d3d03aa907e100e262a0f8f7746b78f8f87a5d"}, "fss": {:hex, :fss, "0.1.1", "9db2344dbbb5d555ce442ac7c2f82dd975b605b50d169314a20f08ed21e08642", [:mix], [], "hexpm", "78ad5955c7919c3764065b21144913df7515d52e228c09427a004afe9c1a16b0"}, "glob_ex": {:hex, :glob_ex, "0.1.11", "cb50d3f1ef53f6ca04d6252c7fde09fd7a1cf63387714fe96f340a1349e62c93", [:mix], [], "hexpm", "342729363056e3145e61766b416769984c329e4378f1d558b63e341020525de4"}, "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, - "kino": {:hex, :kino, "0.14.2", "46c5da03f2d62dc119ec5e1c1493f409f08998eac26015ecdfae322ffff46d76", [:mix], [{:fss, "~> 0.1.0", [hex: :fss, repo: "hexpm", optional: false]}, {:nx, "~> 0.1", [hex: :nx, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}, {:table, "~> 0.1.2", [hex: :table, repo: "hexpm", optional: false]}], "hexpm", "f54924dd0800ee8b291fe437f942889e90309eb3541739578476f53c1d79c968"}, + "kino": {:hex, :kino, "0.17.0", "72f1a2bf691db7b8352bae86b3951fdf9b23619b5d8586cb7cd1e9c2edc8ff9b", [:mix], [{:fss, "~> 0.1.0", [hex: :fss, repo: "hexpm", optional: false]}, {:nx, "~> 0.1", [hex: :nx, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}, {:table, "~> 0.1.2", [hex: :table, repo: "hexpm", optional: false]}], "hexpm", "e1ec49a2ebbf622c1675f96b427c565ce02df6725e8f2e8d4a743c8e791bd090"}, "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, "makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"}, - "makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"}, - "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, - "sourceror": {:hex, :sourceror, "1.7.1", "599d78f4cc2be7d55c9c4fd0a8d772fd0478e3a50e726697c20d13d02aa056d4", [:mix], [], "hexpm", "cd6f268fe29fa00afbc535e215158680a0662b357dc784646d7dff28ac65a0fc"}, - "statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"}, + "makeup_erlang": {:hex, :makeup_erlang, "1.0.2", "03e1804074b3aa64d5fad7aa64601ed0fb395337b982d9bcf04029d68d51b6a7", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "af33ff7ef368d5893e4a267933e7744e46ce3cf1f61e2dccf53a111ed3aa3727"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"}, + "sourceror": {:hex, :sourceror, "1.10.0", "38397dedbbc286966ec48c7af13e228b171332be1ad731974438c77791945ce9", [:mix], [], "hexpm", "29dbdfc92e04569c9d8e6efdc422fc1d815f4bd0055dc7c51b8800fb75c4b3f1"}, + "statistex": {:hex, :statistex, "1.1.0", "7fec1eb2f580a0d2c1a05ed27396a084ab064a40cfc84246dbfb0c72a5c761e5", [:mix], [], "hexpm", "f5950ea26ad43246ba2cce54324ac394a4e7408fdcf98b8e230f503a0cba9cf5"}, "table": {:hex, :table, "0.1.2", "87ad1125f5b70c5dea0307aa633194083eb5182ec537efc94e96af08937e14a8", [:mix], [], "hexpm", "7e99bc7efef806315c7e65640724bf165c3061cdc5d854060f74468367065029"}, "text_diff": {:hex, :text_diff, "0.1.0", "1caf3175e11a53a9a139bc9339bd607c47b9e376b073d4571c031913317fecaa", [:mix], [], "hexpm", "d1ffaaecab338e49357b6daa82e435f877e0649041ace7755583a0ea3362dbd7"}, } diff --git a/test/rewrite_test.exs b/test/rewrite_test.exs index 21521fc..3778c13 100644 --- a/test/rewrite_test.exs +++ b/test/rewrite_test.exs @@ -1111,6 +1111,15 @@ defmodule RewriteTest do assert Enum.slice(project, 1, 0) == [] end + test "to_list/1" do + a = Source.from_string(":a", path: "a.exs") + b = Source.from_string(":b", path: "b.exs") + c = Source.from_string(":c", path: "c.exs") + {:ok, project} = Rewrite.from_sources([a, b, c]) + + assert Enum.to_list(project) == [a, b, c] + end + test "member?/1 returns true" do project = Rewrite.new() project = Rewrite.new_source!(project, "a.ex", ":a")