-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds bang versions for each function
- Loading branch information
Showing
22 changed files
with
163 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,34 @@ | ||
defmodule PetrovichElixir.Petrovich do | ||
defmodule Petrovich do | ||
@moduledoc """ | ||
Public interface to all the functions. | ||
Documentation for Petrovich. | ||
Public interface to all the functions. | ||
It can inflect first, middle, and last names. | ||
It also can detect gender by name. | ||
""" | ||
|
||
alias PetrovichElixir.Parser | ||
alias Petrovich.Parser | ||
|
||
@default_gender :androgynous | ||
|
||
def firstname(name, case_, gender \\ @default_gender) do | ||
Parser.parse(name, :firstname, case_, gender) | ||
end | ||
def firstname!(name, case_, gender \\ @default_gender) do | ||
Parser.parse!(name, :firstname, case_, gender) | ||
end | ||
|
||
def middlename(name, case_, gender \\ @default_gender) do | ||
Parser.parse(name, :middlename, case_, gender) | ||
end | ||
def middlename!(name, case_, gender \\ @default_gender) do | ||
Parser.parse!(name, :middlename, case_, gender) | ||
end | ||
|
||
def lastname(name, case_, gender \\ @default_gender) do | ||
Parser.parse(name, :lastname, case_, gender) | ||
end | ||
def lastname!(name, case_, gender \\ @default_gender) do | ||
Parser.parse!(name, :lastname, case_, gender) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
defmodule PetrovichElixir.Applier do | ||
defmodule Petrovich.Applier do | ||
@moduledoc """ | ||
Applies rules on value. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
defmodule Petrovich.Exceptions.ParseException do | ||
defexception message: "Name is not parsed" | ||
end | ||
|
||
defmodule Petrovich.Exceptions.RulesFileException do | ||
defexception message: "Rules file is missing" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
lib/petrovich_elixir/stores/gender_store.ex → lib/petrovich/stores/gender_store.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
lib/petrovich_elixir/stores/name_store.ex → lib/petrovich/stores/name_store.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
defmodule PetrovichElixir.NameStore do | ||
defmodule Petrovich.NameStore do | ||
@moduledoc """ | ||
This module stores different rules on how to inflect values. | ||
It stores rules for first, middle and last names. | ||
""" | ||
|
||
use PetrovichElixir.Store, setting: :rules_path | ||
use Petrovich.Store, setting: :rules_path | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
defmodule PetrovichElixir.Mixfile do | ||
defmodule Petrovich.Mixfile do | ||
use Mix.Project | ||
|
||
@version "0.0.1" | ||
|
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
test/petrovich_elixir_test/config_test.exs → test/petrovich_test/config_test.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
defmodule PetrovichTest.Exceptions.ParseExceptionTest do | ||
use ExUnit.Case | ||
|
||
alias Petrovich.Parser | ||
alias Petrovich.Exceptions.ParseException | ||
|
||
test "raise ParseException" do | ||
assert_raise ParseException, fn -> | ||
Parser.parse!("bad value", :firstname, :prepositional, :male) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.