Skip to content

Commit

Permalink
processing done, TODO non-blocking CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandruBurlacu committed Mar 8, 2018
1 parent bf8d635 commit a7d970a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lab2/lib/lab2.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ defmodule Lab2 do
"value" => String.to_float(v)
} end)
"Application/json" -> Poison.decode! content
"Application/xml" -> content
"Application/xml" -> (fn -> %{
"device_id" => content |> SweetXml.xpath(SweetXml.sigil_x"/device/@id") |> to_string,
"sensor_type" => content |> SweetXml.xpath(SweetXml.sigil_x"/device/type/text()") |> to_string |> String.to_integer,
"value" => content |> SweetXml.xpath(SweetXml.sigil_x"/device/value/text()") |> to_string |> String.to_float
} end).()
"text/plain; charset=utf-8" -> IO.puts content
end
end
Expand Down
6 changes: 3 additions & 3 deletions lab2/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule Lab2.MixProject do
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger, :httpotion]
extra_applications: [:logger, :httpotion, :xmerl]
]
end

Expand All @@ -28,8 +28,8 @@ defmodule Lab2.MixProject do
{:excoveralls, github: "parroty/excoveralls", only: :test},
{:poison, "~> 3.1"},
{:httpotion, "~> 3.1.0"},
{:nimble_csv, "~> 0.3"}
# {:xml, "~>"}
{:nimble_csv, "~> 0.3"},
{:sweet_xml, "~> 0.6.5"}
]
end

Expand Down
2 changes: 2 additions & 0 deletions lab2/mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"nimble_csv": {:hex, :nimble_csv, "0.4.0", "e2a21d93071cb3b3278411b5b49fe6b55a0e4b3e90485d1187e0c9c75c74f977", [:mix], [], "hexpm"},
"parallel_stream": {:hex, :parallel_stream, "1.0.6", "b967be2b23f0f6787fab7ed681b4c45a215a81481fb62b01a5b750fa8f30f76c", [:mix], [], "hexpm"},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
"quinn": {:hex, :quinn, "1.1.2", "f6f1462fee7c815388daafe4a3718765aafaeed813bd9369a7cec7f829dbfd56", [:mix], [], "hexpm"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"},
"sweet_xml": {:hex, :sweet_xml, "0.6.5", "dd9cde443212b505d1b5f9758feb2000e66a14d3c449f04c572f3048c66e6697", [:mix], [], "hexpm"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"},
}

0 comments on commit a7d970a

Please sign in to comment.