forked from elixirs/faker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commerce.ex
129 lines (107 loc) · 2.83 KB
/
commerce.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
defmodule Faker.Commerce do
import Faker, only: [localize: 1]
@moduledoc """
Functions for generating commerce related data
"""
@doc """
Returns a random color
## Examples
iex> Faker.Commerce.color()
"red"
iex> Faker.Commerce.color()
"sky blue"
iex> Faker.Commerce.color()
"lavender"
iex> Faker.Commerce.color()
"grey"
"""
@spec color() :: String.t()
localize(:color)
@doc """
Returns a random department
## Examples
iex> Faker.Commerce.department()
"Home, Garden & Tools"
iex> Faker.Commerce.department()
"Electronics & Computers"
iex> Faker.Commerce.department()
"Clothing, Shoes & Jewelery"
iex> Faker.Commerce.department()
"Toys, Kids & Baby"
"""
@spec department() :: String.t()
localize(:department)
@doc """
Returns a random number that represents a price
## Examples
iex> Faker.Commerce.price()
1.11
iex> Faker.Commerce.price()
4.02
iex> Faker.Commerce.price()
8.36
iex> Faker.Commerce.price()
3.05
"""
@spec price() :: float
def price do
Faker.random_between(1, 1000) / 100.0
end
@doc """
Returns a complete product name, based on product adjectives, product
materials, product names
## Examples
iex> Faker.Commerce.product_name()
"Ergonomic Steel Shirt"
iex> Faker.Commerce.product_name()
"Fantastic Car"
iex> Faker.Commerce.product_name()
"Granite Gloves"
iex> Faker.Commerce.product_name()
"Plastic Shoes"
"""
@spec product_name() :: String.t()
localize(:product_name)
@doc """
Returns a random adjective for a product
## Examples
iex> Faker.Commerce.product_name_adjective()
"Small"
iex> Faker.Commerce.product_name_adjective()
"Ergonomic"
iex> Faker.Commerce.product_name_adjective()
"Incredible"
iex> Faker.Commerce.product_name_adjective()
"Gorgeous"
"""
@spec product_name_adjective() :: String.t()
localize(:product_name_adjective)
@doc """
Returns a random product material
## Examples
iex> Faker.Commerce.product_name_material()
"Rubber"
iex> Faker.Commerce.product_name_material()
"Concrete"
iex> Faker.Commerce.product_name_material()
"Steel"
iex> Faker.Commerce.product_name_material()
"Granite"
"""
@spec product_name_material() :: String.t()
localize(:product_name_material)
@doc """
Returns a random product name
## Examples
iex> Faker.Commerce.product_name_product()
"Gloves"
iex> Faker.Commerce.product_name_product()
"Computer"
iex> Faker.Commerce.product_name_product()
"Table"
iex> Faker.Commerce.product_name_product()
"Shirt"
"""
@spec product_name_product() :: String.t()
localize(:product_name_product)
end