Class: Runoff::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/runoff/location.rb

Overview

Contains class methods for finding out the appropriate file paths.

Examples

Location::default_skype_data_location skype_username
# => /home/user/.Skype/skype_username/main.db

Class Method Summary collapse

Class Method Details

.default_skype_data_location(skype_username) ⇒ Object

Public: Composes the default Skype database location depending on the operating system.

skype_username - A String that contains a username of the Skype account,

which database we want to access.

Examples

On Linux:
default_skype_data_location skype_username
# => /home/user/.Skype/skype_username/mai.db

On Windows:
default_skype_data_location skype_username
# =>  /Users/user/AppData/Roaming/Skype/skype_username/main.db

Returns a String that contains the path to the Skype database file.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/runoff/location.rb', line 50

def self.default_skype_data_location(skype_username)
  case RbConfig::CONFIG['host_os']
  when /mingw/
    if File.exist?("#{ENV['APPDATA']}\\Skype")
      format_windows_path "#{ENV['APPDATA']}\\Skype\\#{skype_username}\\main.db"
    else
      format_windows_path self.get_default_skype_data_location_on_windows_8(skype_username)
    end
  when /linux/
    "#{ENV['HOME']}/.Skype/#{skype_username}/main.db"
  else
    "#{ENV['HOME']}/Library/Application Support/Skype/#{skype_username}/main.db"
  end
end

.get_database_path(username, options) ⇒ Object

Public: Gets a path to the Skype’s main.db file.

username - A String containing Skype username options - A hash containing command-line options passed to the command.

If the username is empty, then the hash must contain :from key.

Examples

get_database_path('john_doe', {})
# => Path to the default Skype database location depending on the operating system.

get_database_path('', { from: '~/Desktop/main.db' })
# => '~/Desktop/main.db'

Returns a String



26
27
28
29
30
31
32
# File 'lib/runoff/location.rb', line 26

def self.get_database_path(username, options)
  if options.from
    options.from
  else
    self.default_skype_data_location username
  end
end

.get_export_path(options) ⇒ Object

Public: Composes a path where the exported files must be saved.

options - an object with command line options passed to the runoff executable.

Returns a string with a directory path.



70
71
72
73
74
75
76
77
78
79
# File 'lib/runoff/location.rb', line 70

def self.get_export_path(options)
  path = options.destination || "#{ENV['HOME']}"
  path = "#{path}/skype_chat_history"

  unless File.exist?(path)
    FileUtils::mkdir_p path
  end

  path
end