Skip to content

Commit

Permalink
update to elixir 0.14.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Kapkov committed Jul 4, 2014
1 parent 84e809c commit e2b7179
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 61 deletions.
24 changes: 12 additions & 12 deletions lib/faker/address.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,43 @@ defmodule Faker.Address do
Enum.each data, fn
{"values", values} ->
Enum.each values, fn({fun, list}) ->
def unquote(binary_to_atom(fun))() do
unquote(binary_to_atom("get_#{fun}"))(Faker.locale, :crypto.rand_uniform(0, unquote(binary_to_atom("#{fun}_count"))(Faker.locale)))
def unquote(String.to_atom(fun))() do
unquote(String.to_atom("get_#{fun}"))(Faker.locale, :crypto.rand_uniform(0, unquote(String.to_atom("#{fun}_count"))(Faker.locale)))
end
defp unquote(binary_to_atom("#{fun}_count"))(unquote(binary_to_atom(lang))) do
defp unquote(String.to_atom("#{fun}_count"))(unquote(String.to_atom(lang))) do
unquote(Enum.count(list))
end
Enum.with_index(list) |> Enum.each fn({el, index}) ->
defp unquote(binary_to_atom("get_#{fun}"))(unquote(binary_to_atom(lang)), unquote(index)) do
defp unquote(String.to_atom("get_#{fun}"))(unquote(String.to_atom(lang)), unquote(index)) do
unquote(el)
end
end
end
{"formats", values} ->
Enum.each values, fn({fun, list}) ->
def unquote(binary_to_atom(fun))() do
unquote(binary_to_atom("format_#{fun}"))(Faker.locale, :crypto.rand_uniform(0, unquote(binary_to_atom("#{fun}_count"))(Faker.locale)))
def unquote(String.to_atom(fun))() do
unquote(String.to_atom("format_#{fun}"))(Faker.locale, :crypto.rand_uniform(0, unquote(String.to_atom("#{fun}_count"))(Faker.locale)))
end
Enum.with_index(list) |> Enum.each fn({el, index}) ->
defp unquote(binary_to_atom("format_#{fun}"))(unquote(binary_to_atom(lang)), unquote(index)) do
defp unquote(String.to_atom("format_#{fun}"))(unquote(String.to_atom(lang)), unquote(index)) do
Faker.format(unquote(el))
end
end
defp unquote(binary_to_atom("#{fun}_count"))(unquote(binary_to_atom(lang))) do
defp unquote(String.to_atom("#{fun}_count"))(unquote(String.to_atom(lang))) do
unquote(Enum.count(list))
end
end
{"functions", values} ->
Enum.each values, fn({fun, list}) ->
def unquote(binary_to_atom(fun))() do
unquote(binary_to_atom(fun))(Faker.locale, :crypto.rand_uniform(0, unquote(binary_to_atom("#{fun}_count"))(Faker.locale)))
def unquote(String.to_atom(fun))() do
unquote(String.to_atom(fun))(Faker.locale, :crypto.rand_uniform(0, unquote(String.to_atom("#{fun}_count"))(Faker.locale)))
end
Enum.with_index(list) |> Enum.each fn({el, index}) ->
defp unquote(binary_to_atom(fun))(unquote(binary_to_atom(lang)), unquote(index)) do
defp unquote(String.to_atom(fun))(unquote(String.to_atom(lang)), unquote(index)) do
unquote(Code.string_to_quoted!('"#{el}"'))
end
end
defp unquote(binary_to_atom("#{fun}_count"))(unquote(binary_to_atom(lang))) do
defp unquote(String.to_atom("#{fun}_count"))(unquote(String.to_atom(lang))) do
unquote(Enum.count(list))
end
end
Expand Down
24 changes: 12 additions & 12 deletions lib/faker/commerce.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,43 @@ defmodule Faker.Commerce do
Enum.each data, fn
{"values", values} ->
Enum.each values, fn({fun, list}) ->
def unquote(binary_to_atom(fun))() do
unquote(binary_to_atom("get_#{fun}"))(Faker.locale, :crypto.rand_uniform(0, unquote(binary_to_atom("#{fun}_count"))(Faker.locale)))
def unquote(String.to_atom(fun))() do
unquote(String.to_atom("get_#{fun}"))(Faker.locale, :crypto.rand_uniform(0, unquote(String.to_atom("#{fun}_count"))(Faker.locale)))
end
defp unquote(binary_to_atom("#{fun}_count"))(unquote(binary_to_atom(lang))) do
defp unquote(String.to_atom("#{fun}_count"))(unquote(String.to_atom(lang))) do
unquote(Enum.count(list))
end
Enum.with_index(list) |> Enum.each fn({el, index}) ->
defp unquote(binary_to_atom("get_#{fun}"))(unquote(binary_to_atom(lang)), unquote(index)) do
defp unquote(String.to_atom("get_#{fun}"))(unquote(String.to_atom(lang)), unquote(index)) do
unquote(el)
end
end
end
{"formats", values} ->
Enum.each values, fn({fun, list}) ->
def unquote(binary_to_atom(fun))() do
unquote(binary_to_atom("format_#{fun}"))(Faker.locale, :crypto.rand_uniform(0, unquote(binary_to_atom("#{fun}_count"))(Faker.locale)))
def unquote(String.to_atom(fun))() do
unquote(String.to_atom("format_#{fun}"))(Faker.locale, :crypto.rand_uniform(0, unquote(String.to_atom("#{fun}_count"))(Faker.locale)))
end
Enum.with_index(list) |> Enum.each fn({el, index}) ->
defp unquote(binary_to_atom("format_#{fun}"))(unquote(binary_to_atom(lang)), unquote(index)) do
defp unquote(String.to_atom("format_#{fun}"))(unquote(String.to_atom(lang)), unquote(index)) do
Faker.format(unquote(el))
end
end
defp unquote(binary_to_atom("#{fun}_count"))(unquote(binary_to_atom(lang))) do
defp unquote(String.to_atom("#{fun}_count"))(unquote(String.to_atom(lang))) do
unquote(Enum.count(list))
end
end
{"functions", values} ->
Enum.each values, fn({fun, list}) ->
def unquote(binary_to_atom(fun))() do
unquote(binary_to_atom(fun))(Faker.locale, :crypto.rand_uniform(0, unquote(binary_to_atom("#{fun}_count"))(Faker.locale)))
def unquote(String.to_atom(fun))() do
unquote(String.to_atom(fun))(Faker.locale, :crypto.rand_uniform(0, unquote(String.to_atom("#{fun}_count"))(Faker.locale)))
end
Enum.with_index(list) |> Enum.each fn({el, index}) ->
defp unquote(binary_to_atom(fun))(unquote(binary_to_atom(lang)), unquote(index)) do
defp unquote(String.to_atom(fun))(unquote(String.to_atom(lang)), unquote(index)) do
unquote(Code.string_to_quoted!('"#{el}"'))
end
end
defp unquote(binary_to_atom("#{fun}_count"))(unquote(binary_to_atom(lang))) do
defp unquote(String.to_atom("#{fun}_count"))(unquote(String.to_atom(lang))) do
unquote(Enum.count(list))
end
end
Expand Down
16 changes: 8 additions & 8 deletions lib/faker/company.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ defmodule Faker.Company do
Enum.each data, fn
{"values", values} ->
Enum.each values, fn({fun, list}) ->
def unquote(binary_to_atom(fun))() do
unquote(binary_to_atom("get_#{fun}"))(Faker.locale, :crypto.rand_uniform(0, unquote(binary_to_atom("#{fun}_count"))(Faker.locale)))
def unquote(String.to_atom(fun))() do
unquote(String.to_atom("get_#{fun}"))(Faker.locale, :crypto.rand_uniform(0, unquote(String.to_atom("#{fun}_count"))(Faker.locale)))
end
defp unquote(binary_to_atom("#{fun}_count"))(unquote(binary_to_atom(lang))) do
defp unquote(String.to_atom("#{fun}_count"))(unquote(String.to_atom(lang))) do
unquote(Enum.count(list))
end
Enum.with_index(list) |> Enum.each fn({el, index}) ->
defp unquote(binary_to_atom("get_#{fun}"))(unquote(binary_to_atom(lang)), unquote(index)) do
defp unquote(String.to_atom("get_#{fun}"))(unquote(String.to_atom(lang)), unquote(index)) do
unquote(el)
end
end
end
{"functions", values} ->
Enum.each values, fn({fun, list}) ->
def unquote(binary_to_atom(fun))() do
unquote(binary_to_atom(fun))(Faker.locale, :crypto.rand_uniform(0, unquote(binary_to_atom("#{fun}_count"))(Faker.locale)))
def unquote(String.to_atom(fun))() do
unquote(String.to_atom(fun))(Faker.locale, :crypto.rand_uniform(0, unquote(String.to_atom("#{fun}_count"))(Faker.locale)))
end
Enum.with_index(list) |> Enum.each fn({el, index}) ->
defp unquote(binary_to_atom(fun))(unquote(binary_to_atom(lang)), unquote(index)) do
defp unquote(String.to_atom(fun))(unquote(String.to_atom(lang)), unquote(index)) do
unquote(Code.string_to_quoted!('"#{el}"'))
end
end
defp unquote(binary_to_atom("#{fun}_count"))(unquote(binary_to_atom(lang))) do
defp unquote(String.to_atom("#{fun}_count"))(unquote(String.to_atom(lang))) do
unquote(Enum.count(list))
end
end
Expand Down
20 changes: 10 additions & 10 deletions lib/faker/internet.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ defmodule Faker.Internet do
Enum.each data, fn
{"values", values} ->
Enum.each values, fn({fun, list}) ->
def unquote(binary_to_atom(fun))() do
unquote(binary_to_atom("get_#{fun}"))(Faker.locale, :crypto.rand_uniform(0, unquote(binary_to_atom("#{fun}_count"))(Faker.locale)))
def unquote(String.to_atom(fun))() do
unquote(String.to_atom("get_#{fun}"))(Faker.locale, :crypto.rand_uniform(0, unquote(String.to_atom("#{fun}_count"))(Faker.locale)))
end
defp unquote(binary_to_atom("#{fun}_count"))(unquote(binary_to_atom(lang))) do
defp unquote(String.to_atom("#{fun}_count"))(unquote(String.to_atom(lang))) do
unquote(Enum.count(list))
end
Enum.with_index(list) |> Enum.each fn({el, index}) ->
defp unquote(binary_to_atom("get_#{fun}"))(unquote(binary_to_atom(lang)), unquote(index)) do
defp unquote(String.to_atom("get_#{fun}"))(unquote(String.to_atom(lang)), unquote(index)) do
unquote(el)
end
end
end
{"functions", values} ->
Enum.each values, fn({fun, list}) ->
def unquote(binary_to_atom(fun))() do
unquote(binary_to_atom(fun))(Faker.locale, :crypto.rand_uniform(0, unquote(binary_to_atom("#{fun}_count"))(Faker.locale)))
def unquote(String.to_atom(fun))() do
unquote(String.to_atom(fun))(Faker.locale, :crypto.rand_uniform(0, unquote(String.to_atom("#{fun}_count"))(Faker.locale)))
end
Enum.with_index(list) |> Enum.each fn({el, index}) ->
defp unquote(binary_to_atom(fun))(unquote(binary_to_atom(lang)), unquote(index)) do
defp unquote(String.to_atom(fun))(unquote(String.to_atom(lang)), unquote(index)) do
unquote(Code.string_to_quoted!('"#{el}"'))
end
end
defp unquote(binary_to_atom("#{fun}_count"))(unquote(binary_to_atom(lang))) do
defp unquote(String.to_atom("#{fun}_count"))(unquote(String.to_atom(lang))) do
unquote(Enum.count(list))
end
end
Expand All @@ -43,14 +43,14 @@ defmodule Faker.Internet do

