{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Bootstrapping the environment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "All dependencies are up to date\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{:ok, [\"relative_path\", \"relevant_search\"]}"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Boyle.mk(\"relative_path\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "All dependencies are up to date\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       ":ok"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Boyle.activate(\"relative_path\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Resolving Hex dependencies...\n",
      "Dependency resolution completed:\n",
      "Unchanged:\n",
      "  jason 1.1.2\n",
      "All dependencies are up to date\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       ":ok"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Boyle.install({:jason, \"~> 1.0\"})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Loading local module\n",
    "\n",
    "We can write some herlper modules and the import them in notebooks.\n",
    "\n",
    "1. Firstly, create a new `ex` file with needed code:\n",
    "    ```elixir\n",
    "    # ./foo.ex\n",
    "    \n",
    "    defmodule Foo do\n",
    "      def bar\n",
    "        :bar\n",
    "      end\n",
    "    end\n",
    "    ```\n",
    "    \n",
    "2. Load the code using `c/1` iex helper command"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Foo]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c(\"foo.ex\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, we can use the functions from this module as expected:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       ":bar"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Foo.bar()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Reading from local files"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We are using `File.read` to do this, while all the pathes can be raltive. for example with json:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "%{\"foo\" => \"bar\"}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Jason.decode!(File.read!(\"data.json\"))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Elixir",
   "language": "Elixir",
   "name": "ielixir"
  },
  "language_info": {
   "codemirror_mode": "elixir",
   "file_extension": "ex",
   "mimetype": "text/x-elixir",
   "name": "elixir",
   "nbconvert_exporter": "",
   "pygments_lexer": "elixir",
   "version": "1.9.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
