Module: LiveJournal::LogJam

Defined in:
lib/livejournal/logjam.rb

Overview

XXX this is currently not working due to database schema divergence

Class Method Summary collapse

Class Method Details

.current_serverObject

Name of LogJam’s current server.



45
46
47
# File 'lib/livejournal/logjam.rb', line 45

def self.current_server
  xml_fetch(logjam_path + '/conf.xml', '/configuration/currentserver')
end

.current_server_userObject

Return [current_server, current_user].



66
67
68
69
70
# File 'lib/livejournal/logjam.rb', line 66

def self.current_server_user
  server = current_server
  user = current_user server
  [server, user]
end

.current_user(servername) ⇒ Object

Username for a given server’s current user.



55
56
57
58
# File 'lib/livejournal/logjam.rb', line 55

def self.current_user servername
  xml_fetch(server_path(servername) + '/conf.xml',
            '/server/currentuser')
end

.database_from_server_user(servername, username) ⇒ Object



72
73
74
# File 'lib/livejournal/logjam.rb', line 72

def self.database_from_server_user servername, username
  Database.new(LogJam::user_path(servername, username) + "/journal.db")
end

.logjam_pathObject

Path to LogJam data.



34
35
36
# File 'lib/livejournal/logjam.rb', line 34

def self.logjam_path
  File.expand_path '~/.logjam'
end

.server_path(servername) ⇒ Object

Path to LogJam’s data for a given server.



50
51
52
# File 'lib/livejournal/logjam.rb', line 50

def self.server_path servername
  logjam_path + '/servers/' + servername  # is escaping needed here?
end

.user_path(servername, username) ⇒ Object

Path to a given user’s data.



61
62
63
# File 'lib/livejournal/logjam.rb', line 61

def self.user_path servername, username
  server_path(servername) + "/users/#{username}"
end

.xml_fetch(file, path) ⇒ Object

:nodoc:



38
39
40
41
42
# File 'lib/livejournal/logjam.rb', line 38

def self.xml_fetch(file, path)  #:nodoc:
  doc = REXML::Document.new(File.open(file))
  doc.elements.each(path) { |element| return element.text }
  return nil
end