def ip_v6_address do
Enum.map_join 1..8, ":", fn(_part) ->
integer_to_binary(:crypto.rand_uniform(0, 65536), 16)
Integer.to_string(:crypto.rand_uniform(0, 65536), 16)
|> String.rjust(4, ?0)
end
end

def mac_address do
Enum.map_join(1..6, ":", fn(_part) ->
integer_to_binary(:crypto.rand_uniform(0, 256), 16)
Integer.to_string(:crypto.rand_uniform(0, 256), 16)
|> String.rjust(2, ?0)
end) |> String.downcase
end
Expand Down
4 changes: 2 additions & 2 deletions lib/faker/lorem.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ defmodule Faker.Lorem do
{:ok, json} = JSEX.decode(json, [{:labels, :binary}])
Enum.each json, fn({lang, functions}) ->
Enum.each functions, fn({fun, list}) ->
defp unquote(binary_to_atom("#{fun}_count"))(unquote(binary_to_atom(lang))) do
defp unquote(String.to_atom("#{fun}_count"))(unquote(String.to_atom(lang))) do
unquote(Enum.count(list))
end
Enum.each Enum.with_index(list), fn({el, index}) ->
defp unquote(binary_to_atom("get_#{fun}"))(unquote(binary_to_atom(lang)), unquote(index+1)) do
defp unquote(String.to_atom("get_#{fun}"))(unquote(String.to_atom(lang)), unquote(index+1)) do
unquote(el)
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/faker/name.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ defmodule Faker.Name do
{:ok, json} = JSEX.decode(json, [{:labels, :binary}])
Enum.each json, fn({lang, functions}) ->
Enum.each functions, fn({fun, list}) ->
defp unquote(binary_to_atom("#{fun}_count"))(unquote(binary_to_atom(lang))) do
defp unquote(String.to_atom("#{fun}_count"))(unquote(String.to_atom(lang))) do
unquote(Enum.count(list))
end
Enum.each Enum.with_index(list), fn({el, index}) ->
defp unquote(binary_to_atom("get_#{fun}"))(unquote(binary_to_atom(lang)), unquote(index+1)) do
defp unquote(String.to_atom("get_#{fun}"))(unquote(String.to_atom(lang)), unquote(index+1)) do
unquote(el)
end
end
Expand Down
16 changes: 8 additions & 8 deletions lib/faker/team.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ defmodule Faker.Team do
Enum.each data, fn
{"values", values} ->
Enum.each values, fn({fun, list}) ->
def unquote(binary_to_atom(fun))() do
unquote(binary_to_atom("get_#{fun}"))(Faker.locale, :crypto.rand_uniform(0, unquote(binary_to_atom("#{fun}_count"))(Faker.locale)))
def unquote(String.to_atom(fun))() do
unquote(String.to_atom("get_#{fun}"))(Faker.locale, :crypto.rand_uniform(0, unquote(String.to_atom("#{fun}_count"))(Faker.locale)))
end
defp unquote(binary_to_atom("#{fun}_count"))(unquote(binary_to_atom(lang))) do
defp unquote(String.to_atom("#{fun}_count"))(unquote(String.to_atom(lang))) do
unquote(Enum.count(list))
end
Enum.with_index(list) |> Enum.each fn({el, index}) ->
defp unquote(binary_to_atom("get_#{fun}"))(unquote(binary_to_atom(lang)), unquote(index)) do
defp unquote(String.to_atom("get_#{fun}"))(unquote(String.to_atom(lang)), unquote(index)) do
unquote(el)
end
end
end
{"functions", values} ->
Enum.each values, fn({fun, list}) ->
def unquote(binary_to_atom(fun))() do
unquote(binary_to_atom(fun))(Faker.locale, :crypto.rand_uniform(0, unquote(binary_to_atom("#{fun}_count"))(Faker.locale)))
def unquote(String.to_atom(fun))() do
unquote(String.to_atom(fun))(Faker.locale, :crypto.rand_uniform(0, unquote(String.to_atom("#{fun}_count"))(Faker.locale)))
end
Enum.with_index(list) |> Enum.each fn({el, index}) ->
defp unquote(binary_to_atom(fun))(unquote(binary_to_atom(lang)), unquote(index)) do
defp unquote(String.to_atom(fun))(unquote(String.to_atom(lang)), unquote(index)) do
unquote(Code.string_to_quoted!('"#{el}"'))
end
end
defp unquote(binary_to_atom("#{fun}_count"))(unquote(binary_to_atom(lang))) do
defp unquote(String.to_atom("#{fun}_count"))(unquote(String.to_atom(lang))) do
unquote(Enum.count(list))
end
end
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ defmodule Faker.Mixfile do

