Class: S3gb::Base
- Inherits:
-
Object
- Object
- S3gb::Base
- Defined in:
- lib/s3gb/base.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #backup ⇒ Object
- #collect_files ⇒ Object
- #commit_changes ⇒ Object
-
#initialize(config) ⇒ Base
constructor
A new instance of Base.
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
#config ⇒ Object
Returns the value of attribute config.
5 6 7 |
# File 'lib/s3gb/base.rb', line 5 def config @config end |
Instance Method Details
#backup ⇒ Object
10 11 12 13 14 15 |
# File 'lib/s3gb/base.rb', line 10 def backup prepare collect_files commit_changes push end |
#collect_files ⇒ Object
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_changes ⇒ Object
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 |