Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nicholasjhenry/my-umbrella
An experiment applying James Shore's Nullable patterns to Elixir
https://github.com/nicholasjhenry/my-umbrella
Last synced: 8 days ago
JSON representation
An experiment applying James Shore's Nullable patterns to Elixir
- Host: GitHub
- URL: https://github.com/nicholasjhenry/my-umbrella
- Owner: nicholasjhenry
- Created: 2024-07-05T17:34:35.000Z (4 months ago)
- Default Branch: develop
- Last Pushed: 2024-08-29T12:26:47.000Z (3 months ago)
- Last Synced: 2024-10-12T03:11:27.925Z (about 1 month ago)
- Language: Elixir
- Homepage: https://2024.elixirconf.com/#speakers-presenter-nicholas-henry
- Size: 753 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# My Umbrella: Do I need an umbrella today?
![My Umbrella](./assets/umbrella.webp)
An example application for the presentation:
Beyond Mocks - Messing with Our Preconceptions of Testing
This application demonstrates various tactics for testing external, unstable dependencies, AKA
infrastructure. For the presentation, the focus is specifically on James Shore's technique,
_Nullables_ from the pattern language _Testing Without Mocks_.## Example
```elixir
orlando = MyUmbrella.Coordinates.new(28.5383, -81.3792)
{:ok, weather} = MyUmbrella.for_today(orlando)
MyUmbrella.announce(weather)
#=> {:ok, MyUmbrella.Announcement{value: "Thunderstorms! Take two umbrellas!"}}
```## Sequence Diagram
```mermaid
sequenceDiagram
Controller->>MyUmbrella: for_today(Coordinates.t())
MyUmbrella->>WeatherApi: get_forecast(Coordinates.t(), :today)
WeatherApi-->>MyUmbrella: {:ok, list(WeatherReport.t())}
MyUmbrella->>WeatherReport: filter_by_same_day(list(WeatherReport.t()), DateTime.t())
WeatherReport-->>MyUmbrella: list(WeatherReport.t())
MyUmbrella->>Precipitation: determine_most_intense_precipitation_condition(list(WeatherReport.t()), :today)
Precipitation-->>MyUmbrella: Precipitation.t()
MyUmbrella-->>Controller: {:ok, Precipitation.t()}
Controller->>MyUmbrella: announce(Precipitation.t())
MyUmbrella->>Announcement: to_announcement(Precipitation.t())
Announcement-->>MyUmbrella: Annoucement.t()
MyUmbrella-->>Controller: Annoucement.t()
```## Development
Prerequites:
- `asdf`: https://asdf-vm.com/
- `httpie`: https://httpie.io/cli
- Open Weather Map Application ID: https://openweathermap.org/Setup:
```sh
git clone https://github.com/nicholasjhenry/my_umbrella.git
cd ./my_umbrella
asdf install
```Testing:
```sh
mix test
```Lint and type checks:
```sh
mix check
```Run:
```sh
# terminal window: 1
export OPEN_WEATHER_MAP_APP_ID=YOUR_APP_ID
mix server# terminal window: 2
script/request
```