def project do
[ app: :faker,
version: "0.3.0",
elixir: ">= 0.14.0",
version: "0.3.1",
elixir: ">= 0.14.2",
description: "Faker is pure Elixir library for generating fake data.",
package: package,
deps: deps ]
Expand Down
2 changes: 1 addition & 1 deletion test/faker/address_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule AddressTest do

test "building_number/0" do
assert is_binary(Faker.Address.building_number)
assert size(Faker.Address.building_number) in 1..5
assert String.length(Faker.Address.building_number) in 1..5
end

test "city/0" do
Expand Down
8 changes: 4 additions & 4 deletions test/faker/code_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ defmodule CodeTest do

test "isbn/0" do
assert is_binary(Faker.Code.isbn)
assert size(Faker.Code.isbn) == 10
assert String.length(Faker.Code.isbn) == 10
end

test "isbn10/0" do
assert is_binary(Faker.Code.isbn10)
assert size(Faker.Code.isbn10) == 10
assert String.length(Faker.Code.isbn10) == 10
end

test "isbn13/0" do
assert is_binary(Faker.Code.isbn13)
assert size(Faker.Code.isbn13) == 13
assert String.length(Faker.Code.isbn13) == 13
end

test "issn/0" do
assert is_binary(Faker.Code.issn)
assert size(Faker.Code.issn) == 9
assert String.length(Faker.Code.issn) == 9
end
end

0 comments on commit e2b7179

Please sign in to comment.