From dade87fe48f6c01e4e324f7a3d1418a14468d95a Mon Sep 17 00:00:00 2001 From: Kyle Lin Date: Mon, 7 Mar 2022 11:44:45 +0800 Subject: [PATCH] suspend .swp, .swo --- .gitignore | 2 ++ vaker/attr.v | 24 +++++++++++------------- vaker/data_faker.v | 9 +++++++++ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index a639c67..9984f58 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ main *.dylib *.dll *.c +*.swp +*.swo vls.log diff --git a/vaker/attr.v b/vaker/attr.v index 3a11ee5..0dc8f6f 100644 --- a/vaker/attr.v +++ b/vaker/attr.v @@ -5,21 +5,19 @@ import arrays { binary_search } type Attribute = map[string][]string const ( - builtin_attrs = [ - 'amount', - 'amount_with_currency', - 'currency', - 'e164_phone_number', - 'lat', - 'long', - 'phone_number', - 'skip', + builtin_attrs = build_attrs() +) + +fn build_attrs() []string { + attr_funcs := default_df.attribute_functions.keys() + builtin_attrs := [ 'str_len', - 'toll_free_phone_number', - 'uuid_digit', - 'uuid_hyphenated', + 'skip', ] -) + attrs := arrays.concat(attr_funcs, builtin_attrs) + attrs.sort() + return attrs +} // Dummy struct for get_attrs struct Struct { diff --git a/vaker/data_faker.v b/vaker/data_faker.v index a6bddf1..c2b505d 100644 --- a/vaker/data_faker.v +++ b/vaker/data_faker.v @@ -24,14 +24,23 @@ mut: attribute_functions map[string]fn (PtrInfo) = { 'amount': amount 'amount_with_currency': amount_with_currency + 'century': century 'currency': currency + 'date': date + 'day_of_week': day_of_week 'e164_phone_number': e164_phone_number 'lat': latitude + 'timestamp': timestamp 'long': longitude + 'month': month + 'period': period 'phone_number': phone_number + 'timezone': timezone 'toll_free_phone_number': toll_free_phone_number + 'unix_time': unix_time 'uuid_digit': digit 'uuid_hyphenated': hyphenated + 'year': year } current_attribute_function &fn (PtrInfo) = voidptr(0) }