mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-17 15:31:27 +00:00
Delete elixir directory
This commit is contained in:
parent
0063ef3b48
commit
211acb4b31
1
elixir/.gitignore
vendored
1
elixir/.gitignore
vendored
@ -1 +0,0 @@
|
||||
_build/
|
||||
@ -1 +0,0 @@
|
||||
use Mix.Config
|
||||
@ -1,83 +0,0 @@
|
||||
defmodule GildedRose do
|
||||
# Example
|
||||
# update_quality([%Item{name: "Backstage passes to a TAFKAL80ETC concert", sell_in: 9, quality: 1}])
|
||||
# => [%Item{name: "Backstage passes to a TAFKAL80ETC concert", sell_in: 8, quality: 3}]
|
||||
|
||||
def update_quality(items) do
|
||||
Enum.map(items, &update_item/1)
|
||||
end
|
||||
|
||||
def update_item(item) do
|
||||
item = cond do
|
||||
item.name != "Aged Brie" && item.name != "Backstage passes to a TAFKAL80ETC concert" ->
|
||||
if item.quality > 0 do
|
||||
if item.name != "Sulfuras, Hand of Ragnaros" do
|
||||
%{item | quality: item.quality - 1}
|
||||
else
|
||||
item
|
||||
end
|
||||
else
|
||||
item
|
||||
end
|
||||
true ->
|
||||
cond do
|
||||
item.quality < 50 ->
|
||||
item = %{item | quality: item.quality + 1}
|
||||
cond do
|
||||
item.name == "Backstage passes to a TAFKAL80ETC concert" ->
|
||||
item = cond do
|
||||
item.sell_in < 11 ->
|
||||
cond do
|
||||
item.quality < 50 ->
|
||||
%{item | quality: item.quality + 1}
|
||||
true -> item
|
||||
end
|
||||
true -> item
|
||||
end
|
||||
cond do
|
||||
item.sell_in < 6 ->
|
||||
cond do
|
||||
item.quality < 50 ->
|
||||
%{item | quality: item.quality + 1}
|
||||
true -> item
|
||||
end
|
||||
true -> item
|
||||
end
|
||||
true -> item
|
||||
end
|
||||
true -> item
|
||||
end
|
||||
end
|
||||
item = cond do
|
||||
item.name != "Sulfuras, Hand of Ragnaros" ->
|
||||
%{item | sell_in: item.sell_in - 1}
|
||||
true -> item
|
||||
end
|
||||
cond do
|
||||
item.sell_in < 0 ->
|
||||
cond do
|
||||
item.name != "Aged Brie" ->
|
||||
cond do
|
||||
item.name != "Backstage passes to a TAFKAL80ETC concert" ->
|
||||
cond do
|
||||
item.quality > 0 ->
|
||||
cond do
|
||||
item.name != "Sulfuras, Hand of Ragnaros" ->
|
||||
%{item | quality: item.quality - 1}
|
||||
true -> item
|
||||
end
|
||||
true -> item
|
||||
end
|
||||
true -> %{item | quality: item.quality - item.quality}
|
||||
end
|
||||
true ->
|
||||
cond do
|
||||
item.quality < 50 ->
|
||||
%{item | quality: item.quality + 1}
|
||||
true -> item
|
||||
end
|
||||
end
|
||||
true -> item
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,3 +0,0 @@
|
||||
defmodule Item do
|
||||
defstruct name: nil, sell_in: nil, quality: nil
|
||||
end
|
||||
@ -1,9 +0,0 @@
|
||||
defmodule GildedRose.Mixfile do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[app: :gilded_rose,
|
||||
version: "0.0.1",
|
||||
elixir: "~> 1.0"]
|
||||
end
|
||||
end
|
||||
@ -1,10 +0,0 @@
|
||||
defmodule GildedRoseTest do
|
||||
use ExUnit.Case
|
||||
|
||||
test "begin the journey of refactoring" do
|
||||
items = [%Item{name: "foo", sell_in: 0, quality: 0}]
|
||||
GildedRose.update_quality(items)
|
||||
%{name: firstItemName} = List.first(items)
|
||||
assert "fixme" == firstItemName
|
||||
end
|
||||
end
|
||||
@ -1 +0,0 @@
|
||||
ExUnit.start()
|
||||
Loading…
Reference in New Issue
Block a user