Class: VagrantPlugins::OVirtProvider::Action::SetNameOfDomain

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-ovirt4/action/set_name_of_domain.rb

Constant Summary collapse

@@MAX_NAME_LENGTH =
64

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ SetNameOfDomain

Returns a new instance of SetNameOfDomain.



7
8
9
# File 'lib/vagrant-ovirt4/action/set_name_of_domain.rb', line 7

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/vagrant-ovirt4/action/set_name_of_domain.rb', line 11

def call(env)
  dir_name = env[:root_path].basename.to_s.dup.gsub(/[^-a-z0-9_]/i, "")
  timestamp = "_#{Time.now.to_f}"
  max_dir_name_length = dir_name.length-[(dir_name + timestamp).length-(@@MAX_NAME_LENGTH-1), 0].max
  env[:domain_name] = dir_name[0..max_dir_name_length] << timestamp

  @app.call(env)
end