Module: DataGenerator::Gen

Defined in:
lib/howitzer/utils/data_generator/gen.rb

Defined Under Namespace

Classes: User

Class Method Summary collapse

Class Method Details

.delete_all_mailboxesObject

:nocov:


78
79
80
# File 'lib/howitzer/utils/data_generator/gen.rb', line 78

def delete_all_mailboxes
  warn "[WARN] Method '#{__method__}' has not been using anymore. You have to remove usage from here #{caller.first}"
end

.given_user_by_number(num) ⇒ Object

Gets User object by it's number

Parameters:

  • num - User number

Returns:

  • user - User object


49
50
51
52
53
54
55
56
# File 'lib/howitzer/utils/data_generator/gen.rb', line 49

def given_user_by_number(num)
  data = DataStorage.extract('user', num.to_i)
  unless data
    data = Gen::user
    DataStorage.store('user', num.to_i, data)
  end
  data
end

.serialString

Generates uniq string Returns:

  • string - Generated string

Returns:

  • (String)

    Generated string


67
68
69
70
# File 'lib/howitzer/utils/data_generator/gen.rb', line 67

def serial
  a = [('a'..'z').to_a, (0..9).to_a].flatten.shuffle
  "#{Time.now.utc.strftime("%j%H%M%S")}#{a[0..4].join}"
end

.user(params = {}) ⇒ Object


26
27
28
29
30
31
32
33
34
35
36
# File 'lib/howitzer/utils/data_generator/gen.rb', line 26

def user(params={})
  prefix = serial
  default = {
      email: gen_user_email(prefix),
      login: nil,
      first_name: gen_first_name(prefix),
      last_name: gen_last_name(prefix),
      password: settings.def_test_pass
  }
  User.new(default.merge(params))
end