Я хочу опробовать модуль Poison json без создания проекта микширования.
Как его установить и сделать доступным в iex через импорт?
Мне удалось добавить его в проект, а затем использовать его после перехода в каталог проекта и с помощью команды iex -S:
[email protected]:~/code/elixirTry/pj$ cat mix.exs
defmodule Pj.Mixfile do
use Mix.Project
def project do
[app: :pj,
version: "0.0.1",
elixir: "~> 1.2",
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
[applications: [:logger]]
end
# Dependencies can be Hex packages:
#
# {:mydep, "~> 0.3.0"}
#
# Or git/path repositories:
#
# {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"}
#
# Type "mix help deps" for more examples and options
defp deps do
[{:poison, "~> 2.0"}]
end
end
[email protected]:~/code/elixirTry/pj$ cat lib/pj.ex
defmodule Person do
@derive [Poison.Encoder]
defstruct [:name, :age]
end
defmodule Pj do
xx = Poison.encode!(%Person{name: "Devin Torres", age: 27})
end
[email protected]:~/code/elixirTry/pj$ iex -S mix
Erlang/OTP 18 [erts-7.2] [source-e6dd627] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]
Interactive Elixir (1.2.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> import Poison
nil
iex(2)>
Однако, если я просто перейду в обычный iex в общий каталог, то я не могу получить доступ к библиотеке Poison:
iex(4)> import IO
nil
iex(5)> puts("hello")
hello
:ok
iex(6)> import Poison
** (CompileError) iex:6: module Poison is not loaded and could not be found
Также, как мне установить библиотеку глобально из github?