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("database:\n  name:\n  user:\n  password:\nwordpress:\n  home:\n  # this allows you to specify which directories to backup. if it's not\n  # included or the list is empty the entire directory is backed up.\n  backup_paths:\n-\naws:\n  access_key_id:\n  secret_access_key:\n  bucket:\n      EOF\n    )\n  end\nend\n"

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