Skip to content

Commit

Permalink
Merge pull request #73 from annkissam/release/2.0
Browse files Browse the repository at this point in the history
Release/2.0
  • Loading branch information
thebugcatcher committed Sep 5, 2018
2 parents 5267970 + a51d433 commit 7da66bd
Show file tree
Hide file tree
Showing 72 changed files with 2,156 additions and 1,370 deletions.
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
elixir 1.4.5
erlang 20.2
elixir 1.6.5
erlang 20.3.6
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
language: elixir
elixir:
- 1.4.5
- 1.5.2
- 1.6.0
- 1.6.5
- 1.7.3
otp_release:
- 20.2
- 20.3
sudo: false
env:
- MIX_ENV=test POSTGRES_USERNAME=postgres POSTGRES_PASSWORD=
- MIX_ENV=test POSTGRES_USER=postgres POSTGRES_PASSWORD=
script:
- mix test
after_script:
Expand Down
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Versions CHANGELOG

## Version 2.0.0-rc.0

- Change in namespace/module names:
* Replace `Rummage.Ecto.Hooks` with `Rummage.Ecto.Hook`.
* Replace `Rummage.Ecto.CustomHooks` with `Rummage.Ecto.CustomHook`.

- Introducing `Rummage.Ecto.Schema`:

- Changes to `Rummage.Ecto.Hook.Search`:

- Changes to `Rummage.Ecto.Hook.Sort`:

- Changes to `Rummage.Ecto.Hook.Paginate`:

- Changes in Configurations:



## Version: 1.3.0-rc.0

- Better Behaviour definition for Hooks.
Expand All @@ -25,7 +43,7 @@
* This allows usage of `or_where` and `not_where` queries.
* Defaults to `where`.

- Search hook has `search_type` : `is_null`
- Search hook has `search_type` : `is_nil`
* This allows for searching for `NULL` or `NOT NULL`

- Tested/Examples with different `field_types`, `boolean`, `float`, `string` etc.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2017 Aditya Iyengar
Copyright (c) 2017 Annkissam

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
32 changes: 10 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

<img src="src/rummage_logo.png" alt="https://hexdocs.pm/rummage_ecto/Rummage.Ecto.html" width="150" height="150">

