Skip to content

Commit

Permalink
Prepare release v0.2.0 (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
josemrb authored and szymon-jez committed Feb 20, 2019
1 parent 6493150 commit 9d44cad
Show file tree
Hide file tree
Showing 29 changed files with 2,063 additions and 1,259 deletions.
4 changes: 4 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
line_length: 160
]
36 changes: 24 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
language: elixir

elixir:
- 1.4
- 1.5
- 1.6
- 1.7
- 1.8
otp_release:
- 19.3
- 20.3
- 21.0
matrix:
exclude:
- elixir: 1.4
otp_release: 21.0
- elixir: 1.5
otp_release: 21.0
- elixir: 1.7
otp_release: 19.3
- elixir: 1.7
otp_release: 20.3
- elixir: 1.8
otp_release: 19.3
- elixir: 1.8
otp_release: 20.3
env:
global:
- MIX_ENV=test

matrix:
include:
- elixir: 1.3.4
env: TRAVIS_COVERAGE=true
otp_release: 18.3
- elixir: 1.4.2
otp_release: 18.3
- elixir: 1.4.2
otp_release: 19.3

after_success: |
if [ ! -z "${TRAVIS_COVERAGE}" ]; then
mix coveralls.travis
Expand Down
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
# ExPhoneNumber

[![Build Status](https://travis-ci.org/socialpaymentsbv/ex_phone_number.svg?branch=develop)](https://travis-ci.org/socialpaymentsbv/ex_phone_number)
[![Build Status](https://travis-ci.org/socialpaymentsbv/ex_phone_number.svg?branch=develop)](https://travis-ci.org/socialpaymentsbv/ex_phone_number) [![Hex Version](http://img.shields.io/hexpm/v/ex_phone_number.svg?style=flat)](https://hex.pm/packages/ex_phone_number)

It's a library for parsing, formatting, and validating international phone numbers.
Based on Google's [libphonenumber](https://github.com/googlei18n/libphonenumber).
Based on Google's [libphonenumber](https://github.com/googlei18n/libphonenumber) (current metadata version: 8.10.2).

## Installation

1. Add `:ex_phone_number` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:ex_phone_number, "~> 0.1"}]
end
```

2. Add `:ex_phone_number` to the list of applications in `mix.exs`:
```elixir
def application do
[mod: {MyApp, []},
applications: [..., :ex_phone_number]]
[{:ex_phone_number, "~> 0.2"}]
end
```

Expand Down
7 changes: 1 addition & 6 deletions config/.credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
{Credo.Check.Consistency.SpaceAroundOperators},
{Credo.Check.Consistency.SpaceInParentheses},
{Credo.Check.Consistency.TabsOrSpaces},

{Credo.Check.Design.AliasUsage, priority: :low},
{Credo.Check.Design.DuplicatedCode, mass_threshold: 16, nodes_threshold: 2},

{Credo.Check.Design.TagTODO, exit_status: 2},
{Credo.Check.Design.TagFIXME},

{Credo.Check.Readability.FunctionNames},
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 160},
{Credo.Check.Readability.ModuleAttributeNames},
Expand All @@ -29,7 +26,6 @@
{Credo.Check.Readability.TrailingBlankLine},
{Credo.Check.Readability.TrailingWhiteSpace},
{Credo.Check.Readability.VariableNames},

{Credo.Check.Refactor.ABCSize},
{Credo.Check.Refactor.CaseTrivialMatches},
{Credo.Check.Refactor.CondStatements},
Expand All @@ -41,7 +37,6 @@
{Credo.Check.Refactor.NegatedConditionsWithElse},
{Credo.Check.Refactor.Nesting},
{Credo.Check.Refactor.UnlessWithElse},

{Credo.Check.Warning.IExPry},
{Credo.Check.Warning.IoInspect},
{Credo.Check.Warning.NameRedeclarationByAssignment},
Expand All @@ -54,7 +49,7 @@
{Credo.Check.Warning.UnusedListOperation},
{Credo.Check.Warning.UnusedStringOperation},
{Credo.Check.Warning.UnusedTupleOperation},
{Credo.Check.Warning.OperationWithConstantResult},
{Credo.Check.Warning.OperationWithConstantResult}
]
}
]
Expand Down
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ use Mix.Config
config :logger,
backends: [:console]

import_config "#{Mix.env}.exs"
import_config "#{Mix.env()}.exs"
19 changes: 13 additions & 6 deletions lib/ex_phone_number.ex
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
defmodule ExPhoneNumber do
def format(%ExPhoneNumber.Model.PhoneNumber{} = phone_number, phone_number_format) when is_atom(phone_number_format), do: ExPhoneNumber.Formatting.format(phone_number, phone_number_format)
def format(%ExPhoneNumber.Model.PhoneNumber{} = phone_number, phone_number_format)
when is_atom(phone_number_format),
do: ExPhoneNumber.Formatting.format(phone_number, phone_number_format)

def get_number_type(%ExPhoneNumber.Model.PhoneNumber{} = phone_number), do: ExPhoneNumber.Validation.get_number_type(phone_number)
def get_number_type(%ExPhoneNumber.Model.PhoneNumber{} = phone_number),
do: ExPhoneNumber.Validation.get_number_type(phone_number)

def is_possible_number?(%ExPhoneNumber.Model.PhoneNumber{} = phone_number), do: ExPhoneNumber.Validation.is_possible_number?(phone_number)
def is_possible_number?(%ExPhoneNumber.Model.PhoneNumber{} = phone_number),
do: ExPhoneNumber.Validation.is_possible_number?(phone_number)

def is_possible_number?(number, region_code) when is_binary(number), do: ExPhoneNumber.Parsing.is_possible_number?(number, region_code)
def is_possible_number?(number, region_code) when is_binary(number),
do: ExPhoneNumber.Parsing.is_possible_number?(number, region_code)

def is_valid_number?(%ExPhoneNumber.Model.PhoneNumber{} = phone_number), do: ExPhoneNumber.Validation.is_valid_number?(phone_number)
def is_valid_number?(%ExPhoneNumber.Model.PhoneNumber{} = phone_number),
do: ExPhoneNumber.Validation.is_valid_number?(phone_number)

def parse(number_to_parse, default_region), do: ExPhoneNumber.Parsing.parse(number_to_parse, default_region)
def parse(number_to_parse, default_region),
do: ExPhoneNumber.Parsing.parse(number_to_parse, default_region)
end
Loading

0 comments on commit 9d44cad

Please sign in to comment.