Class: S3gb::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/s3gb/base.rb

Direct Known Subclasses

JGit, S3fs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.



6
7
8
# File 'lib/s3gb/base.rb', line 6

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



5
6
7
# File 'lib/s3gb/base.rb', line 5

def config
  @config
end

Instance Method Details

#backupObject



10
11
12
13
14
15
# File 'lib/s3gb/base.rb', line 10

def backup
  prepare
  collect_files
  commit_changes
  push
end

#collect_filesObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/s3gb/base.rb', line 17

def collect_files
  with_exclude_file do |excludes|
    config['sync'].each do |path|
      puts "now comes #{path}"
      full_path = "#{cache_dir}#{File.dirname(path)}"
      ensure_dir full_path
      `rsync -avz --delete --exclude-from #{excludes} #{path} #{full_path}`
    end
  end
end

#commit_changesObject



28
29
30
31
# File 'lib/s3gb/base.rb', line 28

def commit_changes
  ensure_git_repo
  `cd #{cache_dir} && git add . && git add -u . && git commit -m "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}"`
end