[![Build Status](https://travis-ci.org/aditya7iyengar/rummage_ecto.svg?branch=master)](https://travis-ci.org/aditya7iyengar/rummage_ecto)
[![Coverage Status](https://coveralls.io/repos/github/aditya7iyengar/rummage_ecto/badge.svg?branch=master)](https://coveralls.io/github/aditya7iyengar/rummage_ecto?branch=master)
[![Build Status](https://travis-ci.org/annkissam/rummage_ecto.svg?branch=master)](https://travis-ci.org/annkissam/rummage_ecto)
[![Coverage Status](https://coveralls.io/repos/github/annkissam/rummage_ecto/badge.svg?branch=master)](https://coveralls.io/github/annkissam/rummage_ecto?branch=master)
[![Hex Version](http://img.shields.io/hexpm/v/rummage_ecto.svg?style=flat)](https://hex.pm/packages/rummage_ecto)
[![hex.pm downloads](https://img.shields.io/hexpm/dt/rummage_ecto.svg)](https://hex.pm/packages/rummage_ecto)
[![Hex docs](http://img.shields.io/badge/hex.pm-docs-green.svg?style=flat)](https://hexdocs.pm/rummage_ecto)
[![docs](https://inch-ci.org/github/aditya7iyengar/rummage_ecto.svg)](http://inch-ci.org/github/aditya7iyengar/rummage_ecto)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/aditya7iyengar/rummage_ecto/master/LICENSE)
[![docs](https://inch-ci.org/github/annkissam/rummage_ecto.svg)](http://inch-ci.org/github/annkissam/rummage_ecto)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/annkissam/rummage_ecto/master/LICENSE)

**If you're looking for full `Phoenix` support, `Rummage.Phoenix` uses `Rummage.Ecto` and adds `HTML` and `Controller` support
to it. You can check `Rummage.Phoenix` out by clicking [here](https://github.com/aditya7iyengar/rummage_phoenix)**
to it. You can check `Rummage.Phoenix` out by clicking [here](https://github.com/annkissam/rummage_phoenix)**

**Please refer for [CHANGELOG](CHANGELOG.md) for version specific changes**

Expand All @@ -28,7 +28,7 @@ hook.
If you'd like to have something like that, you can always configure `Rummage` to use your `Search` module for that model. This
is why Rummage has been made configurable.**

To see an example usage of `rummage`, check [this](https://github.com/aditya7iyengar/rummage_ecto_example) repository.
To see an example usage of `rummage`, check [this](https://github.com/annkissam/rummage_ecto_example) repository.

## Installation

Expand All @@ -38,17 +38,17 @@ This package is [available in Hex](https://hexdocs.pm/rummage_ecto/), and can be

```elixir
def deps do
[{:rummage_ecto, "~> 1.3"}]
[{:rummage_ecto, "~> 2.0.0-rc.0"}]
end
```

## Blogs

### Current Blogs:

- [Rummage Demo & Basics](https://medium.com/@aditya7iyengar/searching-sorting-and-pagination-in-elixir-phoenix-with-rummage-part-1-933106ec50ca#.der0yrnvq)
- [Using Rummage.Ecto](https://medium.com/@aditya7iyengar/searching-sorting-and-pagination-in-elixir-phoenix-with-rummage-part-2-8e36558984c2#.vviioi5ia)
- [Using Rummage.Phoenix: Part 1](https://medium.com/@aditya7iyengar/searching-sorting-and-pagination-in-elixir-phoenix-with-rummage-part-3-7cf5023bc226#.q08478ud2)
- [Rummage Demo & Basics](https://medium.com/aditya7iyengar/searching-sorting-and-pagination-in-elixir-phoenix-with-rummage-part-1-933106ec50ca#.der0yrnvq)
- [Using Rummage.Ecto](https://medium.com/aditya7iyengar/searching-sorting-and-pagination-in-elixir-phoenix-with-rummage-part-2-8e36558984c2#.vviioi5ia)
- [Using Rummage.Phoenix: Part 1](https://medium.com/aditya7iyengar/searching-sorting-and-pagination-in-elixir-phoenix-with-rummage-part-3-7cf5023bc226#.q08478ud2)

### Coming up next:

Expand Down Expand Up @@ -165,15 +165,3 @@ Below are the ways `Rummage.Ecto` can be used:
paginate: %{per_page: 5, page: 1}
}
```

## Example with Screenshots

- Coming soon...


## Next Steps

- [ ] Strealine associations
- [ ] `rummage_ecto` should have a custom hook to handle embedded_fields
- [ ] Continued writing blogs

32 changes: 1 addition & 31 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -1,34 +1,4 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config

# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
# file won't be loaded nor affect the parent project. For this reason,
# if you want to provide default values for your application for
# 3rd-party users, it should be done in your "mix.exs" file.

# You can configure for your application as:
#
# config :rummage_ecto, key: :value
#
# And access this configuration in your application as:
#
# Application.get_env(:rummage_ecto, :key)
#
# Or configure a 3rd-party app:
#
# config :logger, level: :info
#

# It is also possible to import configuration files, relative to this
# directory. For example, you can emulate configuration per environment
# by uncommenting the line below and defining dev.exs, test.exs and such.
# Configuration from the imported file will override the ones defined
# here (which is why it is important to import them last).
#

if Mix.env == :test ||
Mix.env == :dev ||
Mix.env == :docs, do: import_config "#{Mix.env}.exs"
if Mix.env in ~w{test dev docs}a, do: import_config "#{Mix.env}.exs"

2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ config :rummage_ecto, ecto_repos: [Rummage.Ecto.Repo]

config :rummage_ecto, Rummage.Ecto.Repo,
adapter: Ecto.Adapters.Postgres,
username: System.get_env("POSTGRES_USERNAME"),
username: System.get_env("POSTGRES_USER"),
password: System.get_env("POSTGRES_PASSWORD"),
database: "rummage_ecto_test",
pool: Ecto.Adapters.SQL.Sandbox
2 changes: 1 addition & 1 deletion coveralls.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"coverage_options": {
"treat_no_relevant_lines_as_covered": true,
"minimum_coverage": 100
"minimum_coverage": 90
},
"skip_files": [
"test",
Expand Down
16 changes: 8 additions & 8 deletions lib/rummage_ecto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,21 @@ defmodule Rummage.Ecto do
already configured your app to use a default `search` and/or
specified the `search` at `__using__` level, this is a way of
overriding those defaults. This can be used to override native
`Rummage.Ecto.Hooks.Search` to a custom hook.
`Rummage.Ecto.Hook.Search` to a custom hook.
* `sort`: If you haven't set up a `sort` at the config level or `__using__`
level, this a way of passing `sort` to `rummage`. If you have
already configured your app to use a default `sort` and/or
specified the `sort` at `__using__` level, this is a way of
overriding those defaults. This can be used to override native
`Rummage.Ecto.Hooks.Sort` to a custom hook.
`Rummage.Ecto.Hook.Sort` to a custom hook.
* `paginate`: If you haven't set up a `paginate` at the config level or `__using__`
level, this a way of passing `paginate` to `rummage`. If you have
already configured your app to use a default `paginate` and/or
specified the `paginate` at `__using__` level, this is a way of
overriding those defaults. This can be used to override native
`Rummage.Ecto.Hooks.Paginate` to a custom hook.
`Rummage.Ecto.Hook.Paginate` to a custom hook.
## Examples
Expand Down Expand Up @@ -124,7 +124,7 @@ defmodule Rummage.Ecto do
iex> rummage = %{paginate: %{page: 1}}
iex> repo = Rummage.Ecto.Repo
iex> Ecto.Adapters.SQL.Sandbox.checkout(repo)
iex> opts = [paginate: Rummage.Ecto.Hooks.Paginate, repo: repo]
iex> opts = [paginate: Rummage.Ecto.Hook.Paginate, repo: repo]
iex> {queryable, rummage} = rummage(Product, rummage, opts)
iex> rummage
%{paginate: %{max_page: 0, page: 1, per_page: 10, total_count: 0}}
Expand All @@ -140,9 +140,9 @@ defmodule Rummage.Ecto do
iex> rummage = %{paginate: %{per_page: 1, page: 1}}
iex> repo = Rummage.Ecto.Repo
iex> Ecto.Adapters.SQL.Sandbox.checkout(repo)
iex> repo.insert!(%Product{name: "name"})
iex> repo.insert!(%Product{name: "name2"})
iex> opts = [paginate: Rummage.Ecto.Hooks.Paginate,
iex> repo.insert!(%Product{name: "name", internal_code: "100"})
iex> repo.insert!(%Product{name: "name2", internal_code: "101"})
iex> opts = [paginate: Rummage.Ecto.Hook.Paginate,
...> repo: repo]
iex> {queryable, rummage} = rummage(Product, rummage, opts)
iex> rummage
Expand Down Expand Up @@ -237,7 +237,7 @@ defmodule Rummage.Ecto do
end

defp defaults() do
keys = ~w(repo per_page search sort paginate)a
keys = ~w{repo per_page search sort paginate}a
Enum.map(keys, &get_defs/1)
end

Expand Down
27 changes: 14 additions & 13 deletions lib/rummage_ecto/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ defmodule Rummage.Ecto.Config do
config :app_name, Rummage.Ecto,
per_page: 10,
repo: AppName.Repo,
search: Rummage.Ecto.Hooks.Search,
sort: Rummage.Ecto.Hooks.Sort,
paginate: Rummage.Ecto.Hooks.Paginate
search: Rummage.Ecto.Hook.Search,
sort: Rummage.Ecto.Hook.Sort,
paginate: Rummage.Ecto.Hook.Paginate
"""

Expand All @@ -35,13 +35,13 @@ defmodule Rummage.Ecto.Config do
## Examples
When no config is set, if returns the default hook
(`Rummage.Ecto.Hooks.Search`):
(`Rummage.Ecto.Hook.Search`):
iex> alias Rummage.Ecto.Config
iex> Config.search
Rummage.Ecto.Hooks.Search
Rummage.Ecto.Hook.Search
"""
def search(application \\ :rummage_ecto) do
config(:search, Rummage.Ecto.Hooks.Search, application)
config(:search, Rummage.Ecto.Hook.Search, application)
end

@doc """
Expand All @@ -50,13 +50,13 @@ defmodule Rummage.Ecto.Config do
## Examples
When no config is set, if returns the default hook
(`Rummage.Ecto.Hooks.Sort`):
(`Rummage.Ecto.Hook.Sort`):
iex> alias Rummage.Ecto.Config
iex> Config.sort
Rummage.Ecto.Hooks.Sort
Rummage.Ecto.Hook.Sort
"""
def sort(application \\ :rummage_ecto) do
config(:sort, Rummage.Ecto.Hooks.Sort, application)
config(:sort, Rummage.Ecto.Hook.Sort, application)
end

@doc """
Expand All @@ -65,13 +65,13 @@ defmodule Rummage.Ecto.Config do
## Examples
When no config is set, if returns the default hook
(`Rummage.Ecto.Hooks.Paginate`):
(`Rummage.Ecto.Hook.Paginate`):
iex> alias Rummage.Ecto.Config
iex> Config.paginate
Rummage.Ecto.Hooks.Paginate
Rummage.Ecto.Hook.Paginate
"""
def paginate(application \\ :rummage_ecto) do
config(:paginate, Rummage.Ecto.Hooks.Paginate, application)
config(:paginate, Rummage.Ecto.Hook.Paginate, application)
end

@doc """
Expand Down Expand Up @@ -109,7 +109,8 @@ defmodule Rummage.Ecto.Config do
end

defp config(key, default, application) do
config(application)
application
|> config()
|> Keyword.get(key, default)
|> resolve_config(default)
end
Expand Down
Loading

0 comments on commit 7da66bd

Please sign in to comment.