View Source ExAequo.File.Names (ExAequo v0.6.7)

Tool to manipulate file names

Summary

Functions

assure_ext assures that a given extension is added if not yet present

iex(1)> assure_ext("hello.ex", "ex") "hello.ex"

remove_ext assures that a given extension is removed if present

iex(0)> remove_ext("a.rb", "rb") "a"

replace_ext assures that a given extension replaces the last extension

iex(5)> replace_ext("hello.ex", "ex") "hello.ex"

Functions

Link to this function

assure_ext(path, extension)

View Source

assure_ext assures that a given extension is added if not yet present

iex(1)> assure_ext("hello.ex", "ex") "hello.ex"

iex(2)> assure_ext("hello", "ex") "hello.ex"

iex(3)> assure_ext("some_dir/hello", "ex") "some_dir/hello.ex"

iex(4)> assure_ext("hello.html", "eex") "hello.html.eex"

Link to this function

remove_ext(path, extension)

View Source

remove_ext assures that a given extension is removed if present

iex(0)> remove_ext("a.rb", "rb") "a"

iex(0)> remove_ext("d/a.ex", "rb") "d/a.ex"

Link to this function

replace_ext(path, extension)

View Source

replace_ext assures that a given extension replaces the last extension

iex(5)> replace_ext("hello.ex", "ex") "hello.ex"

iex(6)> replace_ext("hello.rb", "ex") "hello.ex"

iex(7)> replace_ext("hello.html.erb", "eex") "hello.html.eex"

iex(8)> replace_ext("dir/base", "ex") "dir/base.ex"