Class: Phpmyadmin::Backup

Inherits:
Object
  • Object
show all
Defined in:
lib/phpmyadmin/backup.rb,
lib/phpmyadmin/backup/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, username, password) ⇒ Backup

Returns a new instance of Backup.



9
10
11
12
13
14
# File 'lib/phpmyadmin/backup.rb', line 9

def initialize(host, username, password)
  @host = host
  @agent = create_agent
  @last_page = nil
  (username, password)
end

Instance Attribute Details

#agentObject (readonly)

Returns the value of attribute agent.



7
8
9
# File 'lib/phpmyadmin/backup.rb', line 7

def agent
  @agent
end

#last_pageObject (readonly)

Returns the value of attribute last_page.



7
8
9
# File 'lib/phpmyadmin/backup.rb', line 7

def last_page
  @last_page
end

Instance Method Details

#export(database_names = []) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/phpmyadmin/backup.rb', line 16

def export(database_names=[])
  export_url = last_page.search("#li_export a").first['href']

  get export_url do |page|
    dump_form = page.form_with :name => 'dump'
    if database_names.empty?
      database_names = dump_form.field_with(:name => 'db_select[]').options
    end
    database_names.each do |database_name|
      filename = export_single(export_url, database_name)
      yield filename if block_given?
    end
  end
end