Class: DitzStr::Config

Inherits:
ModelObject show all
Defined in:
lib/ditzstr/model-objects.rb

Instance Method Summary collapse

Methods inherited from ModelObject

#changed!, #changed?, changes_are_logged, create, create_interactively, #deserialized_form_of, #each_modelobject, field, field_names, from, inherited, #initialize, #inspect, #log, #save!, #serialized_form_of, #to_s, #to_yaml, #to_yaml_type, #unchanged!, yaml_domain, yaml_other_thing

Constructor Details

This class inherits a constructor from DitzStr::ModelObject

Instance Method Details

#get_default_emailObject



335
336
337
338
339
340
341
342
343
# File 'lib/ditzstr/model-objects.rb', line 335

def get_default_email
  require 'socket'
  email = (ENV["USER"] || "") + "@" +
    begin
      Socket.gethostbyname(Socket.gethostname).first
    rescue SocketError
      Socket.gethostname
    end
end

#get_default_nameObject



325
326
327
328
329
330
331
332
333
# File 'lib/ditzstr/model-objects.rb', line 325

def get_default_name
  require 'etc'

  name = if ENV["USER"]
    pwent = Etc.getpwnam ENV["USER"]
    pwent ? pwent.gecos.split(/,/).first : nil
  end
  name || "Ditz User"
end

#userObject



323
# File 'lib/ditzstr/model-objects.rb', line 323

def user; "#{name} <#{email}>" end