From 2c46cc983b31a27fce9584f0f2f9f2b0e68343a6 Mon Sep 17 00:00:00 2001 From: David Suilea Date: Sat, 12 Dec 2015 19:10:03 +0100 Subject: [PATCH] elixir - set 1 challange 1 --- elixir/set1.exs | 28 ++++++++++++++++++++++++++++ elxr/.gitignore | 5 ----- elxr/README.md | 19 ------------------- elxr/config/config.exs | 30 ------------------------------ elxr/lib/elxr.ex | 19 ------------------- elxr/mix.exs | 33 --------------------------------- elxr/test/elxr_test.exs | 8 -------- elxr/test/test_helper.exs | 1 - 8 files changed, 28 insertions(+), 115 deletions(-) create mode 100644 elixir/set1.exs delete mode 100644 elxr/.gitignore delete mode 100644 elxr/README.md delete mode 100644 elxr/config/config.exs delete mode 100644 elxr/lib/elxr.ex delete mode 100644 elxr/mix.exs delete mode 100644 elxr/test/elxr_test.exs delete mode 100644 elxr/test/test_helper.exs diff --git a/elixir/set1.exs b/elixir/set1.exs new file mode 100644 index 0000000..098ddf9 --- /dev/null +++ b/elixir/set1.exs @@ -0,0 +1,28 @@ +defmodule Set1 do + def hex_to_str(hex_input) do + hex_input + |> Base.decode16!(case: :lower) + end + + def hex_to_b64(hex_input) do + hex_input + |> hex_to_str + |> Base.encode64() + end +end + + +# TODO: Find a way to put the tests in another file +ExUnit.start + +defmodule TestSet1 do + use ExUnit.Case + + test "Hex to String" do + assert Set1.hex_to_str("49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d") == "I'm killing your brain like a poisonous mushroom" + end + + test "Hex to Base64" do + assert Set1.hex_to_b64("49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d") == "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t" + end +end diff --git a/elxr/.gitignore b/elxr/.gitignore deleted file mode 100644 index 755b605..0000000 --- a/elxr/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/_build -/cover -/deps -erl_crash.dump -*.ez diff --git a/elxr/README.md b/elxr/README.md deleted file mode 100644 index d603641..0000000 --- a/elxr/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Elxr - -**TODO: Add description** - -## Installation - -If [available in Hex](https://hex.pm/docs/publish), the package can be installed as: - - 1. Add elxr to your list of dependencies in `mix.exs`: - - def deps do - [{:elxr, "~> 0.0.1"}] - end - - 2. Ensure elxr is started before your application: - - def application do - [applications: [:elxr]] - end diff --git a/elxr/config/config.exs b/elxr/config/config.exs deleted file mode 100644 index b18005e..0000000 --- a/elxr/config/config.exs +++ /dev/null @@ -1,30 +0,0 @@ -# This file is responsible for configuring your application -# and its dependencies with the aid of the Mix.Config module. -use Mix.Config - -# This configuration is loaded before any dependency and is restricted -# to this project. If another project depends on this project, this -# file won't be loaded nor affect the parent project. For this reason, -# if you want to provide default values for your application for -# 3rd-party users, it should be done in your "mix.exs" file. - -# You can configure for your application as: -# -# config :elxr, key: :value -# -# And access this configuration in your application as: -# -# Application.get_env(:elxr, :key) -# -# Or configure a 3rd-party app: -# -# config :logger, level: :info -# - -# It is also possible to import configuration files, relative to this -# directory. For example, you can emulate configuration per environment -# by uncommenting the line below and defining dev.exs, test.exs and such. -# Configuration from the imported file will override the ones defined -# here (which is why it is important to import them last). -# -# import_config "#{Mix.env}.exs" diff --git a/elxr/lib/elxr.ex b/elxr/lib/elxr.ex deleted file mode 100644 index 4c23c2e..0000000 --- a/elxr/lib/elxr.ex +++ /dev/null @@ -1,19 +0,0 @@ -defmodule Elxr do - use Application - - # See http://elixir-lang.org/docs/stable/elixir/Application.html - # for more information on OTP Applications - def start(_type, _args) do - import Supervisor.Spec, warn: false - - children = [ - # Define workers and child supervisors to be supervised - # worker(Elxr.Worker, [arg1, arg2, arg3]), - ] - - # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html - # for other strategies and supported options - opts = [strategy: :one_for_one, name: Elxr.Supervisor] - Supervisor.start_link(children, opts) - end -end diff --git a/elxr/mix.exs b/elxr/mix.exs deleted file mode 100644 index 3dec638..0000000 --- a/elxr/mix.exs +++ /dev/null @@ -1,33 +0,0 @@ -defmodule Elxr.Mixfile do - use Mix.Project - - def project do - [app: :elxr, - version: "0.0.1", - elixir: "~> 1.1", - 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], - mod: {Elxr, []}] - 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 - [] - end -end diff --git a/elxr/test/elxr_test.exs b/elxr/test/elxr_test.exs deleted file mode 100644 index 1f37c15..0000000 --- a/elxr/test/elxr_test.exs +++ /dev/null @@ -1,8 +0,0 @@ -defmodule ElxrTest do - use ExUnit.Case - doctest Elxr - - test "the truth" do - assert 1 + 1 == 2 - end -end diff --git a/elxr/test/test_helper.exs b/elxr/test/test_helper.exs deleted file mode 100644 index 869559e..0000000 --- a/elxr/test/test_helper.exs +++ /dev/null @@ -1 +0,0 @@ -ExUnit.start()