Class: WpBackup::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/wp_backup/config.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Config

Returns a new instance of Config.



6
7
8
9
# File 'lib/wp_backup/config.rb', line 6

def initialize(file)
  @config = YAML.load_file(file)
  @bucket_name = @config['aws'].delete('bucket')
end

Class Method Details

.write_sample(file) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/wp_backup/config.rb', line 27

def self.write_sample(file)
  File.open(file, 'w') do |file|
    file.puts(<<-EOF
database:
  name:
  user:
  password:
wordpress:
  home:
  # this allows you to specify which directories to backup. if it's not
  # included or the list is empty the entire directory is backed up.
  backup_paths:
-
aws:
  access_key_id:
  secret_access_key:
  bucket:
      EOF
    )
  end
end

Instance Method Details

#databaseObject



15
16
17
18
19
20
21
# File 'lib/wp_backup/config.rb', line 15

def database
  Database.new(
    database_config['name'],
    database_config['user'],
    database_config['password']
  )
end

#s3Object



11
12
13
# File 'lib/wp_backup/config.rb', line 11

def s3
  S3.new(aws_config, @bucket_name)
end

#siteObject



23
24
25
# File 'lib/wp_backup/config.rb', line 23

def site
  Site.new(wordpress_config['home'], wordpress_config['backup_paths'])
end