Class: WikiLogFile

Inherits:
Object
  • Object
show all
Defined in:
lib/Wiki2Go/WikiLogFile.rb

Class Method Summary collapse

Class Method Details

.blacklist(path, user) ⇒ Object



36
37
38
39
40
41
# File 'lib/Wiki2Go/WikiLogFile.rb', line 36

def WikiLogFile.blacklist(path,user)
  storage = Wiki2Go::FileStorage.new(path)
  list = storage.load_blacklist
  list.add(user)
  storage.save_list(list)
end

.restore(path, subwiki, filename, blacklist) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/Wiki2Go/WikiLogFile.rb', line 7

def WikiLogFile.restore(path,subwiki,filename,blacklist)
  if filename =~ /(.*)\.txt$/ then
    topic = $1
    storage = Wiki2Go::FileStorage.new(path)
    versions = storage.all_versions_of(subwiki,topic)
    first_good_version = versions.find do |v|
      #        puts "Checking #{v.author} against #{user}"
      true unless  blacklist.contains(v.author)
    end
    if first_good_version.nil? then
      puts "NO GOOD VERSION FOUND. Delete #{topic}!"
    elsif first_good_version.equal?(versions[0]) then
      #        puts "#{topic} is ok"
    else
      puts "#{topic} must be replaced by version by #{first_good_version.author}"
      storage.store_page(subwiki,first_good_version)
    end
  end
end

.restore_all_from(path, subwiki) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/Wiki2Go/WikiLogFile.rb', line 27

def WikiLogFile.restore_all_from(path,subwiki)
  storage = Wiki2Go::FileStorage.new(path)
  blacklist = storage.load_blacklist
  textpath = path + File::SEPARATOR + "texts" + File::SEPARATOR + subwiki
  Dir.foreach(textpath) do |filename|
    restore(path,subwiki,filename,blacklist)
  end
end