Module: ImapArchiver::Config

Included in:
Archiver
Defined in:
lib/imap_archiver/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#archive_folderObject

Returns the value of attribute archive_folder.



4
5
6
# File 'lib/imap_archiver/config.rb', line 4

def archive_folder
  @archive_folder
end

#archive_folder_aclObject

Returns the value of attribute archive_folder_acl.



4
5
6
# File 'lib/imap_archiver/config.rb', line 4

def archive_folder_acl
  @archive_folder_acl
end

#auth_mechObject

Returns the value of attribute auth_mech.



4
5
6
# File 'lib/imap_archiver/config.rb', line 4

def auth_mech
  @auth_mech
end

#base_folderObject

Returns the value of attribute base_folder.



4
5
6
# File 'lib/imap_archiver/config.rb', line 4

def base_folder
  @base_folder
end

#folders_to_archiveObject

Returns the value of attribute folders_to_archive.



4
5
6
# File 'lib/imap_archiver/config.rb', line 4

def folders_to_archive
  @folders_to_archive
end

#imap_serverObject

Returns the value of attribute imap_server.



4
5
6
# File 'lib/imap_archiver/config.rb', line 4

def imap_server
  @imap_server
end

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/imap_archiver/config.rb', line 4

def password
  @password
end

#usernameObject

Returns the value of attribute username.



4
5
6
# File 'lib/imap_archiver/config.rb', line 4

def username
  @username
end

Class Method Details

.included(base) ⇒ Object



27
28
29
# File 'lib/imap_archiver/config.rb', line 27

def self.included(base)
  base.extend(self)
end

.load_config(config_file) ⇒ Object

@@config_struct = ::OpenStruct.new(=> ”,

:username => '',
:password => '')


10
11
12
13
14
15
16
# File 'lib/imap_archiver/config.rb', line 10

def self.load_config(config_file)
  begin
    load config_file
  rescue LoadError => e
    raise "Config_file not found! #{config_file} #{e}"
  end
end

.method_missing(method, *args) ⇒ Object

private



42
43
44
# File 'lib/imap_archiver/config.rb', line 42

def self.method_missing(method, *args)
  @@base.send(method,*args)
end

.run {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



23
24
25
# File 'lib/imap_archiver/config.rb', line 23

def self.run
  yield self
end

Instance Method Details

#config_valid?Boolean

def method_missing(method, *args)

@@config_struct.send(method,*args)

end

Returns:

  • (Boolean)


35
36
37
38
39
40
# File 'lib/imap_archiver/config.rb', line 35

def config_valid?
  self.auth_mech ||= "CRAM-MD5"
  raise "No imap server in configuration file!" if self.imap_server.nil?
  raise "No username in configuration file!" if username.nil?
  raise "No password in configuration file!" if password.nil?
end

#load_config(config_file) ⇒ Object



18
19
20
21
# File 'lib/imap_archiver/config.rb', line 18

def load_config(config_file)
  @@base = self
  ImapArchiver::Config.load_config(config_file)
end