Class: Export

Inherits:
Thor
  • Object
show all
Includes:
FileHandler, MwGateway
Defined in:
lib/mediawiki_cli/export.rb

Instance Method Summary collapse

Instance Method Details

#batchObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mediawiki_cli/export.rb', line 15

def batch
  pages = []

  # TODO combine options
  export ||= to_hash(options.file) if options.file
  export ||= options

  export.each { |key, value|
    case key
      when "categories", "namespaces"
        pages.push invoke "mw:list:members", [],  :categories => export["categories"],
                                      :namespaces => export["namespaces"],
                                      :wiki => parent_options.wiki,
                                      :username => parent_options.username,
                                      :password => parent_options.password,
                                      :file => parent_options.file
      when "pages"
        pages.push export["pages"]
    end
  }
  return output $mw.export(pages.flatten)
end

#exportObject



40
41
42
43
44
# File 'lib/mediawiki_cli/export.rb', line 40

def export
  create_gateway
  opts = (STDIN.tty?) ? options.pages : $stdin.read.split("\n")
  return output $mw.export(opts)
end