diff --git a/erlang/.gitignore b/erlang/.gitignore deleted file mode 100644 index 2a23a830..00000000 --- a/erlang/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -.rebar3 -_* -.eunit -*.o -*.beam -*.plt -*.swp -*.swo -.erlang.cookie -ebin -log -erl_crash.dump -.rebar -logs -_build -*.iml -rebar3.crashdump -*~ -.idea - diff --git a/erlang/README.md b/erlang/README.md deleted file mode 100644 index 7c117b4b..00000000 --- a/erlang/README.md +++ /dev/null @@ -1,31 +0,0 @@ -GildedRose -===== - -You will need to install [erlang](https://www.erlang.org/), and [rebar3](https://github.com/erlang/rebar3). I recommend following the instructions from JetBrains: [Getting Started with Erlang](https://www.jetbrains.com/help/idea/erlang.html). - -When you open this project with IntelliJ I recommend that you do - - File | New | Project from existing sources - -Then be sure to select "Erlang" as the project type, and configure the rebar3 location correctly, -(There is a copy of it in this repo). - -If you're having trouble executing the 'main' application, check your module path in your Project Settings. -I found I had to manually set the module compile output path to '_build/default/lib/gilded_rose/ebin'. -The test output path seemed to be correct as '.eunit' - -Build ------ - - $ rebar3 compile - -Run Tests ---------- - - $ rebar3 eunit - -TextTest Fixture ----------------- -To run for 30 days, I think this ought to work but I tend to run it through the IDE instead: - - $ erl -pa _build/default/lib/gilded_rose/ebin -pa . -eval main:main([30]). -s init stop -noshell diff --git a/erlang/include/gilded_rose.hrl b/erlang/include/gilded_rose.hrl deleted file mode 100644 index 4b74d598..00000000 --- a/erlang/include/gilded_rose.hrl +++ /dev/null @@ -1,5 +0,0 @@ --record(item, { - name :: binary(), - sell_in = 0 :: integer(), - quality = 0 :: integer() -}). diff --git a/erlang/include/texttest_fixture.hrl b/erlang/include/texttest_fixture.hrl deleted file mode 100644 index 6bde4e1f..00000000 --- a/erlang/include/texttest_fixture.hrl +++ /dev/null @@ -1 +0,0 @@ --include("gilded_rose.hrl"). diff --git a/erlang/rebar.config b/erlang/rebar.config deleted file mode 100644 index bf4b1d17..00000000 --- a/erlang/rebar.config +++ /dev/null @@ -1,2 +0,0 @@ -{erl_opts, [warnings_as_errors]}. -{eunit_opts, [verbose]}. \ No newline at end of file diff --git a/erlang/rebar.lock b/erlang/rebar.lock deleted file mode 100644 index 57afcca0..00000000 --- a/erlang/rebar.lock +++ /dev/null @@ -1 +0,0 @@ -[]. diff --git a/erlang/src/gilded_rose.app.src b/erlang/src/gilded_rose.app.src deleted file mode 100644 index 4c47019a..00000000 --- a/erlang/src/gilded_rose.app.src +++ /dev/null @@ -1 +0,0 @@ -{application, gilded_rose, [{vsn, "0.1"}]}. diff --git a/erlang/src/gilded_rose.erl b/erlang/src/gilded_rose.erl deleted file mode 100644 index 68f7efac..00000000 --- a/erlang/src/gilded_rose.erl +++ /dev/null @@ -1,87 +0,0 @@ --module(gilded_rose). - --include("gilded_rose.hrl"). - --export([ - update_quality/1 -]). - --spec update_quality([#item{}]) -> [#item{}]. -update_quality(Items) -> - lists:map(fun update_item/1, Items). - --spec update_item(#item{}) -> #item{}. -update_item(Item = #item{name = Name}) -> - Item1 = if - Name /= "Aged Brie" andalso Name /= "Backstage passes to a TAFKAL80ETC concert" -> - if - Item#item.quality > 0 -> - if - Name /= "Sulfuras, Hand of Ragnaros" -> - Item#item{quality = Item#item.quality - 1}; - true -> - Item - end; - true -> - Item - end; - true -> - if - Item#item.quality < 50 -> - Item2 = Item#item{quality = Item#item.quality + 1}, - if - Name == "Backstage passes to a TAFKAL80ETC concert" -> - Item3 = if - Item2#item.sell_in < 11 -> - if - Item2#item.quality < 50 -> - Item2#item{quality = Item2#item.quality + 1}; - true -> Item2 - end; - true -> Item2 - end, - if - Item3#item.sell_in < 6 -> - if - Item3#item.quality < 50 -> - Item3#item{quality = Item3#item.quality + 1}; - true -> Item3 - end; - true -> Item3 - end; - true -> Item2 - end; - true -> Item - end - end, - Item4 = if - Name /= "Sulfuras, Hand of Ragnaros" -> - Item1#item{sell_in = Item1#item.sell_in - 1}; - true -> Item1 - end, - if - Item4#item.sell_in < 0 -> - if - Name /= "Aged Brie" -> - if - Name /= "Backstage passes to a TAFKAL80ETC concert" -> - if - Item4#item.quality > 0 -> - if - Name /= "Sulfuras, Hand of Ragnaros" -> - Item4#item{quality = Item4#item.quality - 1}; - true -> Item4 - end; - true -> Item4 - end; - true -> Item4#item{quality = Item4#item.quality - Item4#item.quality} - end; - true -> - if - Item4#item.quality < 50 -> - Item4#item{quality = Item4#item.quality + 1}; - true -> Item4 - end - end; - true -> Item4 - end. diff --git a/erlang/src/main.erl b/erlang/src/main.erl deleted file mode 100644 index 17f76489..00000000 --- a/erlang/src/main.erl +++ /dev/null @@ -1,34 +0,0 @@ --module(main). - --include("texttest_fixture.hrl"). - --export([main/1]). - --define(ALL_ITEMS, [ - #item{name = "+5 Dexterity Vest", sell_in = 10, quality = 20}, - #item{name = "Aged Brie", sell_in = 2, quality = 0}, - #item{name = "Elixir of the Mongoose", sell_in = 5, quality = 7}, - #item{name = "Sulfuras, Hand of Ragnaros", sell_in = 0, quality = 80}, - #item{name = "Sulfuras, Hand of Ragnaros", sell_in = -1, quality = 80}, - #item{name = "Backstage passes to a TAFKAL80ETC concert", sell_in = 15, quality = 20}, - #item{name = "Backstage passes to a TAFKAL80ETC concert", sell_in = 10, quality = 49}, - #item{name = "Backstage passes to a TAFKAL80ETC concert", sell_in = 5, quality = 49}, - #item{name = "Conjured Mana Cake", sell_in = 3, quality = 6} -]). - -main([Days]) -> - try - texttest_fixture:print_update_quality(Days, ?ALL_ITEMS) - catch - ExceptionClass:ExceptionInfo -> - io:format("something went wrong:~n~p : ~p~n", [ExceptionClass, ExceptionInfo]), - usage() - end; - -main(_) -> - usage(). - -usage() -> - io:format("usage: main main number_of_days\ne.g. main main [30]\n"), - halt(1). - diff --git a/erlang/src/texttest_fixture.erl b/erlang/src/texttest_fixture.erl deleted file mode 100644 index 30ac0863..00000000 --- a/erlang/src/texttest_fixture.erl +++ /dev/null @@ -1,21 +0,0 @@ --module(texttest_fixture). - --include("texttest_fixture.hrl"). - --export([print_update_quality/2]). - -print_one_day(Day, Items) -> - io:format("~n-------- day ~p --------~n", [Day]), - io:format("name, sellIn, quality~n", []), - lists:foreach(fun(#item{name = Name, sell_in = SellIn, quality = Quality}) -> - io:format("~s, ~p, ~p~n", [Name, SellIn, Quality]) - end, Items). - -print_update_quality(Days, Items) -> - io:format("OMGHAI!"), - lists:foreach( - fun(Day) -> print_one_day(Day, Items), - gilded_rose:update_quality(Items) - end, lists:seq(0, Days - 1) - ). - diff --git a/erlang/test/gilded_rose_test.erl b/erlang/test/gilded_rose_test.erl deleted file mode 100644 index 9efd0400..00000000 --- a/erlang/test/gilded_rose_test.erl +++ /dev/null @@ -1,9 +0,0 @@ --module(gilded_rose_test). - --include_lib("eunit/include/eunit.hrl"). - --include("gilded_rose.hrl"). - -update_quality_test_() -> [ - {"foo", ?_assertMatch([#item{name= "Foo"}], gilded_rose:update_quality([#item{name = "Foo", sell_in = 0, quality = 0}]))} -].