Skip to content

Commit

Permalink
Code for step 1
Browse files Browse the repository at this point in the history
  • Loading branch information
akoutmos committed Jun 1, 2020
0 parents commit 95e5e60
Show file tree
Hide file tree
Showing 13 changed files with 153 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where third-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Ignore package tarball (built via "mix hex.build").
store_inventory-*.tar

21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# StoreInventory

**TODO: Add description**

## Installation

If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `store_inventory` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:store_inventory, "~> 0.1.0"}
]
end
```

Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/store_inventory](https://hexdocs.pm/store_inventory).

11 changes: 11 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Config

config :store_inventory, ecto_repos: [StoreInventory.Repo]

config :store_inventory, StoreInventory.Repo,
database: "store_inventory_repo",
username: "postgres",
password: "postgres",
hostname: "localhost"

import_config "#{Mix.env()}.exs"
3 changes: 3 additions & 0 deletions config/dev.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Config

config :store_inventory, repo: StoreInventory.Repo
3 changes: 3 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Config

config :store_inventory, repo: StoreInventory.TestRepo
18 changes: 18 additions & 0 deletions lib/store_inventory.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
defmodule StoreInventory do
@moduledoc """
Documentation for `StoreInventory`.
"""

@doc """
Hello world.
## Examples
iex> StoreInventory.hello()
:world
"""
def hello do
:world
end
end
17 changes: 17 additions & 0 deletions lib/store_inventory/application.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
defmodule StoreInventory.Application do
@moduledoc false

use Application

def start(_type, _args) do
opts = [strategy: :one_for_one, name: StoreInventory.Supervisor]
Supervisor.start_link(get_children(), opts)
end

defp get_children do
case Mix.env() do
:test -> []
_ -> [StoreInventory.Repo]
end
end
end
5 changes: 5 additions & 0 deletions lib/store_inventory/repo.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
defmodule StoreInventory.Repo do
use Ecto.Repo,
otp_app: :store_inventory,
adapter: Ecto.Adapters.Postgres
end
29 changes: 29 additions & 0 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
defmodule StoreInventory.MixProject do
use Mix.Project

def project do
[
app: :store_inventory,
version: "0.1.0",
elixir: "~> 1.10",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end

# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger],
mod: {StoreInventory.Application, []}
]
end

# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:ecto_sql, "~> 3.0"},
{:postgrex, ">= 0.0.0"}
]
end
end
9 changes: 9 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
%{
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm", "4a0850c9be22a43af9920a71ab17c051f5f7d45c209e40269a1938832510e4d9"},
"db_connection": {:hex, :db_connection, "2.2.2", "3bbca41b199e1598245b716248964926303b5d4609ff065125ce98bcd368939e", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm", "642af240d8a8affb93b4ba5a6fcd2bbcbdc327e1a524b825d383711536f8070c"},
"decimal": {:hex, :decimal, "1.8.1", "a4ef3f5f3428bdbc0d35374029ffcf4ede8533536fa79896dd450168d9acdf3c", [:mix], [], "hexpm", "3cb154b00225ac687f6cbd4acc4b7960027c757a5152b369923ead9ddbca7aec"},
"ecto": {:hex, :ecto, "3.4.4", "a2c881e80dc756d648197ae0d936216c0308370332c5e77a2325a10293eef845", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cc4bd3ad62abc3b21fb629f0f7a3dab23a192fca837d257dd08449fba7373561"},
"ecto_sql": {:hex, :ecto_sql, "3.4.4", "d28bac2d420f708993baed522054870086fd45016a9d09bb2cd521b9c48d32ea", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.4.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.3.0 or ~> 0.4.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.0", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "edb49af715dd72f213b66adfd0f668a43c17ed510b5d9ac7528569b23af57fe8"},
"postgrex": {:hex, :postgrex, "0.15.4", "5d691c25fc79070705a2ff0e35ce0822b86a0ee3c6fdb7a4fb354623955e1aed", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "306515b9d975fcb2478dc337a1d27dc3bf8af7cd71017c333fe9db3a3d211b0a"},
"telemetry": {:hex, :telemetry, "0.4.1", "ae2718484892448a24470e6aa341bc847c3277bfb8d4e9289f7474d752c09c7f", [:rebar3], [], "hexpm", "4738382e36a0a9a2b6e25d67c960e40e1a2c95560b9f936d8e29de8cd858480f"},
}
8 changes: 8 additions & 0 deletions test/store_inventory_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
defmodule StoreInventoryTest do
use ExUnit.Case
doctest StoreInventory

test "greets the world" do
assert StoreInventory.hello() == :world
end
end
1 change: 1 addition & 0 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ExUnit.start()

0 comments on commit 95e5e60

Please sign in to comment.