Tidy up tests for Code (#5531)

Tidy up tests for Code (#5531)

* Better test names
* Removed a few duplicate tests
* Used a few describe/2 blocks to organize tests a bit more

Code.require_file "test_helper.exs", __DIR__

defmodule CodeTest do
  use ExUnit.Case, async: true

  doctest Code

  import PathHelpers

  def genmodule(name) do
    defmodule name do
      Kernel.LexicalTracker.remote_references(__MODULE__)
    end
  end

  contents = quote do
    defmodule CodeTest.Sample do
      def eval_quoted_info, do: {__MODULE__, __ENV__.file, __ENV__.line}
    end
  end

  Code.eval_quoted contents, [], file: "sample.ex", line: 13

  describe "eval_string/1-3" do
    test "correctly evaluates a string of code" do
      assert Code.eval_string("1 + 2") == {3, []}
      assert Code.eval_string("two = 1 + 1") == {2, [two: 2]}
    end

    test "supports a %Macro.Env{} struct as the third argument" do
      assert {3, _} = Code.eval_string("a + b", [a: 1, b: 2], __ENV__)
    end

    test "can return bindings from a different context" do
      assert Code.eval_string("var!(a, Sample) = 1") == {1, [{{:a, Sample}, 1}]}
    end

    test "supports unnamed scopes" do
      assert {%RuntimeError{}, [a: %RuntimeError{}]} =
        Code.eval_string("a = (try do (raise \"hello\") rescue e -> e end)")
    end

    test "supports the :requires option" do
      assert Code.eval_string("Kernel.if true, do: :ok", [], requires: [Z, Kernel]) == {:ok, []}
    end

    test "with many options" do
      options = [
        functions: [{Kernel, [is_atom: 1]}],
        macros: [{Kernel, [and: 2]}],
        aliases: [{K, Kernel}],
        requires: [Kernel],
      ]

      code = "is_atom(:foo) and K.is_list([])"

      assert Code.eval_string(code, [], options) == {true, []}
    end

    test "yields the correct stacktrace" do
      try do
        Code.eval_string("<<a::size(b)>>", a: :a, b: :b)
      rescue
        _ ->
          assert System.stacktrace |> Enum.any?(&(elem(&1, 0) == __MODULE__))
      end
    end
  end

  test "eval binary errors" do
    msg = "nofile:2: a binary field without size is only allowed at the end of a binary pattern"
    assert_raise CompileError, msg, fn ->
      Code.eval_string("""
      foo = "foo"
      "\\"" <> bar <> "\\"" = foo
      """)
    end
  end

  test "eval_quoted/1" do
    assert Code.eval_quoted(quote(do: 1 + 2)) == {3, []}
    assert CodeTest.Sample.eval_quoted_info() == {CodeTest.Sample, "sample.ex", 13}
  end

  test "eval_quoted/2 with a %Macro.Env{} struct as the second argument" do
    alias :lists, as: MyList
    assert Code.eval_quoted(quote(do: MyList.flatten [[1, 2, 3]]), [], __ENV__) == {[1, 2, 3], []}
  end

  test "eval_file/1" do
    assert Code.eval_file(fixture_path("code_sample.exs")) == {3, [var: 3]}

    assert_raise Code.LoadError, fn ->
      Code.eval_file("non_existent.exs")
    end
  end

  test "require_file/1" do
    Code.require_file fixture_path("code_sample.exs")
    assert fixture_path("code_sample.exs") in Code.loaded_files
    assert Code.require_file(fixture_path("code_sample.exs")) == nil

    Code.unload_files [fixture_path("code_sample.exs")]
    refute fixture_path("code_sample.exs") in Code.loaded_files
    assert Code.require_file(fixture_path("code_sample.exs")) != nil
  end

  test "string_to_quoted/1" do
    assert Code.string_to_quoted("1 + 2") == {:ok, {:+, [line: 1], [1, 2]}}
    assert Code.string_to_quoted("a.1") == {:error, {1, "syntax error before: ", "1"}}
  end

  test "string_to_quoted!/1 works as string_to_quoted/1 but raises on errors" do
    assert Code.string_to_quoted!("1 + 2") == {:+, [line: 1], [1, 2]}

    assert_raise SyntaxError, fn ->
      Code.string_to_quoted!("a.1")
    end

    assert_raise TokenMissingError, fn ->
      Code.string_to_quoted!("1 +")
    end
  end

  test "string_to_quoted!/2 raises with the :existing_atoms_only option" do
    assert catch_error(Code.string_to_quoted!(":there_is_no_such_atom", existing_atoms_only: true)) == :badarg
  end

  test "compile source" do
    assert __MODULE__.__info__(:compile)[:source] == String.to_charlist(__ENV__.file)
  end

  test "compile info returned with source accessible through keyword module" do
    compile = __MODULE__.__info__(:compile)
    assert Keyword.get(compile, :source) != nil
  end

  describe "compile_string/1" do
    test "compiles the given string" do
      assert [{CompileStringSample, _}] = Code.compile_string("defmodule CompileStringSample, do: :ok")
    after
      :code.purge CompileSimpleSample
      :code.delete CompileSimpleSample
    end

    test "works across lexical scopes" do
      assert [{CompileCrossSample, _}] = Code.compile_string("CodeTest.genmodule CompileCrossSample")
    after
      :code.purge CompileCrossSample
      :code.delete CompileCrossSample
    end
  end

  test "ensure_loaded?/1" do
    assert Code.ensure_loaded?(__MODULE__)
    refute Code.ensure_loaded?(Code.NoFile)
  end

  test "ensure_compiled?/1" do
    assert Code.ensure_compiled?(__MODULE__)
    refute Code.ensure_compiled?(Code.NoFile)
  end

  test "compiler_options/1 validates options" do
    message = "unknown compiler option: :not_a_valid_option"
    assert_raise RuntimeError, message, fn ->
      Code.compiler_options(not_a_valid_option: :foo)
    end

    message = "compiler option :debug_info should be a boolean, got: :not_a_boolean"
    assert_raise RuntimeError, message, fn ->
      Code.compiler_options(debug_info: :not_a_boolean)
    end
  end
end

defmodule Code.SyncTest do
  use ExUnit.Case

  test "path manipulation" do
    path = Path.join(__DIR__, "fixtures")
    Code.prepend_path path
    assert to_charlist(path) in :code.get_path

    Code.delete_path path
    refute to_charlist(path) in :code.get_path
  end
end

Code.require_file "test_helper.exs", __DIR__

defmodule CodeTest do
  use ExUnit.Case, async: true

  doctest Code

  import PathHelpers

  def genmodule(name) do
    defmodule name do
      Kernel.LexicalTracker.remote_references(__MODULE__)
    end
  end

  contents = quote do
    defmodule CodeTest.Sample do
      def eval_quoted_info, do: {__MODULE__, __ENV__.file, __ENV__.line}
    end
  end

  Code.eval_quoted contents, [], file: "sample.ex", line: 13

  test "eval string" do
    assert Code.eval_string("1 + 2") == {3, []}
    assert {3, _} = Code.eval_string("a + b", [a: 1, b: 2], Macro.Env.location(__ENV__))
  end

  test "eval string with other context" do
    assert Code.eval_string("var!(a, Sample) = 1") == {1, [{{:a, Sample}, 1}]}
  end

  test "eval binary errors" do
    msg = "nofile:2: a binary field without size is only allowed at the end of a binary pattern"
    assert_raise CompileError, msg, fn ->
      Code.eval_string("""
      foo = "foo"
      "\\"" <> bar <> "\\"" = foo
      """)
    end
  end

  test "eval with unnamed scopes" do
    assert {%RuntimeError{}, [a: %RuntimeError{}]} =
           Code.eval_string("a = (try do (raise \"hello\") rescue e -> e end)")
  end

  test "eval options" do
    assert Code.eval_string("is_atom(:foo) and K.is_list([])", [],
                            functions: [{Kernel, [is_atom: 1]}],
                            macros: [{Kernel, [..: 2, and: 2]}],
                            aliases: [{K, Kernel}],
                            requires: [Kernel]) == {true, []}
  end

  test "eval stacktrace" do
    try do
      Code.eval_string("<<a :: size(b)>>", a: :a, b: :b)
    rescue
      _ ->
        assert System.stacktrace |> Enum.any?(&(elem(&1, 0) == __MODULE__))
    end
  end

  test "eval with requires" do
    assert Code.eval_string("Kernel.if true, do: :ok", [], requires: [Z, Kernel]) == {:ok, []}
  end

  test "eval quoted" do
    assert Code.eval_quoted(quote(do: 1 + 2)) == {3, []}
    assert CodeTest.Sample.eval_quoted_info() == {CodeTest.Sample, "sample.ex", 13}
  end

  test "eval quoted with env" do
    alias :lists, as: MyList
    assert Code.eval_quoted(quote(do: MyList.flatten [[1, 2, 3]]), [], __ENV__) == {[1, 2, 3], []}
  end

  test "eval file" do
    assert Code.eval_file(fixture_path("code_sample.exs")) == {3, [var: 3]}

    assert_raise Code.LoadError, fn ->
      Code.eval_file("non_existent.exs")
    end
  end

  test "require" do
    Code.require_file fixture_path("code_sample.exs")
    assert fixture_path("code_sample.exs") in Code.loaded_files
    assert Code.require_file(fixture_path("code_sample.exs")) == nil

    Code.unload_files [fixture_path("code_sample.exs")]
    refute fixture_path("code_sample.exs") in Code.loaded_files
    assert Code.require_file(fixture_path("code_sample.exs")) != nil
  end

  test "string to quoted" do
    assert Code.string_to_quoted("1 + 2")  == {:ok, {:+, [line: 1], [1, 2]}}
    assert Code.string_to_quoted!("1 + 2") == {:+, [line: 1], [1, 2]}

    assert Code.string_to_quoted("a.1") ==
           {:error, {1, "syntax error before: ", "1"}}

    assert_raise SyntaxError, fn ->
      Code.string_to_quoted!("a.1")
    end
  end

  test "string to quoted existing atoms only" do
    assert :badarg = catch_error(Code.string_to_quoted!(":there_is_no_such_atom", existing_atoms_only: true))
  end

  test "string_to_quoted!" do
    assert Code.string_to_quoted!("1 + 2") == {:+, [line: 1], [1, 2]}

    assert_raise SyntaxError, fn ->
      Code.string_to_quoted!("a.1")
    end

    assert_raise TokenMissingError, fn ->
      Code.string_to_quoted!("1 +")
    end
  end

  test "compile source" do
    assert __MODULE__.__info__(:compile)[:source] == String.to_charlist(__ENV__.file)
  end

  test "compile info returned with source accessible through keyword module" do
    compile = __MODULE__.__info__(:compile)
    assert Keyword.get(compile, :source) != nil
  end

  test "compile string works accross lexical scopes" do
    assert [{CompileCrossSample, _}] = Code.compile_string("CodeTest.genmodule CompileCrossSample")
  after
    :code.purge CompileCrossSample
    :code.delete CompileCrossSample
  end

  test "compile string" do
    assert [{CompileStringSample, _}] = Code.compile_string("defmodule CompileStringSample, do: :ok")
  after
    :code.purge CompileSimpleSample
    :code.delete CompileSimpleSample
  end

  test "compile quoted" do
    assert [{CompileQuotedSample, _}] = Code.compile_string("defmodule CompileQuotedSample, do: :ok")
  after
    :code.purge CompileQuotedSample
    :code.delete CompileQuotedSample
  end

  test "ensure_loaded?" do
    assert Code.ensure_loaded?(__MODULE__)
    refute Code.ensure_loaded?(Code.NoFile)
  end

  test "ensure_compiled?" do
    assert Code.ensure_compiled?(__MODULE__)
    refute Code.ensure_compiled?(Code.NoFile)
  end

  test "compiler_options/1 validates options" do
    message = "unknown compiler option: :not_a_valid_option"
    assert_raise RuntimeError, message, fn ->
      Code.compiler_options(not_a_valid_option: :foo)
    end

    message = "compiler option :debug_info should be a boolean, got: :not_a_boolean"
    assert_raise RuntimeError, message, fn ->
      Code.compiler_options(debug_info: :not_a_boolean)
    end
  end
end

defmodule Code.SyncTest do
  use ExUnit.Case

  test "path manipulation" do
    path = Path.join(__DIR__, "fixtures")
    Code.prepend_path path
    assert to_charlist(path) in :code.get_path

    Code.delete_path path
    refute to_charlist(path) in :code.get_path
  end
end


Add sleep function to Process

Add sleep function to Process

defmodule ElixirScript.Process do

  def alive?(pid) do
    Elixir.Core.processes.is_alive(pid)
  end

  def delete(key) do
    Elixir.Core.processes.erase(key)
  end

  def exit(pid, reason) do
    Elixir.Core.processes.exit(pid, reason)
  end

  def flag(flag, value) do
    Elixir.Core.processes.process_flag(flag, value)
  end

  def flag(pid, flag, value) do
    Elixir.Core.processes.process_flag(pid, flag, value)
  end

  def get() do
    Elixir.Core.processes.get_process_dict()
  end

  def get(key, default \\ nil) do
    Elixir.Core.processes.get(key, default)
  end

  def get_keys() do
    Elixir.Core.processes.get_keys()
  end

  def get_keys(value) do
    Elixir.Core.processes.get_keys(value)
  end

  def put(key, value) do
    Elixir.Core.processes.put(key, value)
  end

  def link(pid) do
    Elixir.Core.processes.link(pid)
  end

  def unlink(pid) do
    Elixir.Core.processes.unlink(pid)
  end

  def register(pid, name) when is_atom(name) do
    Elixir.Core.processes.register(pid, name)
  end

  def registered() do
    Elixir.Core.processes.registered()
  end

  def whereis(name) do
    Elixir.Core.processes.whereis(name)
  end

  def list() do
    Elixir.Core.processes.list()
  end

  def sleep(duration) do
    Elixir.Core.processes.sleep(duration)
  end

end

defmodule ElixirScript.Process do

  def alive?(pid) do
    Elixir.Core.processes.is_alive(pid)
  end

  def delete(key) do
    Elixir.Core.processes.erase(key)
  end

  def exit(pid, reason) do
    Elixir.Core.processes.exit(pid, reason)
  end

  def flag(flag, value) do
    Elixir.Core.processes.process_flag(flag, value)
  end

  def flag(pid, flag, value) do
    Elixir.Core.processes.process_flag(pid, flag, value)
  end

  def get() do
    Elixir.Core.processes.get_process_dict()
  end

  def get(key, default \\ nil) do
    Elixir.Core.processes.get(key, default)
  end

  def get_keys() do
    Elixir.Core.processes.get_keys()
  end

  def get_keys(value) do
    Elixir.Core.processes.get_keys(value)
  end

  def put(key, value) do
    Elixir.Core.processes.put(key, value)
  end

  def link(pid) do
    Elixir.Core.processes.link(pid)
  end

  def unlink(pid) do
    Elixir.Core.processes.unlink(pid)
  end

  def register(pid, name) when is_atom(name) do
    Elixir.Core.processes.register(pid, name)
  end

  def registered() do
    Elixir.Core.processes.registered()
  end

  def whereis(name) do
    Elixir.Core.processes.whereis(name)
  end

  def list() do
    Elixir.Core.processes.list()
  end

end


Fixing result handling of :file.consult

Fixing result handling of :file.consult

defmodule Mix.Tasks.Compile.App do
  use Mix.Task

  @recursive true

  @moduledoc """
  Writes an .app file.

  By default, this task will detect all modules in your `compile_path`
  (defaults to `ebin`) and generate a best guess for your application
  specification. This best guess also includes `kernel`, `stdlib`
  and `elixir` as application dependencies.

  You can optionally define an `application/0` function inside your
  `Mix.Project` that returns a keyword list to further configure
  your application according to the OTP design principles:

  http://www.erlang.org/doc/design_principles/applications.html

  ## Command line options

  * `--force` - forces compilation regardless of modification times

  ## Configuration

  * `:app` - The application name as a binary (required)
  * `:version` - The application version as a binary (required)

  """
  def run(args) do
    { opts, _, _ } = OptionParser.parse(args, switches: [force: :boolean])

    project = Mix.Project.get!
    config  = Mix.project

    app     = Keyword.fetch!(config, :app)
    version = Keyword.fetch!(config, :version)

    validate_app(app)
    validate_version(version)

    path = Mix.Project.compile_path
    mods = modules_from(Path.wildcard('#{path}/*.beam')) |> Enum.sort

    target  = Path.join(path, "#{app}.app")
    sources = Mix.Project.config_files

    if opts[:force] || Mix.Utils.stale?(sources, [target]) || modules_changed?(mods, target) do
      best_guess = [
        vsn: to_char_list(version),
        modules: mods,
        applications: [:kernel, :stdlib, :elixir]
      ]

      properties = if function_exported?(project, :application, 0) do
        Keyword.merge(best_guess, project.application)
      else
        best_guess
      end

      properties = ensure_correct_properties(app, properties)
      contents   = { :application, app, properties }

      Mix.Project.build_structure(config)
      File.open!(target, [:write], &:io.fwrite(&1, "~p.", [contents]))

      Mix.shell.info "Generated #{app}.app"
      :ok
    else
      :noop
    end
  end

  defp modules_changed?(mods, target) do
    case :file.consult(target) do
      { :ok, [ { :application, _app, properties } ] } ->
        properties[:registered] == mods
      _ ->
        false
    end
  end

  defp validate_app(app) when is_atom(app), do: :ok
  defp validate_app(_), do: raise(Mix.Error, message: "Expected :app to be an atom")

  defp validate_version(version) do
    unless is_binary(version) and match?({ :ok, _ }, Version.parse(version)) do
      raise(Mix.Error, message: "Expected :version to be a SemVer version")
    end
  end

  defp modules_from(beams) do
    Enum.map beams, &(&1 |> Path.basename |> Path.rootname('.beam') |> list_to_atom)
  end

  defp ensure_correct_properties(app, properties) do
    properties
    |> Keyword.put_new(:description, to_char_list(app))
    |> Keyword.put_new(:registered, [])
    |> validate_properties
  end

  defp validate_properties(properties) do
    Enum.each properties, fn
      { :description, value } ->
        unless is_list(value), do:
          invalid "Application description (:description) is not a character list (got #{inspect value})"
      { :id, value } ->
        unless is_list(value), do:
          invalid "Application id (:id) is not a character list (got #{inspect value} instead)"
      { :vsn, value } ->
        unless is_list(value), do:
          invalid "Application vsn (:vsn) is not a character list (got #{inspect value} instead)"
      { :maxT, value } ->
        unless value == :infinity or is_integer(value), do:
          invalid "Application maximum time (:maxT) is not an integer or :infinity (got #{inspect value} instead)"
      { :modules, value } ->
        unless is_list(value) and Enum.all?(value, &is_atom(&1)), do:
          invalid "Application modules (:modules) should be a list of atoms (got #{inspect value} instead)"
      { :registered, value } ->
        unless is_list(value) and Enum.all?(value, &is_atom(&1)), do:
          invalid "Application registered processes (:registered) should be a list of atoms (got #{inspect value} instead)"
      { :included_applications, value } ->
        unless is_list(value) and Enum.all?(value, &is_atom(&1)), do:
          invalid "Application included applications (:included_applications) should be a list of atoms (got #{inspect value} instead)"
      { :applications, value } ->
        unless is_list(value) and Enum.all?(value, &is_atom(&1)), do:
          invalid "Application dependencies (:applications) should be a list of atoms (got #{inspect value} instead)"
      { :env, value } ->
        unless Keyword.keyword?(value), do:
          invalid "Application dependencies (:env) should be a keyword list (got #{inspect value} instead)"
      { :start_phases, value } ->
        unless Keyword.keyword?(value), do:
          invalid "Application start phases (:start_phases) should be a keyword list (got #{inspect value} instead)"
      { :mod, [] } ->
        :ok
      { :mod, { module, _args } } when is_atom(module) ->
        :ok
      { :mod, value } ->
        invalid "Application callback module (:mod) should be either [] or {module, start_args} (got #{inspect value} instead)"
      _ ->
        :ok
    end

    properties
  end

  defp invalid(message) do
    raise Mix.Error, message: message
  end
end

defmodule Mix.Tasks.Compile.App do
  use Mix.Task

  @recursive true

  @moduledoc """
  Writes an .app file.

  By default, this task will detect all modules in your `compile_path`
  (defaults to `ebin`) and generate a best guess for your application
  specification. This best guess also includes `kernel`, `stdlib`
  and `elixir` as application dependencies.

  You can optionally define an `application/0` function inside your
  `Mix.Project` that returns a keyword list to further configure
  your application according to the OTP design principles:

  http://www.erlang.org/doc/design_principles/applications.html

  ## Command line options

  * `--force` - forces compilation regardless of modification times

  ## Configuration

  * `:app` - The application name as a binary (required)
  * `:version` - The application version as a binary (required)

  """
  def run(args) do
    { opts, _, _ } = OptionParser.parse(args, switches: [force: :boolean])

    project = Mix.Project.get!
    config  = Mix.project

    app     = Keyword.fetch!(config, :app)
    version = Keyword.fetch!(config, :version)

    validate_app(app)
    validate_version(version)

    path = Mix.Project.compile_path
    mods = modules_from(Path.wildcard('#{path}/*.beam')) |> Enum.sort

    target  = Path.join(path, "#{app}.app")
    sources = Mix.Project.config_files

    if opts[:force] || Mix.Utils.stale?(sources, [target]) || modules_changed?(mods, target) do
      best_guess = [
        vsn: to_char_list(version),
        modules: mods,
        applications: [:kernel, :stdlib, :elixir]
      ]

      properties = if function_exported?(project, :application, 0) do
        Keyword.merge(best_guess, project.application)
      else
        best_guess
      end

      properties = ensure_correct_properties(app, properties)
      contents   = { :application, app, properties }

      Mix.Project.build_structure(config)
      File.open!(target, [:write], &:io.fwrite(&1, "~p.", [contents]))

      Mix.shell.info "Generated #{app}.app"
      :ok
    else
      :noop
    end
  end

  defp modules_changed?(mods, target) do
    case :file.consult(target) do
      { :ok, { :application, _app, properties } } ->
        properties[:registered] == mods
      _ ->
        false
    end
  end

  defp validate_app(app) when is_atom(app), do: :ok
  defp validate_app(_), do: raise(Mix.Error, message: "Expected :app to be an atom")

  defp validate_version(version) do
    unless is_binary(version) and match?({ :ok, _ }, Version.parse(version)) do
      raise(Mix.Error, message: "Expected :version to be a SemVer version")
    end
  end

  defp modules_from(beams) do
    Enum.map beams, &(&1 |> Path.basename |> Path.rootname('.beam') |> list_to_atom)
  end

  defp ensure_correct_properties(app, properties) do
    properties
    |> Keyword.put_new(:description, to_char_list(app))
    |> Keyword.put_new(:registered, [])
    |> validate_properties
  end

  defp validate_properties(properties) do
    Enum.each properties, fn
      { :description, value } ->
        unless is_list(value), do:
          invalid "Application description (:description) is not a character list (got #{inspect value})"
      { :id, value } ->
        unless is_list(value), do:
          invalid "Application id (:id) is not a character list (got #{inspect value} instead)"
      { :vsn, value } ->
        unless is_list(value), do:
          invalid "Application vsn (:vsn) is not a character list (got #{inspect value} instead)"
      { :maxT, value } ->
        unless value == :infinity or is_integer(value), do:
          invalid "Application maximum time (:maxT) is not an integer or :infinity (got #{inspect value} instead)"
      { :modules, value } ->
        unless is_list(value) and Enum.all?(value, &is_atom(&1)), do:
          invalid "Application modules (:modules) should be a list of atoms (got #{inspect value} instead)"
      { :registered, value } ->
        unless is_list(value) and Enum.all?(value, &is_atom(&1)), do:
          invalid "Application registered processes (:registered) should be a list of atoms (got #{inspect value} instead)"
      { :included_applications, value } ->
        unless is_list(value) and Enum.all?(value, &is_atom(&1)), do:
          invalid "Application included applications (:included_applications) should be a list of atoms (got #{inspect value} instead)"
      { :applications, value } ->
        unless is_list(value) and Enum.all?(value, &is_atom(&1)), do:
          invalid "Application dependencies (:applications) should be a list of atoms (got #{inspect value} instead)"
      { :env, value } ->
        unless Keyword.keyword?(value), do:
          invalid "Application dependencies (:env) should be a keyword list (got #{inspect value} instead)"
      { :start_phases, value } ->
        unless Keyword.keyword?(value), do:
          invalid "Application start phases (:start_phases) should be a keyword list (got #{inspect value} instead)"
      { :mod, [] } ->
        :ok
      { :mod, { module, _args } } when is_atom(module) ->
        :ok
      { :mod, value } ->
        invalid "Application callback module (:mod) should be either [] or {module, start_args} (got #{inspect value} instead)"
      _ ->
        :ok
    end

    properties
  end

  defp invalid(message) do
    raise Mix.Error, message: message
  end
end


Bump version to 1.0.3

Bump version to 1.0.3

defmodule Bmark.Mixfile do
  use Mix.Project

  def project do
    [app: :bmark,
     version: "1.0.3",
     elixir: "~> 1.0",
     deps: deps,
     description: description,
     package: package]
  end

  def application do
    [applications: [:logger]]
  end

  defp deps do
    [
      {:inch_ex, only: :docs},
      {:earmark, "~> 0.1.17", only: :dev},
      {:ex_doc, "~> 0.10", only: :dev}
    ]
  end

  defp description do
    """
    A benchmarking tool for Elixir with a focus on comparing results with confidence.
    """
  end

  defp package do
    [files: ["lib", "mix.exs", "README.md", "LICENSE", "CONTRIBUTING.md"],
     maintainers: ["Joseph Kain"],
     licenses: ["MIT"],
     links: %{
       "github" => "https://github.com/joekain/bmark",
       "Blog posts" => "http://learningelixir.joekain.com/bmark-posts/"
     }]
  end
end

defmodule Bmark.Mixfile do
  use Mix.Project

  def project do
    [app: :bmark,
     version: "1.0.2",
     elixir: "~> 1.0",
     deps: deps,
     description: description,
     package: package]
  end

  def application do
    [applications: [:logger]]
  end

  defp deps do
    [
      {:inch_ex, only: :docs},
      {:earmark, "~> 0.1.17", only: :dev},
      {:ex_doc, "~> 0.10", only: :dev}
    ]
  end

  defp description do
    """
    A benchmarking tool for Elixir with a focus on comparing results with confidence.
    """
  end

  defp package do
    [files: ["lib", "mix.exs", "README.md", "LICENSE", "CONTRIBUTING.md"],
     maintainers: ["Joseph Kain"],
     licenses: ["MIT"],
     links: %{
       "github" => "https://github.com/joekain/bmark",
       "Blog posts" => "http://learningelixir.joekain.com/bmark-posts/"
     }]
  end
end


version 0.5.2

version 0.5.2

defmodule Wwwtech.MixProject do
  use Mix.Project

  def project do
    [
      app: :wwwtech,
      version: "0.5.2",
      elixir: "~> 1.5",
      elixirc_paths: elixirc_paths(Mix.env()),
      compilers: [:phoenix, :gettext] ++ Mix.compilers(),
      start_permanent: Mix.env() == :prod,
      aliases: aliases(),
      deps: deps()
    ]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [
      mod: {Wwwtech.Application, []},
      extra_applications: [:logger, :runtime_tools, :httpotion]
    ]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [
      {:phoenix, "~> 1.4.10"},
      {:phoenix_pubsub, "~> 1.1"},
      {:phoenix_ecto, "~> 4.0"},
      {:ecto_sql, "~> 3.1"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 2.11"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:gettext, "~> 0.11"},
      {:jason, "~> 1.0"},
      {:plug_cowboy, "~> 2.0"},
      {:argon2_elixir, "~> 2.0"},
      {:timex, "~> 3.5"},
      {:earmark, "~> 1.4.0"},
      {:xml_builder, "~> 2.1"},
      {:exexif, "~> 0.0.5"},
      {:mogrify, "~> 0.7.3"},
      {:microformats2, "~> 0.1"},
      {:webmentions, "~> 0.3"},
      {:bamboo, "~> 1.2"},
      {:bamboo_smtp, "~> 1.5"},
      {:appsignal, "~> 1.0"}
    ]
  end

  # Aliases are shortcuts or tasks specific to the current project.
  # For example, to create, migrate and run the seeds file at once:
  #
  #     $ mix ecto.setup
  #
  # See the documentation for `Mix` for more info on aliases.
  defp aliases do
    [
      "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      test: ["ecto.create --quiet", "ecto.migrate", "test"],
      build: "cmd ./.build/build",
      deploy: "cmd ./.build/deploy"
    ]
  end
end

defmodule Wwwtech.MixProject do
  use Mix.Project

  def project do
    [
      app: :wwwtech,
      version: "0.5.1",
      elixir: "~> 1.5",
      elixirc_paths: elixirc_paths(Mix.env()),
      compilers: [:phoenix, :gettext] ++ Mix.compilers(),
      start_permanent: Mix.env() == :prod,
      aliases: aliases(),
      deps: deps()
    ]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [
      mod: {Wwwtech.Application, []},
      extra_applications: [:logger, :runtime_tools, :httpotion]
    ]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [
      {:phoenix, "~> 1.4.10"},
      {:phoenix_pubsub, "~> 1.1"},
      {:phoenix_ecto, "~> 4.0"},
      {:ecto_sql, "~> 3.1"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 2.11"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:gettext, "~> 0.11"},
      {:jason, "~> 1.0"},
      {:plug_cowboy, "~> 2.0"},
      {:argon2_elixir, "~> 2.0"},
      {:timex, "~> 3.5"},
      {:earmark, "~> 1.4.0"},
      {:xml_builder, "~> 2.1"},
      {:exexif, "~> 0.0.5"},
      {:mogrify, "~> 0.7.3"},
      {:microformats2, "~> 0.1"},
      {:webmentions, "~> 0.3"},
      {:bamboo, "~> 1.2"},
      {:bamboo_smtp, "~> 1.5"},
      {:appsignal, "~> 1.0"}
    ]
  end

  # Aliases are shortcuts or tasks specific to the current project.
  # For example, to create, migrate and run the seeds file at once:
  #
  #     $ mix ecto.setup
  #
  # See the documentation for `Mix` for more info on aliases.
  defp aliases do
    [
      "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      test: ["ecto.create --quiet", "ecto.migrate", "test"],
      build: "cmd ./.build/build",
      deploy: "cmd ./.build/deploy"
    ]
  end
end


version 0.7.3

version 0.7.3

defmodule Wwwtech.MixProject do
  use Mix.Project

  def project do
    [
      app: :wwwtech,
      version: "0.7.3",
      elixir: "~> 1.5",
      elixirc_paths: elixirc_paths(Mix.env()),
      compilers: [:phoenix, :gettext] ++ Mix.compilers(),
      start_permanent: Mix.env() == :prod,
      aliases: aliases(),
      deps: deps()
    ]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [
      mod: {Wwwtech.Application, []},
      extra_applications: [:logger, :runtime_tools]
    ]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [
      {:phoenix, "~> 1.4.10"},
      {:phoenix_pubsub, "~> 1.1"},
      {:phoenix_ecto, "~> 4.0"},
      {:ecto_sql, "~> 3.1"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 2.11"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:gettext, "~> 0.11"},
      {:jason, "~> 1.0"},
      {:plug_cowboy, "~> 2.0"},
      {:argon2_elixir, "~> 2.0"},
      {:timex, "~> 3.5"},
      {:earmark, "~> 1.4.0"},
      {:xml_builder, "~> 2.1"},
      {:exexif, "~> 0.0.5"},
      {:mogrify, "~> 0.7.3"},
      {:microformats2, "~> 0.1"},
      {:webmentions, "~> 0.3"},
      {:floki, "~> 0.23"},
      {:bamboo, "~> 1.2"},
      {:bamboo_smtp, "~> 1.5"},
      {:appsignal, "~> 1.0"},
      {:tesla, "~> 1.3.0"}
    ]
  end

  # Aliases are shortcuts or tasks specific to the current project.
  # For example, to create, migrate and run the seeds file at once:
  #
  #     $ mix ecto.setup
  #
  # See the documentation for `Mix` for more info on aliases.
  defp aliases do
    [
      "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      test: ["ecto.create --quiet", "ecto.migrate", "test"],
      build: "cmd ./.build/build",
      deploy: "cmd ./.build/deploy"
    ]
  end
end

defmodule Wwwtech.MixProject do
  use Mix.Project

  def project do
    [
      app: :wwwtech,
      version: "0.7.2",
      elixir: "~> 1.5",
      elixirc_paths: elixirc_paths(Mix.env()),
      compilers: [:phoenix, :gettext] ++ Mix.compilers(),
      start_permanent: Mix.env() == :prod,
      aliases: aliases(),
      deps: deps()
    ]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [
      mod: {Wwwtech.Application, []},
      extra_applications: [:logger, :runtime_tools]
    ]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [
      {:phoenix, "~> 1.4.10"},
      {:phoenix_pubsub, "~> 1.1"},
      {:phoenix_ecto, "~> 4.0"},
      {:ecto_sql, "~> 3.1"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 2.11"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:gettext, "~> 0.11"},
      {:jason, "~> 1.0"},
      {:plug_cowboy, "~> 2.0"},
      {:argon2_elixir, "~> 2.0"},
      {:timex, "~> 3.5"},
      {:earmark, "~> 1.4.0"},
      {:xml_builder, "~> 2.1"},
      {:exexif, "~> 0.0.5"},
      {:mogrify, "~> 0.7.3"},
      {:microformats2, "~> 0.1"},
      {:webmentions, "~> 0.3"},
      {:floki, "~> 0.23"},
      {:bamboo, "~> 1.2"},
      {:bamboo_smtp, "~> 1.5"},
      {:appsignal, "~> 1.0"},
      {:tesla, "~> 1.3.0"}
    ]
  end

  # Aliases are shortcuts or tasks specific to the current project.
  # For example, to create, migrate and run the seeds file at once:
  #
  #     $ mix ecto.setup
  #
  # See the documentation for `Mix` for more info on aliases.
  defp aliases do
    [
      "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      test: ["ecto.create --quiet", "ecto.migrate", "test"],
      build: "cmd ./.build/build",
      deploy: "cmd ./.build/deploy"
    ]
  end
end


Version 1.0.0-rc6

Version 1.0.0-rc6

defmodule ReleaseManager.Mixfile do
  use Mix.Project

  def project do
    [ app: :exrm,
      version: "1.0.0-rc6",
      elixir: "~> 1.0",
      description: description,
      package: package,
      deps: deps,
      docs: docs,
      test_coverage: [tool: Coverex.Task, coveralls: true]]
  end

  def application, do: [
    applications: [:logger, :relx]
  ]

  def deps do
    [{:relx, "~> 3.5.0" },
     {:earmark, "~> 0.1", only: :dev},
     {:ex_doc, "~> 0.10", only: :dev},
     {:coverex, "~> 1.4", only: :test}]
  end

  defp description do
    """
    Exrm, or Elixir Release Manager, provides mix tasks for building,
    upgrading, and controlling release packages for your application.
    """
  end

  defp package do
    [ files: ["lib", "priv", "mix.exs", "README.md", "LICENSE"],
      maintainers: ["Paul Schoenfelder"],
      licenses: ["MIT"],
      links: %{ "GitHub": "https://github.com/bitwalker/exrm" } ]
  end

  defp docs do
    [main: "extra-getting-started",
     extras: [
        "docs/Getting Started.md",
        "docs/Release Configuration.md",
        "docs/Deployment.md",
        "docs/Upgrades and Downgrades.md",
        "docs/Common Issues.md",
        "docs/Examples.md"
    ]]
  end

end

defmodule ReleaseManager.Mixfile do
  use Mix.Project

  def project do
    [ app: :exrm,
      version: "1.0.0-rc5",
      elixir: "~> 1.0",
      description: description,
      package: package,
      deps: deps,
      docs: docs,
      test_coverage: [tool: Coverex.Task, coveralls: true]]
  end

  def application, do: [
    applications: [:logger, :relx]
  ]

  def deps do
    [{:relx, "~> 3.5.0" },
     {:earmark, "~> 0.1", only: :dev},
     {:ex_doc, "~> 0.10", only: :dev},
     {:coverex, "~> 1.4", only: :test}]
  end

  defp description do
    """
    Exrm, or Elixir Release Manager, provides mix tasks for building,
    upgrading, and controlling release packages for your application.
    """
  end

  defp package do
    [ files: ["lib", "priv", "mix.exs", "README.md", "LICENSE"],
      maintainers: ["Paul Schoenfelder"],
      licenses: ["MIT"],
      links: %{ "GitHub": "https://github.com/bitwalker/exrm" } ]
  end

  defp docs do
    [main: "extra-getting-started",
     extras: [
        "docs/Getting Started.md",
        "docs/Release Configuration.md",
        "docs/Deployment.md",
        "docs/Upgrades and Downgrades.md",
        "docs/Common Issues.md",
        "docs/Examples.md"
    ]]
  end

end


Fixed earmark dependency for docs until 0.2.x is fixed

defmodule CSV.Mixfile do
  use Mix.Project

  def project do
    [
        app: :csv,
        version: "1.2.3",
        elixir: "~> 1.1",
        deps: deps,
        package: package,
        docs: &docs/0,
        name: "CSV",
        consolidate_protocols: true,
        source_url: "https://github.com/beatrichartz/csv",
        description: "CSV Decoding and Encoding for Elixir"
    ]
  end

  defp package do
    [
        maintainers: ["Beat Richartz"],
        licenses: ["MIT"],
        links: %{github: "https://github.com/beatrichartz/csv" }
    ]
  end

  defp deps do
    [
      {:benchfella, only: :bench},
      {:ex_csv, only: :bench},
      {:csvlixir, only: :bench},
      {:cesso, only: :bench},
      {:ex_doc, "0.9.0", only: :docs},
      {:inch_ex, only: :docs},
      {:earmark, "0.1.19", only: :docs}
    ]
  end

  defp docs do
    {ref, 0} = System.cmd("git", ["rev-parse", "--verify", "--quiet", "HEAD"])

    [
        source_ref: ref,
        main: "overview"
    ]
  end
end

defmodule CSV.Mixfile do
  use Mix.Project

  def project do
    [
        app: :csv,
        version: "1.2.3",
        elixir: "~> 1.1",
        deps: deps,
        package: package,
        docs: &docs/0,
        name: "CSV",
        consolidate_protocols: true,
        source_url: "https://github.com/beatrichartz/csv",
        description: "CSV Decoding and Encoding for Elixir"
    ]
  end

  defp package do
    [
        maintainers: ["Beat Richartz"],
        licenses: ["MIT"],
        links: %{github: "https://github.com/beatrichartz/csv" }
    ]
  end

  defp deps do
    [
      {:benchfella, only: :bench},
      {:ex_csv, only: :bench},
      {:csvlixir, only: :bench},
      {:cesso, only: :bench},
      {:ex_doc, "0.9.0", only: :docs},
      {:inch_ex, only: :docs},
      {:earmark, only: :docs}
    ]
  end

  defp docs do
    {ref, 0} = System.cmd("git", ["rev-parse", "--verify", "--quiet", "HEAD"])

    [
        source_ref: ref,
        main: "overview"
    ]
  end
end


add package

add package

defmodule HttpProxy.Mixfile do
  use Mix.Project

  def project do
    [app: :http_proxy,
     version: "0.1.0",
     elixir: "~> 1.0",
     name: "ExHttpProxy",
     source_url: "https://github.com/KazuCocoa/http_proxy",
     description: "Multi port HTTP Proxy",
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps,
     package: package,
     aliases: aliases]
  end

  def application do
    [
      applications: [:logger, :cowboy, :plug, :hackney],
      mod: {HttpProxy, []}
    ]
  end

  defp aliases do
    [proxy: ["run --no-halt"]]
  end

  defp deps do
    [
      {:cowboy, "~> 1.0.0" },
      {:plug, "~> 1.0.0"},
      {:hackney, "~> 1.3.2"},
      {:ex_parametarized, "~> 1.0.0", only: :test}
    ]
  end

  defp package do
    [
      files: ~w(lib mix.exs README.md LICENSE),
      maintainers: ["Kazuaki Matsuo"],
      licenses: ["MIT"],
      links: %{"GitHub" => "https://github.com/KazuCocoa/http_proxy"}
    ]
  end
end

defmodule HttpProxy.Mixfile do
  use Mix.Project

  def project do
    [app: :http_proxy,
     version: "0.1.0",
     elixir: "~> 1.0",
     name: "ExHttpProxy",
     source_url: "https://github.com/KazuCocoa/http_proxy",
     description: "Multi port HTTP Proxy",
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps,
     aliases: aliases]
  end

  def application do
    [
      applications: [:logger, :cowboy, :plug, :hackney],
      mod: {HttpProxy, []}
    ]
  end

  defp aliases do
    [proxy: ["run --no-halt"]]
  end

  defp deps do
    [
      {:cowboy, "~> 1.0.0" },
      {:plug, "~> 1.0.0"},
      {:hackney, "~> 1.3.2"},
      {:ex_parametarized, "~> 1.0.0", only: :test}
    ]
  end

  defp package do
    [
      files: ~w(lib mix.exs README.md LICENSE),
      maintainers: ["Kazuaki Matsuo"],
      licenses: ["MIT"],
      links: %{"GitHub" => "https://github.com/KazuCocoa/http_proxy"}
    ]
  end
end


Add phoenix (because of upcoming WebSocket Proxy)

defmodule Microcrawler.Mixfile do
  use Mix.Project

  def project do
    [
      app: :microcrawler,
      version: "0.0.1",
      elixir: "~> 1.3",
      elixirc_paths: elixirc_paths(Mix.env),
      compilers: Mix.compilers,
      build_embedded: Mix.env == :prod,
      start_permanent: Mix.env == :prod,
      deps: deps,
      dialyzer: [plt_add_deps: [:apex]]
    ]
  end

  # Configuration for the OTP application
  #
  # Type `mix help compile.app` for more information
  def application do
    [mod: {Microcrawler, []},
     applications: [:logger, :crypto]]
  end

  # Specifies your project dependencies
  #
  # Type `mix help deps` for examples and options
  defp deps do
    [
      {:amqp_client, git: "https://github.com/jbrisbin/amqp_client.git", override: true},
      {:amqp, "~> 0.1.4"},
      {:apex, "~>0.5.2"},
      {:cberl, git: "https://github.com/chitika/cberl", override: true},
      {:dialyxir, "~> 0.3.5", only: [:dev]},
      {:distillery, "~> 0.9"},
      {:execjs, "~> 1.1.3"},
      {:logger_file_backend, "~> 0.0.8"},
      {:phoenix, "~> 1.2.1"},
      {:poison, "~> 1.5"},
      {:tirexs, "~> 0.8.8"}
    ]
  end

  defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
  defp elixirc_paths(_),     do: ["lib", "web"]
end

defmodule Microcrawler.Mixfile do
  use Mix.Project

  def project do
    [
      app: :microcrawler,
      version: "0.0.1",
      elixir: "~> 1.3",
      elixirc_paths: elixirc_paths(Mix.env),
      compilers: Mix.compilers,
      build_embedded: Mix.env == :prod,
      start_permanent: Mix.env == :prod,
      deps: deps,
      dialyzer: [plt_add_deps: [:apex]]
    ]
  end

  # Configuration for the OTP application
  #
  # Type `mix help compile.app` for more information
  def application do
    [mod: {Microcrawler, []},
     applications: [:logger, :crypto]]
  end

  # Specifies your project dependencies
  #
  # Type `mix help deps` for examples and options
  defp deps do
    [
      {:amqp_client, git: "https://github.com/jbrisbin/amqp_client.git", override: true},
      {:amqp, "~> 0.1.4"},
      {:apex, "~>0.5.2"},
      {:cberl, git: "https://github.com/chitika/cberl", override: true},
      {:dialyxir, "~> 0.3.5", only: [:dev]},
      {:distillery, "~> 0.9"},
      {:execjs, "~> 1.1.3"},
      {:logger_file_backend, "~> 0.0.8"},
      {:poison, "~> 1.5"},
      {:tirexs, "~> 0.8.8"}
    ]
  end

  defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
  defp elixirc_paths(_),     do: ["lib", "web"]
end


use farmbot nerves system rpi3

use farmbot nerves system rpi3

defmodule Farmbot.Mixfile do
  use Mix.Project
  @target System.get_env("MIX_TARGET") || "host"
  @version Path.join(__DIR__, "VERSION") |> File.read! |> String.trim

  defp commit() do
    {t,_} = System.cmd("git", ["log", "--pretty=format:%h", "-1"])
    t
  end

  Mix.shell.info([:green, """
  Env
    MIX_TARGET:   #{@target}
    MIX_ENV:      #{Mix.env}
  """, :reset])

  def project do
    [app: :farmbot,
     description: "The Brains of the Farmbot Project",
     package: package(),
     test_coverage: [tool: ExCoveralls],
     version: @version,
     target: @target,
     commit: commit(),
     archives: [nerves_bootstrap: "~> 0.6.0"],
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps_path: "deps/#{@target}",
     build_path: "_build/#{@target}",
     lockfile: "mix.lock.#{@target}",
     config_path: "config/config.exs",
     lockfile: "mix.lock",
     elixirc_paths: elixirc_paths(Mix.env, @target),
     aliases: aliases(@target),
     deps: deps() ++ deps(@target),
     dialyzer: [
       plt_add_deps: :transitive,
       flags:        []
     ],
     preferred_cli_env: [
       "test":             :test,
       "coveralls":        :test,
       "coveralls.detail": :test,
       "coveralls.post":   :test,
       "coveralls.html":   :test,
       "coveralls.travis": :test
     ],
     source_url: "https://github.com/Farmbot/farmbot_os",
     homepage_url: "http://farmbot.io",
     docs: [
       main: "Farmbot",
       logo: "priv/static/farmbot_logo.png",
       extras: [
         "docs/BUILDING.md",
         "docs/FAQ.md",
         "README.md"
       ]
     ]
   ]
  end

  def application do
    [mod: {Farmbot, []}, extra_applications: [:logger]]
  end

  defp deps do
    [
      {:nerves, "~> 0.7.5", runtime: false},

      {:gen_mqtt, "~> 0.3.1"},
      {:vmq_commons, "1.0.0", manager: :rebar3},

      {:poison, "~> 3.0"},
      {:ex_json_schema, "~> 0.5.3"},
      {:rsa, "~> 0.0.1"},
      {:httpoison, "~> 0.13.0"},

      {:tzdata, "~> 0.1.201601", override: true},
      {:timex, "~> 3.1.13"},

      # {:fs, "~> 0.9.1"},
      {:nerves_uart, "0.1.2"},
      {:uuid, "~> 1.1" },

      {:cowboy, "~> 1.0.0"},
      {:plug, "~> 1.0"},
      {:ecto, "~> 2.2.2"},
      {:sqlite_ecto2, "~> 2.2.1"}
    ]
  end

  defp deps("host") do
    [
      {:credo, "~> 0.8", only: [:dev, :test], runtime: false},
      {:ex_doc, "~> 0.14", only: :dev},
      {:excoveralls, "~> 0.6", only: :test},
      {:mock, "~> 0.2.0", only: :test},
    ]
  end

  defp deps(target) do
    [ system(target),
      {:bootloader, "~> 0.1"},
      {:nerves_runtime, "~> 0.4"},
      {:nerves_network, "~> 0.3"},
      {:nerves_firmware_ssh, "~> 0.2"},
    ]
  end

  defp system("rpi3"), do: {:nerves_system_farmbot_rpi3, "0.16.2-farmbot", runtime: false}
  defp system("rpi0"), do: {:nerves_system_rpi0, ">= 0.0.0", runtime: false}
  defp system("qemu_arm"), do: {:nerves_system_qemu_arm, ">= 0.0.0", runtime: false}

  defp package do
    [
      name: "Farmbot OS",
      maintainers: "Farmbot.io",
      licenses: "MIT"
    ]
  end

  defp elixirc_paths(:dev, "host") do
    ["./lib", "./nerves/host"]
  end

  defp elixirc_paths(:test, "host") do
    ["./lib", "./nerves/host", "./test/support"]
  end

  defp elixirc_paths(_env, _target) do
    ["./lib", "./nerves/target"]
  end

  defp aliases("host"), do: []

  defp aliases(_system) do
    ["deps.precompile": ["nerves.precompile", "deps.precompile"],
     "deps.loadpaths":  ["deps.loadpaths", "nerves.loadpaths"]
    ]
  end
end

defmodule Farmbot.Mixfile do
  use Mix.Project
  @target System.get_env("MIX_TARGET") || "host"
  @version Path.join(__DIR__, "VERSION") |> File.read! |> String.trim

  defp commit() do
    {t,_} = System.cmd("git", ["log", "--pretty=format:%h", "-1"])
    t
  end

  Mix.shell.info([:green, """
  Env
    MIX_TARGET:   #{@target}
    MIX_ENV:      #{Mix.env}
  """, :reset])

  def project do
    [app: :farmbot,
     description: "The Brains of the Farmbot Project",
     package: package(),
     test_coverage: [tool: ExCoveralls],
     version: @version,
     target: @target,
     commit: commit(),
     archives: [nerves_bootstrap: "~> 0.6.0"],
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps_path: "deps/#{@target}",
     build_path: "_build/#{@target}",
     lockfile: "mix.lock.#{@target}",
     config_path: "config/config.exs",
     lockfile: "mix.lock",
     elixirc_paths: elixirc_paths(Mix.env, @target),
     aliases: aliases(@target),
     deps: deps() ++ deps(@target),
     dialyzer: [
       plt_add_deps: :transitive,
       flags:        []
     ],
     preferred_cli_env: [
       "test":             :test,
       "coveralls":        :test,
       "coveralls.detail": :test,
       "coveralls.post":   :test,
       "coveralls.html":   :test,
       "coveralls.travis": :test
     ],
     source_url: "https://github.com/Farmbot/farmbot_os",
     homepage_url: "http://farmbot.io",
     docs: [
       main: "Farmbot",
       logo: "priv/static/farmbot_logo.png",
       extras: [
         "docs/BUILDING.md",
         "docs/FAQ.md",
         "README.md"
       ]
     ]
   ]
  end

  def application do
    [mod: {Farmbot, []}, extra_applications: [:logger]]
  end

  defp deps do
    [
      {:nerves, "~> 0.7.5", runtime: false},

      {:gen_mqtt, "~> 0.3.1"},
      {:vmq_commons, "1.0.0", manager: :rebar3},

      {:poison, "~> 3.0"},
      {:ex_json_schema, "~> 0.5.3"},
      {:rsa, "~> 0.0.1"},
      {:httpoison, "~> 0.13.0"},

      {:tzdata, "~> 0.1.201601", override: true},
      {:timex, "~> 3.1.13"},

      # {:fs, "~> 0.9.1"},
      {:nerves_uart, "0.1.2"},
      {:uuid, "~> 1.1" },

      {:cowboy, "~> 1.0.0"},
      {:plug, "~> 1.0"},
      {:ecto, "~> 2.2.2"},
      {:sqlite_ecto2, "~> 2.2.1"}
    ]
  end

  defp deps("host") do
    [
      {:credo, "~> 0.8", only: [:dev, :test], runtime: false},
      {:ex_doc, "~> 0.14", only: :dev},
      {:excoveralls, "~> 0.6", only: :test},
      {:mock, "~> 0.2.0", only: :test},
    ]
  end

  defp deps(target) do
    [ system(target),
      {:bootloader, "~> 0.1"},
      {:nerves_runtime, "~> 0.4"},
      {:nerves_network, "~> 0.3"},
      {:nerves_firmware_ssh, "~> 0.2"},
    ]
  end

  defp system("rpi3"), do: {:nerves_system_rpi3, "~> 0.16.1", runtime: false}
  defp system("rpi0"), do: {:nerves_system_rpi0, ">= 0.0.0", runtime: false}
  defp system("qemu_arm"), do: {:nerves_system_qemu_arm, ">= 0.0.0", runtime: false}

  defp package do
    [
      name: "Farmbot OS",
      maintainers: "Farmbot.io",
      licenses: "MIT"
    ]
  end

  defp elixirc_paths(:dev, "host") do
    ["./lib", "./nerves/host"]
  end

  defp elixirc_paths(:test, "host") do
    ["./lib", "./nerves/host", "./test/support"]
  end

  defp elixirc_paths(_env, _target) do
    ["./lib", "./nerves/target"]
  end

  defp aliases("host"), do: []

  defp aliases(_system) do
    ["deps.precompile": ["nerves.precompile", "deps.precompile"],
     "deps.loadpaths":  ["deps.loadpaths", "nerves.loadpaths"]
    ]
  end
end


Use parentheses for methods, avoid warnings

defmodule SendGrid.Mixfile do
  use Mix.Project

  def project do
    [app: :sendgrid,
     version: "1.3.0",
     elixir: "~> 1.2",
     package: package(),
     description: description(),
     source_url: project_url(),
     homepage_url: project_url(),
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps()]
  end

  def application do
    [
      applications: [
        :logger,
        :httpoison
      ]
    ]
  end

  defp deps do
    [
      {:earmark,     "~> 0.1",  only: :dev},
      {:ex_doc,      "~> 0.11", only: :dev},
      {:httpoison,   "~> 0.11.0"},
      {:poison,      "~> 3.0"}
    ]
  end

  defp description do
    """
    A wrapper for SendGrid's API to create composable emails.
    """
  end

  defp project_url do
    """
    https://github.com/alexgaribay/sendgrid_elixir
    """
  end

  defp package do
    [
      files: ["lib", "mix.exs", "LICENSE", "README.md"],
      maintainers: ["Alex Garibay"],
      licenses: ["MIT"],
      links: %{"GitHub" => project_url()}
    ]
  end

end

defmodule SendGrid.Mixfile do
  use Mix.Project

  def project do
    [app: :sendgrid,
     version: "1.3.0",
     elixir: "~> 1.2",
     package: package,
     description: description,
     source_url: project_url,
     homepage_url: project_url,
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps]
  end

  def application do
    [
      applications: [
        :logger,
        :httpoison
      ]
    ]
  end

  defp deps do
    [
      {:earmark,     "~> 0.1",  only: :dev},
      {:ex_doc,      "~> 0.11", only: :dev},
      {:httpoison,   "~> 0.11.0"},
      {:poison,      "~> 3.0"}
    ]
  end

  defp description do
    """
    A wrapper for SendGrid's API to create composable emails.
    """
  end

  defp project_url do
    """
    https://github.com/alexgaribay/sendgrid_elixir
    """
  end

  defp package do
    [
      files: ["lib", "mix.exs", "LICENSE", "README.md"],
      maintainers: ["Alex Garibay"],
      licenses: ["MIT"],
      links: %{"GitHub" => project_url}
    ]
  end

end


Preparing port of 2.2.1 update to 2.3

Preparing port of 2.2.1 update to 2.3

defmodule Ewebmachine.Mixfile do
  use Mix.Project

  @description """
  Ewebmachine contains macros and plugs to allow you to compose
  HTTP decision handlers and run the HTTP decision tree to get
  your HTTP response. This project is a rewrite for Elixir and
  Plug of basho webmachine.
  """

  def project, do: [
    app: :ewebmachine,
    elixir: ">= 1.10.0",
    version: "2.3.1-dev",
    docs: docs(),
    deps: deps(),
    description: @description,
    package: package()
  ]

  def application, do: [
    mod: { Ewebmachine.App, [] },
    extra_applications: [:inets],
    env: []
  ]

  defp docs, do: [
    main: "Ewebmachine",
    source_url: "https://github.com/kbrw/ewebmachine",
    source_ref: "master"
  ]

  defp deps, do: [
    {:plug, "~> 1.10"},
    {:plug_cowboy, "~> 2.4", optional: true},
    {:ex_doc, ">= 0.0.0", only: :dev},
    {:dialyxir, "~> 0.5", only: [:dev], runtime: false}
  ]

  defp package, do: [
    links: %{ "Source" => "http://github.com/kbrw/ewebmachine",
              "Doc" => "http://hexdocs.pm/ewebmachine" },
    maintainers: ["Arnaud Wetzel", "Yurii Rashkovskii", "Jean Parpaillon"],
    licenses: ["MIT"],
    files: ["lib", "priv", "mix.exs", "README*", "templates", "LICENSE*", "CHANGELOG*", "examples"]
  ]
end

defmodule Ewebmachine.Mixfile do
  use Mix.Project

  @description """
  Ewebmachine contains macros and plugs to allow you to compose
  HTTP decision handlers and run the HTTP decision tree to get
  your HTTP response. This project is a rewrite for Elixir and
  Plug of basho webmachine.
  """

  def project, do: [
    app: :ewebmachine,
    elixir: ">= 1.10.0",
    version: "2.3.0",
    docs: docs(),
    deps: deps(),
    description: @description,
    package: package()
  ]

  def application, do: [
    mod: { Ewebmachine.App, [] },
    extra_applications: [:inets],
    env: []
  ]

  defp docs, do: [
    main: "Ewebmachine",
    source_url: "https://github.com/kbrw/ewebmachine",
    source_ref: "master"
  ]

  defp deps, do: [
    {:plug, "~> 1.10"},
    {:plug_cowboy, "~> 2.4", optional: true},
    {:ex_doc, ">= 0.0.0", only: :dev},
    {:dialyxir, "~> 0.5", only: [:dev], runtime: false}
  ]

  defp package, do: [
    links: %{ "Source" => "http://github.com/kbrw/ewebmachine",
              "Doc" => "http://hexdocs.pm/ewebmachine" },
    maintainers: ["Arnaud Wetzel", "Yurii Rashkovskii", "Jean Parpaillon"],
    licenses: ["MIT"],
    files: ["lib", "priv", "mix.exs", "README*", "templates", "LICENSE*", "CHANGELOG*", "examples"]
  ]
end


Version 2.0.4

Version 2.0.4

defmodule Distillery.Mixfile do
  use Mix.Project

  def project do
    [
      app: :distillery,
      version: "2.0.4",
      elixir: "~> 1.6",
      build_embedded: Mix.env() == :prod,
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      description: description(),
      package: package(),
      docs: docs(),
      aliases: aliases(),
      elixirc_paths: elixirc_paths(Mix.env),
      preferred_cli_env: [
        docs: :docs,
        "hex.publish": :docs,
        "eqc.mini": :test,
        coveralls: :test,
        "coveralls.detail": :test,
        "coveralls.html": :test,
        "coveralls.json": :test,
        "coveralls.post": :test,
      ],
      test_coverage: [tool: ExCoveralls],
      dialyzer: [
        flags: [:error_handling, :race_conditions, :underspecs]
      ]
    ]
  end

  def application do
    [extra_applications: [:runtime_tools, :logger]]
  end

  defp deps do
    [
      {:artificery, "~> 0.2"},
      {:ex_doc, "~> 0.13", only: [:docs]},
      {:excoveralls, "~> 0.6", only: [:test]},
      {:eqc_ex, "~> 1.4", only: [:test]},
      {:ex_unit_clustered_case, "~> 0.3", only: [:test], runtime: false},
      {:dialyxir, "~> 1.0.0-rc.2", only: [:dev], runtime: false}
    ]
  end

  defp description do
    """
    Build releases of your Mix projects with ease!
    """
  end

  defp package do
    [
      files: ["lib", "priv", "mix.exs", "README.md", "LICENSE.md"],
      maintainers: ["Paul Schoenfelder"],
      licenses: ["MIT"],
      links: %{
        Documentation: "https://hexdocs.pm/distillery",
        Changelog: "https://hexdocs.pm/distillery/changelog.html",
        GitHub: "https://github.com/bitwalker/distillery"
      }
    ]
  end

  defp aliases do
    [
      docs: [&mkdocs/1, "docs"],
      c: ["compile", "format --check-equivalent"],
      "compile-check": [
        "compile",
        "format --check-formatted --dry-run",
        "dialyzer --halt-exit-status"
      ],
    ]
  end

  defp mkdocs(_args) do
    docs = Path.join([File.cwd!, "bin", "docs"])
    {_, 0} = System.cmd(docs, ["build"], into: IO.stream(:stdio, :line))
  end

  defp docs do
    [
      source_url: "https://github.com/bitwalker/distillery",
      homepage_url: "https://github.com/bitwalker/distillery",
      main: "home"
    ]
  end

  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]
end

defmodule Distillery.Mixfile do
  use Mix.Project

  def project do
    [
      app: :distillery,
      version: "2.0.3",
      elixir: "~> 1.6",
      build_embedded: Mix.env() == :prod,
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      description: description(),
      package: package(),
      docs: docs(),
      aliases: aliases(),
      elixirc_paths: elixirc_paths(Mix.env),
      preferred_cli_env: [
        docs: :docs,
        "hex.publish": :docs,
        "eqc.mini": :test,
        coveralls: :test,
        "coveralls.detail": :test,
        "coveralls.html": :test,
        "coveralls.json": :test,
        "coveralls.post": :test,
      ],
      test_coverage: [tool: ExCoveralls],
      dialyzer: [
        flags: [:error_handling, :race_conditions, :underspecs]
      ]
    ]
  end

  def application do
    [extra_applications: [:runtime_tools, :logger]]
  end

  defp deps do
    [
      {:artificery, "~> 0.2"},
      {:ex_doc, "~> 0.13", only: [:docs]},
      {:excoveralls, "~> 0.6", only: [:test]},
      {:eqc_ex, "~> 1.4", only: [:test]},
      {:ex_unit_clustered_case, "~> 0.3", only: [:test], runtime: false},
      {:dialyxir, "~> 1.0.0-rc.2", only: [:dev], runtime: false}
    ]
  end

  defp description do
    """
    Build releases of your Mix projects with ease!
    """
  end

  defp package do
    [
      files: ["lib", "priv", "mix.exs", "README.md", "LICENSE.md"],
      maintainers: ["Paul Schoenfelder"],
      licenses: ["MIT"],
      links: %{
        Documentation: "https://hexdocs.pm/distillery",
        Changelog: "https://hexdocs.pm/distillery/changelog.html",
        GitHub: "https://github.com/bitwalker/distillery"
      }
    ]
  end

  defp aliases do
    [
      docs: [&mkdocs/1, "docs"],
      c: ["compile", "format --check-equivalent"],
      "compile-check": [
        "compile",
        "format --check-formatted --dry-run",
        "dialyzer --halt-exit-status"
      ],
    ]
  end

  defp mkdocs(_args) do
    docs = Path.join([File.cwd!, "bin", "docs"])
    {_, 0} = System.cmd(docs, ["build"], into: IO.stream(:stdio, :line))
  end

  defp docs do
    [
      source_url: "https://github.com/bitwalker/distillery",
      homepage_url: "https://github.com/bitwalker/distillery",
      main: "home"
    ]
  end

  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]
end


update

update

defmodule Eeb.Mixfile do
  use Mix.Project

  @version "0.1.1"

  def project do
    [app: :eeb,
     version: @version,
     aliases: aliases,
     elixir: "~> 1.1",
     description: description,
     package: package,
     source_url: "https://github.com/aborn/eeb",
     homepage_url: "https://github.com/aborn/eeb",
     deps: deps,
     test_coverage: [tool: ExCoveralls]]
  end

  def application do
    [
     applications: [:logger,:tzdata,:cowboy],
     mod: {Eeb, []}
    ]
  end

  defp description do
  """
  Elixir extendable blog.
  """
  end

  defp package do
    [
      maintainers: ["Aborn Jiang"],
      licenses: ["MIT"],
      links: %{"GitHub" => "https://github.com/aborn/eeb"}]
  end

  defp deps do
    [{:earmark, "~> 0.1.19", only: :dev},
     {:ex_doc, "~> 0.11.1", only: :docs},
     {:timex, "~> 1.0.0", only: :dev},
     {:cowboy, "~> 1.0", only: :dev},
     {:plug, "~> 0.14", only: :dev},
     {:excoveralls, "~> 0.4", only: :test},
     {:tzdata, "~> 0.1.8", only: :dev}]  ## https://github.com/bitwalker/timex/issues/86
  end

  defp aliases do
    [compile: ["deps.check", &unload_hex/1, "compile"],
     run: [&unload_hex/1, "run"],
     install: ["archive.build -o archives/eeb.ez", "archive.install archives/eeb.ez --force"],
     uninstall: ["archive.uninstall eeb.ez"]]
  end

  defp unload_hex(_) do
    paths = Path.join(Mix.Local.archives_path, "eeb*.ez") |> Path.wildcard

    Enum.each(paths, fn archive ->
      ebin = Mix.Archive.ebin(archive)
      Code.delete_path(ebin)

      {:ok, files} = :erl_prim_loader.list_dir(to_char_list(ebin))

      Enum.each(files, fn file ->
        file = List.to_string(file)
        size = byte_size(file) - byte_size(".beam")

        case file do
          <<name :: binary-size(size), ".beam">> ->
            module = String.to_atom(name)
            :code.delete(module)
            :code.purge(module)
          _ ->
            :ok
        end
      end)
    end)
  end

end

defmodule Eeb.Mixfile do
  use Mix.Project

  @version "0.1.0"

  def project do
    [app: :eeb,
     version: @version,
     aliases: aliases,
     elixir: "~> 1.1",
     description: description,
     package: package,
     source_url: "https://github.com/aborn/eeb",
     homepage_url: "https://github.com/aborn/eeb",
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps,
     test_coverage: [tool: ExCoveralls]]
  end

  def application do
    [
     applications: [:logger,:tzdata,:cowboy],
     mod: {Eeb, []}
    ]
  end

  defp description do
  """
  Elixir extendable blog.
  """
  end

  defp package do
    [
      maintainers: ["Aborn Jiang"],
      licenses: ["MIT"],
      links: %{"GitHub" => "https://github.com/aborn/eeb"}]
  end

  defp deps do
    [{:earmark, "~> 0.1.19"},
     {:ex_doc, "~> 0.11.1", only: :docs},
     {:timex, "~> 1.0.0"},
     {:cowboy, "~> 1.0" },
     {:plug, "~> 0.14" },
     {:excoveralls, "~> 0.4", only: :test},
     {:tzdata, "~> 0.1.8"}]  ## https://github.com/bitwalker/timex/issues/86
  end

  defp aliases do
    [compile: ["deps.check", &unload_hex/1, "compile"],
     run: [&unload_hex/1, "run"],
     install: ["archive.build -o archives/eeb.ez", "archive.install archives/eeb.ez --force"],
     uninstall: ["archive.uninstall eeb.ez"]]
  end

  defp unload_hex(_) do
    paths = Path.join(Mix.Local.archives_path, "eeb*.ez") |> Path.wildcard

    Enum.each(paths, fn archive ->
      ebin = Mix.Archive.ebin(archive)
      Code.delete_path(ebin)

      {:ok, files} = :erl_prim_loader.list_dir(to_char_list(ebin))

      Enum.each(files, fn file ->
        file = List.to_string(file)
        size = byte_size(file) - byte_size(".beam")

        case file do
          <<name :: binary-size(size), ".beam">> ->
            module = String.to_atom(name)
            :code.delete(module)
            :code.purge(module)
          _ ->
            :ok
        end
      end)
    end)
  end

end


Enabled build target selection based on CONREAL_TARGET.

defmodule Conreality.Mixfile do
  use Mix.Project

  @target System.get_env("CONREAL_TARGET") ||  System.get_env("NERVES_TARGET") || "qemu_arm"

  def project do
    [app: :conreality,
     version: "0.0.1",
     target: @target,
     archives: [nerves_bootstrap: "~> 0.1.4"],
     deps_path: "deps/#{@target}",
     build_path: "_build/#{@target}",
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     aliases: aliases,
     deps: deps ++ system(@target)]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [mod: {Conreality, []},
     applications: [:logger]]
  end

  def deps do
    [{:nerves, "~> 0.3.0"}]
  end

  def system(target) do
    [{:"nerves_system_#{target}", ">= 0.0.0"}]
  end

  def aliases do
    ["deps.precompile": ["nerves.precompile", "deps.precompile"],
     "deps.loadpaths":  ["deps.loadpaths", "nerves.loadpaths"]]
  end

end

defmodule Conreality.Mixfile do
  use Mix.Project

  @target System.get_env("NERVES_TARGET") || "qemu_arm"

  def project do
    [app: :conreality,
     version: "0.0.1",
     target: @target,
     archives: [nerves_bootstrap: "~> 0.1.4"],
     deps_path: "deps/#{@target}",
     build_path: "_build/#{@target}",
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     aliases: aliases,
     deps: deps ++ system(@target)]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [mod: {Conreality, []},
     applications: [:logger]]
  end

  def deps do
    [{:nerves, "~> 0.3.0"}]
  end

  def system(target) do
    [{:"nerves_system_#{target}", ">= 0.0.0"}]
  end

  def aliases do
    ["deps.precompile": ["nerves.precompile", "deps.precompile"],
     "deps.loadpaths":  ["deps.loadpaths", "nerves.loadpaths"]]
  end

end


Add alias for phoenix.server

Add alias for phoenix.server

defmodule HelloPhoenixVuejs.Mixfile do
  use Mix.Project

  def project do
    [app: :hello_phoenix_vuejs,
     version: "0.0.1",
     elixir: "~> 1.2",
     elixirc_paths: elixirc_paths(Mix.env),
     compilers: [:phoenix, :gettext] ++ Mix.compilers,
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps(),
     aliases: aliases()]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [mod: {HelloPhoenixVuejs, []},
     applications: [:phoenix, :phoenix_pubsub, :phoenix_html, :cowboy, :logger, :gettext]]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
  defp elixirc_paths(_),     do: ["lib", "web"]

  defp aliases do
    [ps: "phoenix.server"]
  end

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [{:phoenix, "~> 1.2.1"},
     {:phoenix_pubsub, "~> 1.0"},
     {:phoenix_html, "~> 2.6"},
     {:phoenix_live_reload, "~> 1.0", only: :dev},
     {:gettext, "~> 0.11"},
     {:cowboy, "~> 1.0"}]
  end
end

defmodule HelloPhoenixVuejs.Mixfile do
  use Mix.Project

  def project do
    [app: :hello_phoenix_vuejs,
     version: "0.0.1",
     elixir: "~> 1.2",
     elixirc_paths: elixirc_paths(Mix.env),
     compilers: [:phoenix, :gettext] ++ Mix.compilers,
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps()]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [mod: {HelloPhoenixVuejs, []},
     applications: [:phoenix, :phoenix_pubsub, :phoenix_html, :cowboy, :logger, :gettext]]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
  defp elixirc_paths(_),     do: ["lib", "web"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [{:phoenix, "~> 1.2.1"},
     {:phoenix_pubsub, "~> 1.0"},
     {:phoenix_html, "~> 2.6"},
     {:phoenix_live_reload, "~> 1.0", only: :dev},
     {:gettext, "~> 0.11"},
     {:cowboy, "~> 1.0"}]
  end
end


Fix version to be semver

Fix version to be semver

defmodule SNMP.Mixfile do
  use Mix.Project

  def project do
    [ app: :snmp_ex,
      version: "0.2.0",
      elixir: "~> 1.7",
      build_embedded: Mix.env() == :prod,
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      description: description(),
      package: package(),
      dialyzer: [
        plt_add_apps: [
          :logger,
          :snmp,
          :netaddr_ex,
        ],
        ignore_warnings: "dialyzer.ignore",
        flags: [
          :unmatched_returns,
          :error_handling,
          :race_conditions,
          :underspecs,
        ],
      ],
    ]
  end

  def application do
    [ extra_applications: [
        :logger,
        :snmp,
      ],
      env: [
        timeout: 5000,
        max_repetitions: 10,
        engine_discovery_timeout: 1000,
        mib_cache:      "priv/snmp/mibs",
        snmp_conf_dir:  "priv/snmp/conf",
        snmpm_conf_dir: "priv/snmp",
        mib_sources: [
          "/usr/share/snmp/mibs",
        ],
      ],
      mod: {SNMP, []},
    ]
  end

  defp deps do
    [ {:netaddr_ex, "~> 1.0.5"},
    ]
  end

  defp description do
    "An SNMP client library for Elixir, wrapping the Erlang OTP SNMP API and Logic"
  end

    defp package do
    [ licenses: ["Mozilla Public License 2.0"],
      links: %{
        "GitHub" => "https://github.com/jonnystorm/snmp-elixir",
      },
    ]
  end

end

defmodule SNMP.Mixfile do
  use Mix.Project

  def project do
    [ app: :snmp_ex,
      version: "0.2",
      elixir: "~> 1.7",
      build_embedded: Mix.env() == :prod,
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      description: description(),
      package: package(),
      dialyzer: [
        plt_add_apps: [
          :logger,
          :snmp,
          :netaddr_ex,
        ],
        ignore_warnings: "dialyzer.ignore",
        flags: [
          :unmatched_returns,
          :error_handling,
          :race_conditions,
          :underspecs,
        ],
      ],
    ]
  end

  def application do
    [ extra_applications: [
        :logger,
        :snmp,
      ],
      env: [
        timeout: 5000,
        max_repetitions: 10,
        engine_discovery_timeout: 1000,
        mib_cache:      "priv/snmp/mibs",
        snmp_conf_dir:  "priv/snmp/conf",
        snmpm_conf_dir: "priv/snmp",
        mib_sources: [
          "/usr/share/snmp/mibs",
        ],
      ],
      mod: {SNMP, []},
    ]
  end

  defp deps do
    [ {:netaddr_ex, "~> 1.0.5"},
    ]
  end

  defp description do
    "An SNMP client library for Elixir, wrapping the Erlang OTP SNMP API and Logic"
  end

    defp package do
    [ licenses: ["Mozilla Public License 2.0"],
      links: %{
        "GitHub" => "https://github.com/jonnystorm/snmp-elixir",
      },
    ]
  end

end


bump version to 0.1.1 to fix broken hex package

defmodule Mix.Tasks.Compile.Myhtml do
  def run(_) do
    if match? {:win32, _}, :os.type do
      IO.warn "Windows is not yet a target."
      exit(1)
    else
      {result, _error_code} = System.cmd("make", ["priv/myhtmlex.so"], stderr_to_stdout: true)
      IO.binwrite result
    end
    :ok
  end
end

defmodule Myhtmlex.Mixfile do
  use Mix.Project

  def project do
    [
      app: :myhtmlex,
      version: "0.1.1",
      elixir: "~> 1.5",
      compilers: [:myhtml, :elixir, :app],
      start_permanent: Mix.env == :prod,
      description: "A module to decode HTML into a tree, porting all properties of the underlying library myhtml, being fast and correct in regards to the html spec.",
      package: package(),
      deps: deps()
    ]
  end

  def package do
    [
      maintainers: ["Lukas Rieder"],
      licenses: ["GNU LGPL"],
      links: %{
        "Github" => "https://github.com/Overbryd/myhtmlex",
        "Issues" => "https://github.com/Overbryd/myhtmlex/issues",
        "MyHTML" => "https://github.com/lexborisov/myhtml"
      },
      files: [
        "lib",
        "c_src",
        "Makefile",
        "Makefile.Darwin",
        "Makefile.Linux",
        "mix.exs",
        "README.md",
        "LICENSE"
      ]
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger]
    ]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      # documentation helpers
      {:ex_doc, ">= 0.0.0", only: :dev},
      # benchmarking helpers
      {:benchfella, "~> 0.3.0", only: :dev}
    ]
  end
end

defmodule Mix.Tasks.Compile.Myhtml do
  def run(_) do
    if match? {:win32, _}, :os.type do
      IO.warn "Windows is not yet a target."
      exit(1)
    else
      {result, _error_code} = System.cmd("make", ["priv/myhtmlex.so"], stderr_to_stdout: true)
      IO.binwrite result
    end
    :ok
  end
end

defmodule Myhtmlex.Mixfile do
  use Mix.Project

  def project do
    [
      app: :myhtmlex,
      version: "0.1.0",
      elixir: "~> 1.5",
      compilers: [:myhtml, :elixir, :app],
      start_permanent: Mix.env == :prod,
      description: "A module to decode HTML into a tree, porting all properties of the underlying library myhtml, being fast and correct in regards to the html spec.",
      package: package(),
      deps: deps()
    ]
  end

  def package do
    [
      maintainers: ["Lukas Rieder"],
      licenses: ["GNU LGPL"],
      links: %{
        "Github" => "https://github.com/Overbryd/myhtmlex",
        "Issues" => "https://github.com/Overbryd/myhtmlex/issues",
        "MyHTML" => "https://github.com/lexborisov/myhtml"
      },
      files: [
        "lib",
        "c_src",
        "Makefile",
        "Makefile.Darwin",
        "Makefile.Linux",
        "mix.exs",
        "README.md",
        "LICENSE"
      ]
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger]
    ]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      # documentation helpers
      {:ex_doc, ">= 0.0.0", only: :dev},
      # benchmarking helpers
      {:benchfella, "~> 0.3.0", only: :dev}
    ]
  end
end


Fix typo in test name (#10258)

Fix typo in test name (#10258)

Code.require_file("../test_helper.exs", __DIR__)

defmodule EEx.TokenizerTest do
  use ExUnit.Case, async: true
  require EEx.Tokenizer, as: T

  @opts %{indentation: 0, trim: false}

  test "simple chars lists" do
    assert T.tokenize('foo', 1, 1, @opts) == {:ok, [{:text, 'foo'}, {:eof, 1, 4}]}
  end

  test "simple strings" do
    assert T.tokenize("foo", 1, 1, @opts) == {:ok, [{:text, 'foo'}, {:eof, 1, 4}]}
  end

  test "strings with embedded code" do
    assert T.tokenize('foo <% bar %>', 1, 1, @opts) ==
             {:ok, [{:text, 'foo '}, {:expr, 1, 5, '', ' bar '}, {:eof, 1, 14}]}
  end

  test "strings with embedded equals code" do
    assert T.tokenize('foo <%= bar %>', 1, 1, @opts) ==
             {:ok, [{:text, 'foo '}, {:expr, 1, 5, '=', ' bar '}, {:eof, 1, 15}]}
  end

  test "strings with embedded slash code" do
    assert T.tokenize('foo <%/ bar %>', 1, 1, @opts) ==
             {:ok, [{:text, 'foo '}, {:expr, 1, 5, '/', ' bar '}, {:eof, 1, 15}]}
  end

  test "strings with embedded pipe code" do
    assert T.tokenize('foo <%| bar %>', 1, 1, @opts) ==
             {:ok, [{:text, 'foo '}, {:expr, 1, 5, '|', ' bar '}, {:eof, 1, 15}]}
  end

  test "strings with more than one line" do
    assert T.tokenize('foo\n<%= bar %>', 1, 1, @opts) ==
             {:ok, [{:text, 'foo\n'}, {:expr, 2, 1, '=', ' bar '}, {:eof, 2, 11}]}
  end

  test "strings with more than one line and expression with more than one line" do
    string = '''
    foo <%= bar

    baz %>
    <% foo %>
    '''

    exprs = [
      {:text, 'foo '},
      {:expr, 1, 5, '=', ' bar\n\nbaz '},
      {:text, '\n'},
      {:expr, 4, 1, '', ' foo '},
      {:text, '\n'},
      {:eof, 5, 1}
    ]

    assert T.tokenize(string, 1, 1, @opts) == {:ok, exprs}
  end

  test "quotation" do
    assert T.tokenize('foo <%% true %>', 1, 1, @opts) ==
             {:ok, [{:text, 'foo <% true %>'}, {:eof, 1, 16}]}
  end

  test "quotation with do/end" do
    assert T.tokenize('foo <%% true do %>bar<%% end %>', 1, 1, @opts) ==
             {:ok, [{:text, 'foo <% true do %>bar<% end %>'}, {:eof, 1, 32}]}
  end

  test "quotation with interpolation" do
    exprs = [
      {:text, 'a <% b '},
      {:expr, 1, 9, '=', ' c '},
      {:text, ' '},
      {:expr, 1, 18, '=', ' d '},
      {:text, ' e %> f'},
      {:eof, 1, 33}
    ]

    assert T.tokenize('a <%% b <%= c %> <%= d %> e %> f', 1, 1, @opts) == {:ok, exprs}
  end

  test "improperly formatted quotation with interpolation" do
    exprs = [
      {:text, '<%% a <%= b %> c %>'},
      {:eof, 1, 22}
    ]

    assert T.tokenize('<%%% a <%%= b %> c %>', 1, 1, @opts) == {:ok, exprs}
  end

  test "eex comments" do
    exprs = [
      {:text, 'foo '},
      {:eof, 1, 16}
    ]

    assert T.tokenize('foo <%# true %>', 1, 1, @opts) == {:ok, exprs}
  end

  test "eex comments with do/end" do
    exprs = [
      {:text, 'foo bar'},
      {:eof, 1, 32}
    ]

    assert T.tokenize('foo <%# true do %>bar<%# end %>', 1, 1, @opts) == {:ok, exprs}
  end

  test "elixir comments" do
    exprs = [
      {:text, 'foo '},
      {:expr, 1, 5, [], ' true # this is a boolean '},
      {:eof, 1, 35}
    ]

    assert T.tokenize('foo <% true # this is a boolean %>', 1, 1, @opts) == {:ok, exprs}
  end

  test "elixir comments with do/end" do
    exprs = [
      {:start_expr, 1, 1, [], ' if true do # startif '},
      {:text, 'text'},
      {:end_expr, 1, 31, [], ' end # closeif '},
      {:eof, 1, 50}
    ]

    assert T.tokenize('<% if true do # startif %>text<% end # closeif %>', 1, 1, @opts) ==
             {:ok, exprs}
  end

  test "strings with embedded do end" do
    exprs = [
      {:text, 'foo '},
      {:start_expr, 1, 5, '', ' if true do '},
      {:text, 'bar'},
      {:end_expr, 1, 24, '', ' end '},
      {:eof, 1, 33}
    ]

    assert T.tokenize('foo <% if true do %>bar<% end %>', 1, 1, @opts) == {:ok, exprs}
  end

  test "strings with embedded -> end" do
    exprs = [
      {:text, 'foo '},
      {:start_expr, 1, 5, '', ' cond do '},
      {:middle_expr, 1, 18, '', ' false -> '},
      {:text, 'bar'},
      {:middle_expr, 1, 35, '', ' true -> '},
      {:text, 'baz'},
      {:end_expr, 1, 51, '', ' end '},
      {:eof, 1, 60}
    ]

    assert T.tokenize('foo <% cond do %><% false -> %>bar<% true -> %>baz<% end %>', 1, 1, @opts) ==
             {:ok, exprs}
  end

  test "strings with multiple callbacks" do
    exprs = [
      {:start_expr, 1, 1, '=', ' a fn -> '},
      {:text, 'foo'},
      {:middle_expr, 1, 18, '', ' end, fn -> '},
      {:text, 'bar'},
      {:end_expr, 1, 37, '', ' end '},
      {:eof, 1, 46}
    ]

    assert T.tokenize('<%= a fn -> %>foo<% end, fn -> %>bar<% end %>', 1, 1, @opts) ==
             {:ok, exprs}
  end

  test "strings with callback followed by do block" do
    exprs = [
      {:start_expr, 1, 1, '=', ' a fn -> '},
      {:text, 'foo'},
      {:middle_expr, 1, 18, '', ' end do '},
      {:text, 'bar'},
      {:end_expr, 1, 33, '', ' end '},
      {:eof, 1, 42}
    ]

    assert T.tokenize('<%= a fn -> %>foo<% end do %>bar<% end %>', 1, 1, @opts) == {:ok, exprs}
  end

  test "strings with embedded keywords blocks" do
    exprs = [
      {:text, 'foo '},
      {:start_expr, 1, 5, '', ' if true do '},
      {:text, 'bar'},
      {:middle_expr, 1, 24, '', ' else '},
      {:text, 'baz'},
      {:end_expr, 1, 37, '', ' end '},
      {:eof, 1, 46}
    ]

    assert T.tokenize('foo <% if true do %>bar<% else %>baz<% end %>', 1, 1, @opts) ==
             {:ok, exprs}
  end

  test "trim mode" do
    template = '\t<%= if true do %> \n TRUE \n  <% else %>\n FALSE \n  <% end %>  \n\n  '

    exprs = [
      {:start_expr, 1, 2, '=', ' if true do '},
      {:text, '\n TRUE \n'},
      {:middle_expr, 3, 3, '', ' else '},
      {:text, '\n FALSE \n'},
      {:end_expr, 5, 3, '', ' end '},
      {:eof, 7, 3}
    ]

    assert T.tokenize(template, 1, 1, %{@opts | trim: true}) == {:ok, exprs}
  end

  test "trim mode with comment" do
    exprs = [
      {:text, '\n123'},
      {:eof, 2, 4}
    ]

    assert T.tokenize('  <%# comment %>  \n123', 1, 1, %{@opts | trim: true}) == {:ok, exprs}
  end

  test "trim mode with CRLF" do
    exprs = [
      {:text, '0\n'},
      {:expr, 2, 3, '=', ' 12 '},
      {:text, '\n34'},
      {:eof, 3, 3}
    ]

    assert T.tokenize('0\r\n  <%= 12 %>  \r\n34', 1, 1, %{@opts | trim: true}) == {:ok, exprs}
  end

  test "trim mode set to false" do
    exprs = [
      {:text, ' '},
      {:expr, 1, 2, '=', ' 12 '},
      {:text, ' \n'},
      {:eof, 2, 1}
    ]

    assert T.tokenize(' <%= 12 %> \n', 1, 1, %{@opts | trim: false}) == {:ok, exprs}
  end

  test "trim mode no false positives" do
    assert_not_trimmed = fn x ->
      assert T.tokenize(x, 1, 1, %{@opts | trim: false}) == T.tokenize(x, 1, 1, @opts)
    end

    assert_not_trimmed.('foo <%= "bar" %>  ')
    assert_not_trimmed.('\n  <%= "foo" %>bar')
    assert_not_trimmed.('  <%% hello %>  ')
    assert_not_trimmed.('  <%= 01 %><%= 23 %>\n')
  end

  test "returns error when there is start mark and no end mark" do
    assert T.tokenize('foo <% :bar', 1, 1, @opts) == {:error, 1, 12, "missing token '%>'"}
    assert T.tokenize('<%# true ', 1, 1, @opts) == {:error, 1, 10, "missing token '%>'"}
  end

  test "marks invalid expressions as regular expressions" do
    assert T.tokenize('<% 1 $ 2 %>', 1, 1, @opts) ==
             {:ok, [{:expr, 1, 1, [], ' 1 $ 2 '}, {:eof, 1, 12}]}
  end
end

Code.require_file("../test_helper.exs", __DIR__)

defmodule EEx.TokenizerTest do
  use ExUnit.Case, async: true
  require EEx.Tokenizer, as: T

  @opts %{indentation: 0, trim: false}

  test "simple chars lists" do
    assert T.tokenize('foo', 1, 1, @opts) == {:ok, [{:text, 'foo'}, {:eof, 1, 4}]}
  end

  test "simple strings" do
    assert T.tokenize("foo", 1, 1, @opts) == {:ok, [{:text, 'foo'}, {:eof, 1, 4}]}
  end

  test "strings with embedded code" do
    assert T.tokenize('foo <% bar %>', 1, 1, @opts) ==
             {:ok, [{:text, 'foo '}, {:expr, 1, 5, '', ' bar '}, {:eof, 1, 14}]}
  end

  test "strings with embedded equals code" do
    assert T.tokenize('foo <%= bar %>', 1, 1, @opts) ==
             {:ok, [{:text, 'foo '}, {:expr, 1, 5, '=', ' bar '}, {:eof, 1, 15}]}
  end

  test "strings with embedded slash code" do
    assert T.tokenize('foo <%/ bar %>', 1, 1, @opts) ==
             {:ok, [{:text, 'foo '}, {:expr, 1, 5, '/', ' bar '}, {:eof, 1, 15}]}
  end

  test "strings with embedded pipe code" do
    assert T.tokenize('foo <%| bar %>', 1, 1, @opts) ==
             {:ok, [{:text, 'foo '}, {:expr, 1, 5, '|', ' bar '}, {:eof, 1, 15}]}
  end

  test "strings with more than one line" do
    assert T.tokenize('foo\n<%= bar %>', 1, 1, @opts) ==
             {:ok, [{:text, 'foo\n'}, {:expr, 2, 1, '=', ' bar '}, {:eof, 2, 11}]}
  end

  test "strings with more than one line and expression with more than one line" do
    string = '''
    foo <%= bar

    baz %>
    <% foo %>
    '''

    exprs = [
      {:text, 'foo '},
      {:expr, 1, 5, '=', ' bar\n\nbaz '},
      {:text, '\n'},
      {:expr, 4, 1, '', ' foo '},
      {:text, '\n'},
      {:eof, 5, 1}
    ]

    assert T.tokenize(string, 1, 1, @opts) == {:ok, exprs}
  end

  test "quotation" do
    assert T.tokenize('foo <%% true %>', 1, 1, @opts) ==
             {:ok, [{:text, 'foo <% true %>'}, {:eof, 1, 16}]}
  end

  test "quotation with do/end" do
    assert T.tokenize('foo <%% true do %>bar<%% end %>', 1, 1, @opts) ==
             {:ok, [{:text, 'foo <% true do %>bar<% end %>'}, {:eof, 1, 32}]}
  end

  test "quotation with interpolation" do
    exprs = [
      {:text, 'a <% b '},
      {:expr, 1, 9, '=', ' c '},
      {:text, ' '},
      {:expr, 1, 18, '=', ' d '},
      {:text, ' e %> f'},
      {:eof, 1, 33}
    ]

    assert T.tokenize('a <%% b <%= c %> <%= d %> e %> f', 1, 1, @opts) == {:ok, exprs}
  end

  test "improperly formatted quotation with interpolation" do
    exprs = [
      {:text, '<%% a <%= b %> c %>'},
      {:eof, 1, 22}
    ]

    assert T.tokenize('<%%% a <%%= b %> c %>', 1, 1, @opts) == {:ok, exprs}
  end

  test "eex comments" do
    exprs = [
      {:text, 'foo '},
      {:eof, 1, 16}
    ]

    assert T.tokenize('foo <%# true %>', 1, 1, @opts) == {:ok, exprs}
  end

  test "eex comments with do/end" do
    exprs = [
      {:text, 'foo bar'},
      {:eof, 1, 32}
    ]

    assert T.tokenize('foo <%# true do %>bar<%# end %>', 1, 1, @opts) == {:ok, exprs}
  end

  test "elixir comments" do
    exprs = [
      {:text, 'foo '},
      {:expr, 1, 5, [], ' true # this is a boolean '},
      {:eof, 1, 35}
    ]

    assert T.tokenize('foo <% true # this is a boolean %>', 1, 1, @opts) == {:ok, exprs}
  end

  test "elixir comments with do/end" do
    exprs = [
      {:start_expr, 1, 1, [], ' if true do # startif '},
      {:text, 'text'},
      {:end_expr, 1, 31, [], ' end # closeif '},
      {:eof, 1, 50}
    ]

    assert T.tokenize('<% if true do # startif %>text<% end # closeif %>', 1, 1, @opts) ==
             {:ok, exprs}
  end

  test "strings with embedded do end" do
    exprs = [
      {:text, 'foo '},
      {:start_expr, 1, 5, '', ' if true do '},
      {:text, 'bar'},
      {:end_expr, 1, 24, '', ' end '},
      {:eof, 1, 33}
    ]

    assert T.tokenize('foo <% if true do %>bar<% end %>', 1, 1, @opts) == {:ok, exprs}
  end

  test "strings with embedded -> end" do
    exprs = [
      {:text, 'foo '},
      {:start_expr, 1, 5, '', ' cond do '},
      {:middle_expr, 1, 18, '', ' false -> '},
      {:text, 'bar'},
      {:middle_expr, 1, 35, '', ' true -> '},
      {:text, 'baz'},
      {:end_expr, 1, 51, '', ' end '},
      {:eof, 1, 60}
    ]

    assert T.tokenize('foo <% cond do %><% false -> %>bar<% true -> %>baz<% end %>', 1, 1, @opts) ==
             {:ok, exprs}
  end

  test "strings with multiple callbacks" do
    exprs = [
      {:start_expr, 1, 1, '=', ' a fn -> '},
      {:text, 'foo'},
      {:middle_expr, 1, 18, '', ' end, fn -> '},
      {:text, 'bar'},
      {:end_expr, 1, 37, '', ' end '},
      {:eof, 1, 46}
    ]

    assert T.tokenize('<%= a fn -> %>foo<% end, fn -> %>bar<% end %>', 1, 1, @opts) ==
             {:ok, exprs}
  end

  test "strings with callback followed by do block" do
    exprs = [
      {:start_expr, 1, 1, '=', ' a fn -> '},
      {:text, 'foo'},
      {:middle_expr, 1, 18, '', ' end do '},
      {:text, 'bar'},
      {:end_expr, 1, 33, '', ' end '},
      {:eof, 1, 42}
    ]

    assert T.tokenize('<%= a fn -> %>foo<% end do %>bar<% end %>', 1, 1, @opts) == {:ok, exprs}
  end

  test "strings with embedded keywords blocks" do
    exprs = [
      {:text, 'foo '},
      {:start_expr, 1, 5, '', ' if true do '},
      {:text, 'bar'},
      {:middle_expr, 1, 24, '', ' else '},
      {:text, 'baz'},
      {:end_expr, 1, 37, '', ' end '},
      {:eof, 1, 46}
    ]

    assert T.tokenize('foo <% if true do %>bar<% else %>baz<% end %>', 1, 1, @opts) ==
             {:ok, exprs}
  end

  test "trim mode" do
    template = '\t<%= if true do %> \n TRUE \n  <% else %>\n FALSE \n  <% end %>  \n\n  '

    exprs = [
      {:start_expr, 1, 2, '=', ' if true do '},
      {:text, '\n TRUE \n'},
      {:middle_expr, 3, 3, '', ' else '},
      {:text, '\n FALSE \n'},
      {:end_expr, 5, 3, '', ' end '},
      {:eof, 7, 3}
    ]

    assert T.tokenize(template, 1, 1, %{@opts | trim: true}) == {:ok, exprs}
  end

  test "trim mode with comment" do
    exprs = [
      {:text, '\n123'},
      {:eof, 2, 4}
    ]

    assert T.tokenize('  <%# comment %>  \n123', 1, 1, %{@opts | trim: true}) == {:ok, exprs}
  end

  test "trim mode with CRLF" do
    exprs = [
      {:text, '0\n'},
      {:expr, 2, 3, '=', ' 12 '},
      {:text, '\n34'},
      {:eof, 3, 3}
    ]

    assert T.tokenize('0\r\n  <%= 12 %>  \r\n34', 1, 1, %{@opts | trim: true}) == {:ok, exprs}
  end

  test "trim mode set to false" do
    exprs = [
      {:text, ' '},
      {:expr, 1, 2, '=', ' 12 '},
      {:text, ' \n'},
      {:eof, 2, 1}
    ]

    assert T.tokenize(' <%= 12 %> \n', 1, 1, %{@opts | trim: false}) == {:ok, exprs}
  end

  test "trim mode no false positives" do
    assert_not_trimmed = fn x ->
      assert T.tokenize(x, 1, 1, %{@opts | trim: false}) == T.tokenize(x, 1, 1, @opts)
    end

    assert_not_trimmed.('foo <%= "bar" %>  ')
    assert_not_trimmed.('\n  <%= "foo" %>bar')
    assert_not_trimmed.('  <%% hello %>  ')
    assert_not_trimmed.('  <%= 01 %><%= 23 %>\n')
  end

  test "returns error when there is start mark and no end mark" do
    assert T.tokenize('foo <% :bar', 1, 1, @opts) == {:error, 1, 12, "missing token '%>'"}
    assert T.tokenize('<%# true ', 1, 1, @opts) == {:error, 1, 10, "missing token '%>'"}
  end

  test "marks invalid expressions as regualr expressions" do
    assert T.tokenize('<% 1 $ 2 %>', 1, 1, @opts) ==
             {:ok, [{:expr, 1, 1, [], ' 1 $ 2 '}, {:eof, 1, 12}]}
  end
end


Remove an unneeded template variable

Remove an unneeded template variable

defmodule JumubaseWeb.PageView do
  use JumubaseWeb, :view
  import JumubaseWeb.LayoutView, only: [title: 0]

  import JumubaseWeb.Internal.ContestView,
    only: [deadline: 1, deadline_info: 2, name_with_flag: 1, year: 1]

  alias Jumubase.Foundation
  alias Jumubase.Foundation.{Contest, Host}
  alias JumubaseWeb.Endpoint
  alias JumubaseWeb.MapHelpers

  def host_map_image do
    img_tag(MapHelpers.host_map_url(), class: "img-responsive map-image")
  end

  def render_phase_panels(conn) do
    c = Foundation.get_latest_official_contest()
    do_render_phase_panels(conn, c)
  end

  def app_link(platform) do
    img_tag = img_tag(app_badge_path(platform), height: 40)
    link(img_tag, to: app_url(platform), class: "app-link")
  end

  def rule_booklet_link(title, year, opts \\ []) do
    icon_link(
      "file",
      title,
      Routes.static_path(Endpoint, "/resources/Ausschreibung_#{year}.pdf"),
      opts
    )
  end

  def render("rules.html", assigns) do
    render("rules.#{get_locale()}.html", assigns)
  end

  def render("faq.html", assigns) do
    render("faq.#{get_locale()}.html", assigns)
  end

  def render("privacy.html", assigns) do
    render("privacy.#{get_locale()}.html", assigns)
  end

  def render("scripts.privacy.html", _assigns) do
    ~E{<script src="/js/privacy.js"></script>}
  end

  def to_accordion_item(%Host{} = host) do
    %{id: host.id, title: host.name, body: render_markdown(host.address)}
  end

  # Private helpers

  defp do_render_phase_panels(_conn, nil), do: nil

  defp do_render_phase_panels(conn, %Contest{round: 1} = c) do
    if Timex.after?(Timex.today(), c.deadline) do
      render("_rw_phase_panels.html", conn: conn)
    else
      render("_pre_rw_phase_panels.html", conn: conn, year: year(c))
    end
  end

  defp do_render_phase_panels(conn, %Contest{round: 2} = c) do
    today = Timex.today()

    cond do
      Timex.after?(today, c.end_date |> Timex.shift(months: 3)) ->
        render("_interseason_phase_panels.html", conn: conn)

      Timex.after?(today, c.deadline) ->
        render("_lw_phase_panels.html", conn: conn, contest: c)

      true ->
        render("_pre_lw_phase_panels.html", conn: conn, contest: c)
    end
  end

  defp app_url(:android) do
    "https://play.google.com/store/apps/details?id=#{app_id(:android)}&hl=de"
  end

  defp app_url(:ios) do
    "https://itunes.apple.com/de/app/id#{app_id(:ios)}?mt=8"
  end

  defp app_id(platform) do
    Application.get_env(:jumubase, :app_ids)[platform]
  end

  defp app_badge_path(:android), do: "/images/google-play-badge.png"
  defp app_badge_path(:ios), do: "/images/app-store-badge.svg"

  defp get_locale, do: Gettext.get_locale(Jumubase.Gettext)

  defp render_markdown(nil), do: nil

  defp render_markdown(markdown) do
    case Earmark.as_html(markdown) do
      {:ok, result, _} -> raw(result)
      {:error, _, _} -> nil
    end
  end
end

defmodule JumubaseWeb.PageView do
  use JumubaseWeb, :view
  import JumubaseWeb.LayoutView, only: [title: 0]

  import JumubaseWeb.Internal.ContestView,
    only: [deadline: 1, deadline_info: 2, name_with_flag: 1, year: 1]

  alias Jumubase.Foundation
  alias Jumubase.Foundation.{Contest, Host}
  alias JumubaseWeb.Endpoint
  alias JumubaseWeb.MapHelpers

  def host_map_image do
    img_tag(MapHelpers.host_map_url(), class: "img-responsive map-image")
  end

  def render_phase_panels(conn) do
    c = Foundation.get_latest_official_contest()
    do_render_phase_panels(conn, c)
  end

  def app_link(platform) do
    img_tag = img_tag(app_badge_path(platform), height: 40)
    link(img_tag, to: app_url(platform), class: "app-link")
  end

  def rule_booklet_link(title, year, opts \\ []) do
    icon_link(
      "file",
      title,
      Routes.static_path(Endpoint, "/resources/Ausschreibung_#{year}.pdf"),
      opts
    )
  end

  def render("rules.html", assigns) do
    render("rules.#{get_locale()}.html", assigns)
  end

  def render("faq.html", assigns) do
    render("faq.#{get_locale()}.html", assigns)
  end

  def render("privacy.html", assigns) do
    render("privacy.#{get_locale()}.html", assigns)
  end

  def render("scripts.privacy.html", _assigns) do
    ~E{<script src="/js/privacy.js"></script>}
  end

  def to_accordion_item(%Host{} = host) do
    %{id: host.id, title: host.name, body: render_markdown(host.address)}
  end

  # Private helpers

  defp do_render_phase_panels(_conn, nil), do: nil

  defp do_render_phase_panels(conn, %Contest{round: 1} = c) do
    if Timex.after?(Timex.today(), c.deadline) do
      render("_rw_phase_panels.html", conn: conn)
    else
      render("_pre_rw_phase_panels.html", conn: conn, year: year(c))
    end
  end

  defp do_render_phase_panels(conn, %Contest{round: 2} = c) do
    today = Timex.today()

    cond do
      Timex.after?(today, c.end_date |> Timex.shift(months: 3)) ->
        render("_interseason_phase_panels.html", conn: conn, contest: c)

      Timex.after?(today, c.deadline) ->
        render("_lw_phase_panels.html", conn: conn, contest: c)

      true ->
        render("_pre_lw_phase_panels.html", conn: conn, contest: c)
    end
  end

  defp app_url(:android) do
    "https://play.google.com/store/apps/details?id=#{app_id(:android)}&hl=de"
  end

  defp app_url(:ios) do
    "https://itunes.apple.com/de/app/id#{app_id(:ios)}?mt=8"
  end

  defp app_id(platform) do
    Application.get_env(:jumubase, :app_ids)[platform]
  end

  defp app_badge_path(:android), do: "/images/google-play-badge.png"
  defp app_badge_path(:ios), do: "/images/app-store-badge.svg"

  defp get_locale, do: Gettext.get_locale(Jumubase.Gettext)

  defp render_markdown(nil), do: nil

  defp render_markdown(markdown) do
    case Earmark.as_html(markdown) do
      {:ok, result, _} -> raw(result)
      {:error, _, _} -> nil
    end
  end
end