Skip to content

Commit f77d426

Browse files
authored
Version 3.0.0 release (#177)
* Version 3.0.0 release * Version 3.0.0 release * Version 3.0.0 release * Version 3.0.0 release * Version 3.0.0 release * Version 3.0.0 release
1 parent 77cd4a0 commit f77d426

File tree

9 files changed

+118
-53
lines changed

9 files changed

+118
-53
lines changed

.github/workflows/test.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: test
2+
3+
'on':
4+
push:
5+
pull_request:
6+
branches:
7+
# Branches from forks have the form 'user:branch-name'. Reference:
8+
# https://github.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662/9
9+
- '**:**'
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
env:
17+
MIX_ENV: test
18+
strategy:
19+
matrix:
20+
elixir: ['1.10', '1.11', '1.12']
21+
otp: ['23', '24']
22+
continue-on-error: false
23+
24+
steps:
25+
- uses: actions/checkout@v2
26+
27+
- name: Setup elixir
28+
uses: erlef/setup-elixir@v1
29+
with:
30+
elixir-version: ${{ matrix.elixir }}
31+
otp-version: ${{ matrix.otp }}
32+
33+
- name: Get deps cache
34+
uses: actions/cache@v2
35+
with:
36+
path: deps/
37+
key: deps-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
38+
39+
- name: Get build cache
40+
uses: actions/cache@v2
41+
with:
42+
path: _build/test/
43+
key: build-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
44+
45+
- name: Install Dependencies
46+
run: |
47+
mix local.rebar --force
48+
mix local.hex --force
49+
mix deps.get
50+
mix compile
51+
- name: Run linters
52+
run: |
53+
mix format --check-formatted
54+
mix credo --strict
55+
- name: Run Tests
56+
run: mix coveralls.github
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
60+
- name: Retrieve PLT Cache
61+
uses: actions/cache@v2
62+
id: plt-cache
63+
with:
64+
path: priv/plts
65+
key: plts-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
66+
67+
- name: Create PLTs
68+
if: steps.plt-cache.outputs.cache-hit != 'true'
69+
run: |
70+
mkdir -p priv/plts
71+
mix dialyzer --plt
72+
- name: Run dialyzer
73+
run: mix dialyzer --no-check

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/tmp
77
erl_crash.dump
88
*.ez
9+
/priv/plts
910

1011
#### osx ####
1112
*.DS_Store

.travis.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
9+
## v3.0.0 - 2021-09-12
10+
11+
### Features
12+
13+
- Now support `elixir>=1.10`
14+
- Updates `ecto` to `3.7`
15+
- Updates bunch of other deps to newer versions
16+
17+
### Misc
18+
19+
- Moves from Travis to GitHub Actions
20+
- Adds `mix format` support
21+
22+
823
## v2.0.1 - 2019-10-16
924

1025
### Bugfixes

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# EctoAutoslugField
22

3-
[![Build Status](https://travis-ci.org/sobolevn/ecto_autoslug_field.svg?branch=master)](https://travis-ci.org/sobolevn/ecto_autoslug_field)
3+
[![Build Status](https://github.com/sobolevn/ecto_autoslug_field/workflows/test/badge.svg?branch=master&event=push)](https://github.com/sobolevn/ecto_autoslug_field/actions?query=workflow%3Atest)
44
[![Coverage Status](https://coveralls.io/repos/github/sobolevn/ecto_autoslug_field/badge.svg?branch=master)](https://coveralls.io/github/sobolevn/ecto_autoslug_field?branch=master)
55
[![Module Version](https://img.shields.io/hexpm/v/ecto_autoslug_field.svg)](https://hex.pm/packages/ecto_autoslug_field)
66
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/ecto_autoslug_field/)
7-
[![Total Download](https://img.shields.io/hexpm/dt/ecto_autoslug_field.svg)](https://hex.pm/packages/ecto_autoslug_field)
87
[![License](https://img.shields.io/hexpm/l/ecto_autoslug_field.svg)](https://github.com/sobolevn/ecto_autoslug_field/blob/master/LICENSE)
9-
[![Last Updated](https://img.shields.io/github/last-commit/sobolevn/ecto_autoslug_field.svg)](https://github.com/sobolevn/ecto_autoslug_field/commits/master)
108

119
`ecto_autoslug_field` is a reusable [`Ecto`](https://github.com/elixir-ecto/ecto) library which can automatically create slugs from other fields. We use [`slugger`](https://github.com/h4cc/slugger) as a default slug-engine.
1210

1311
We only depend on the `ecto` package (we do not deal with `ecto_sql` at all).
14-
We support `ecto >= 2.1 and ecto < 4`!
12+
We support `ecto >= 3.7 and ecto < 4`!
1513

1614
See [this blog post](https://sobolevn.me/2017/07/creating-slugs-for-ecto-schemas)
1715
for more information.
@@ -22,7 +20,7 @@ for more information.
2220
```elixir
2321
def deps do
2422
[
25-
{:ecto_autoslug_field, "~> 2.0"}
23+
{:ecto_autoslug_field, "~> 3.0"}
2624
]
2725
end
2826
```
@@ -73,13 +71,13 @@ defmodule EctoSlugs.Blog.Article do
7371
timestamps()
7472
end
7573

76-
def changeset(%Article{} = article, attrs) do
77-
article
78-
|> cast(attrs, [:title, :content, :breaking])
74+
def changeset(model, params \\ :invalid) do
75+
model
76+
|> cast(params, [:title, :content, :breaking])
7977
|> validate_required([:title, :content])
8078
|> unique_constraint(:title)
81-
|> TitleSlug.maybe_generate_slug
82-
|> TitleSlug.unique_constraint
79+
|> TitleSlug.maybe_generate_slug()
80+
|> TitleSlug.unique_constraint()
8381
end
8482
end
8583
```

lib/ecto_autoslug_field/slug.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ defmodule EctoAutoslugField.SlugBase do
4848
1. `atom`-key is supposed to identify the model field
4949
2. `binary`-key is treated as a data itself, it won't be changed
5050
"""
51-
@spec get_sources(Changeset.t(), Keyword.t()) ::
52-
list(atom() | binary()) | none
51+
@spec get_sources(Changeset.t(), Keyword.t()) :: list(atom() | binary())
5352
def get_sources(_changeset, [from: from] = _opts) do
53+
# This code is only used in macros, so it is not tracked by `coveralls`.
54+
# coveralls-ignore-start
5455
[from]
56+
# coveralls-ignore-stop
5557
end
5658

5759
@doc """

lib/ecto_autoslug_field/slug_generator.ex

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ defmodule EctoAutoslugField.SlugGenerator do
55
It is suited for inner use.
66
"""
77

8+
alias Ecto.Changeset
9+
810
import Ecto.Changeset,
911
only: [
1012
put_change: 3,
@@ -17,9 +19,7 @@ defmodule EctoAutoslugField.SlugGenerator do
1719
Default slug builder.
1820
"""
1921
@spec build_slug(Keyword.t(), Changeset.t()) :: String.t()
20-
def build_slug(sources, _changeset) do
21-
do_build_slug(sources)
22-
end
22+
def build_slug(sources, _changeset), do: do_build_slug(sources)
2323

2424
@doc """
2525
This function conditionally generates slug.
@@ -96,10 +96,6 @@ defmodule EctoAutoslugField.SlugGenerator do
9696
defp get_field_data(_, source, _) when is_binary(source), do: source
9797

9898
defp has_value?(nil), do: false
99-
100-
defp has_value?(string) when is_binary(string) do
101-
String.trim(string) != ""
102-
end
103-
99+
defp has_value?(string) when is_binary(string), do: String.trim(string) != ""
104100
defp has_value?(_), do: true
105101
end

mix.exs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ defmodule EctoAutoslugField.Mixfile do
22
use Mix.Project
33

44
@source_url "https://github.com/sobolevn/ecto_autoslug_field"
5-
@version "2.0.1"
5+
@version "3.0.0"
66

77
def project do
88
[
99
app: :ecto_autoslug_field,
1010
version: @version,
11-
elixir: "~> 1.6",
11+
elixir: "~> 1.10",
1212
deps: deps(),
1313
build_embedded: Mix.env() == :prod,
1414
start_permanent: Mix.env() == :prod,
@@ -27,7 +27,10 @@ defmodule EctoAutoslugField.Mixfile do
2727
],
2828

2929
# Dialyzer:
30-
dialyzer: [plt_add_deps: :apps_direct, plt_add_apps: [:ecto]]
30+
dialyzer: [
31+
plt_add_deps: :apps_direct,
32+
plt_add_apps: [:ecto]
33+
]
3134
]
3235
end
3336

@@ -37,15 +40,15 @@ defmodule EctoAutoslugField.Mixfile do
3740

3841
defp deps do
3942
[
40-
{:ecto, ">= 2.1.0"},
43+
{:ecto, ">= 3.7.0"},
4144

4245
# Slugs:
43-
{:slugger, ">= 0.2.0"},
46+
{:slugger, ">= 0.3.0"},
4447

4548
# Testing:
46-
{:excoveralls, "~> 0.5", only: :test},
47-
{:credo, "~> 1.0", only: [:dev, :test], runtime: false},
48-
{:dialyxir, "~> 1.0", only: :dev, runtime: false},
49+
{:excoveralls, "~> 0.14", only: :test},
50+
{:credo, "~> 1.5", only: [:dev, :test], runtime: false},
51+
{:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false},
4952

5053
# Documentation:
5154
{:ex_doc, ">= 0.23.0", only: :dev, runtime: false}

mix.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
66
"dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},
77
"earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"},
8-
"ecto": {:hex, :ecto, "3.6.2", "efdf52acfc4ce29249bab5417415bd50abd62db7b0603b8bab0d7b996548c2bc", [: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", "efad6dfb04e6f986b8a3047822b0f826d9affe8e4ebdd2aeedbfcb14fd48884e"},
8+
"ecto": {:hex, :ecto, "3.7.1", "a20598862351b29f80f285b21ec5297da1181c0442687f9b8329f0445d228892", [: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 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d36e5b39fc479e654cffd4dbe1865d9716e4a9b6311faff799b6f90ab81b8638"},
99
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
1010
"ex_doc": {:hex, :ex_doc, "0.25.1", "4b736fa38dc76488a937e5ef2944f5474f3eff921de771b25371345a8dc810bc", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "3200b0a69ddb2028365281fbef3753ea9e728683863d8cdaa96580925c891f67"},
1111
"excoveralls": {:hex, :excoveralls, "0.14.2", "f9f5fd0004d7bbeaa28ea9606251bb643c313c3d60710bad1f5809c845b748f0", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "ca6fd358621cb4d29311b29d4732c4d47dac70e622850979bc54ed9a3e50f3e1"},
@@ -22,6 +22,6 @@
2222
"parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"},
2323
"slugger": {:hex, :slugger, "0.3.0", "efc667ab99eee19a48913ccf3d038b1fb9f165fa4fbf093be898b8099e61b6ed", [:mix], [], "hexpm", "20d0ded0e712605d1eae6c5b4889581c3460d92623a930ddda91e0e609b5afba"},
2424
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
25-
"telemetry": {:hex, :telemetry, "0.4.3", "a06428a514bdbc63293cd9a6263aad00ddeb66f608163bdec7c8995784080818", [:rebar3], [], "hexpm", "eb72b8365ffda5bed68a620d1da88525e326cb82a75ee61354fc24b844768041"},
25+
"telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"},
2626
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
2727
}

0 commit comments

Comments
 (0)