Class: GithubSnapshot::Snapshot
- Inherits:
-
Object
- Object
- GithubSnapshot::Snapshot
- Defined in:
- lib/github_snapshot/snapshot.rb
Instance Attribute Summary collapse
-
#backup_folder ⇒ Object
readonly
Returns the value of attribute backup_folder.
-
#git_clone_cmd ⇒ Object
readonly
Returns the value of attribute git_clone_cmd.
-
#github ⇒ Object
readonly
Returns the value of attribute github.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#organizations ⇒ Object
readonly
Returns the value of attribute organizations.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#releases_to_keep ⇒ Object
readonly
Returns the value of attribute releases_to_keep.
-
#s3_bucket ⇒ Object
readonly
Returns the value of attribute s3_bucket.
-
#time_now ⇒ Object
readonly
Returns the value of attribute time_now.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #backup ⇒ Object
-
#initialize(config_file = "config.yml") ⇒ Snapshot
constructor
A new instance of Snapshot.
Constructor Details
#initialize(config_file = "config.yml") ⇒ Snapshot
Returns a new instance of Snapshot.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/github_snapshot/snapshot.rb', line 39 def initialize(config_file="config.yml") config = YAML.load(File.read(config_file)) @username = config['username'] @password = config['password'] @organizations = config['organizations'] @s3_bucket = config['s3bucket'] @backup_folder = config['backup_folder'] GithubSnapshot.releases_to_keep = config['releases_to_keep'] GithubSnapshot.git_clone_timeout = config['git_clone_timeout'] @github = Github.new do |config| config.login = username config.password = password config.auto_pagination = true end end |
Instance Attribute Details
#backup_folder ⇒ Object (readonly)
Returns the value of attribute backup_folder.
36 37 38 |
# File 'lib/github_snapshot/snapshot.rb', line 36 def backup_folder @backup_folder end |
#git_clone_cmd ⇒ Object (readonly)
Returns the value of attribute git_clone_cmd.
36 37 38 |
# File 'lib/github_snapshot/snapshot.rb', line 36 def git_clone_cmd @git_clone_cmd end |
#github ⇒ Object (readonly)
Returns the value of attribute github.
36 37 38 |
# File 'lib/github_snapshot/snapshot.rb', line 36 def github @github end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
36 37 38 |
# File 'lib/github_snapshot/snapshot.rb', line 36 def logger @logger end |
#organizations ⇒ Object (readonly)
Returns the value of attribute organizations.
36 37 38 |
# File 'lib/github_snapshot/snapshot.rb', line 36 def organizations @organizations end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
36 37 38 |
# File 'lib/github_snapshot/snapshot.rb', line 36 def password @password end |
#releases_to_keep ⇒ Object (readonly)
Returns the value of attribute releases_to_keep.
36 37 38 |
# File 'lib/github_snapshot/snapshot.rb', line 36 def releases_to_keep @releases_to_keep end |
#s3_bucket ⇒ Object (readonly)
Returns the value of attribute s3_bucket.
36 37 38 |
# File 'lib/github_snapshot/snapshot.rb', line 36 def s3_bucket @s3_bucket end |
#time_now ⇒ Object (readonly)
Returns the value of attribute time_now.
36 37 38 |
# File 'lib/github_snapshot/snapshot.rb', line 36 def time_now @time_now end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
36 37 38 |
# File 'lib/github_snapshot/snapshot.rb', line 36 def username @username end |
Instance Method Details
#backup ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/github_snapshot/snapshot.rb', line 57 def backup create_backup_folder download_from_s3 backup_orgs upload_to_s3 total_size = %x[ du -sh #{backup_folder} | cut -f1 ] GithubSnapshot.logger.info "backup finished, total size is #{total_size}" end |