Class: Backup::RemoveSpecified
- Inherits:
-
Object
- Object
- Backup::RemoveSpecified
- Includes:
- RemoveHeavyData, RemoveWithAllDependencies
- Defined in:
- lib/backup/remove_specified.rb,
lib/backup/remove_specified/shared.rb,
lib/backup/remove_specified/remove_heavy_data.rb,
lib/backup/remove_specified/remove_with_all_dependencies.rb
Defined Under Namespace
Modules: RemoveHeavyData, RemoveWithAllDependencies, Shared
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #dry_run_report ⇒ Object
-
#initialize(config, dry_run_reporter = nil) ⇒ RemoveSpecified
constructor
A new instance of RemoveSpecified.
- #process_all_repos ⇒ Object
- #process_organization(org_id) ⇒ Object
- #process_repo_with_id(repo_id) ⇒ Object
- #process_user(user_id) ⇒ Object
- #run(args = {}) ⇒ Object
Methods included from RemoveWithAllDependencies
#remove_org_with_dependencies, #remove_repo_with_dependencies, #remove_user_with_dependencies
Methods included from SaveNullifiedRelsToFile
#save_nullified_rels_to_file, #save_rels_batch_to_file
Methods included from SaveFile
#current_time_for_subfolder, #ensure_path, #folder_path, #full_file_path, #save_file
Methods included from SaveIdHashToFile
#get_exported_object, #save_id_hash_to_file, #save_ids_batch_to_file
Methods included from RemoveHeavyData
#remove_heavy_data_for_repo, #remove_heavy_data_for_repos_owned_by, #remove_repo_builds, #remove_repo_requests
Constructor Details
#initialize(config, dry_run_reporter = nil) ⇒ RemoveSpecified
Returns a new instance of RemoveSpecified.
13 14 15 16 |
# File 'lib/backup/remove_specified.rb', line 13 def initialize(config, dry_run_reporter=nil) @config = config @dry_run_reporter = dry_run_reporter end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/backup/remove_specified.rb', line 11 def config @config end |
Instance Method Details
#dry_run_report ⇒ Object
18 19 20 |
# File 'lib/backup/remove_specified.rb', line 18 def dry_run_report @dry_run_reporter.report end |
#process_all_repos ⇒ Object
62 63 64 65 66 |
# File 'lib/backup/remove_specified.rb', line 62 def process_all_repos Repository.order(:id).each do |repository| remove_heavy_data_for_repo(repository) end end |
#process_organization(org_id) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/backup/remove_specified.rb', line 46 def process_organization(org_id) if @config.threshold remove_heavy_data_for_repos_owned_by(org_id, 'Organization') else remove_org_with_dependencies(org_id) end end |
#process_repo_with_id(repo_id) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/backup/remove_specified.rb', line 54 def process_repo_with_id(repo_id) if @config.threshold remove_heavy_data_for_repo(Repository.find(repo_id)) else remove_repo_with_dependencies(repo_id) end end |
#process_user(user_id) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/backup/remove_specified.rb', line 38 def process_user(user_id) if @config.threshold remove_heavy_data_for_repos_owned_by(user_id, 'User') else remove_user_with_dependencies(user_id) end end |
#run(args = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/backup/remove_specified.rb', line 22 def run(args={}) user_id = args[:user_id] || @config.user_id repo_id = args[:repo_id] || @config.repo_id org_id = args[:org_id] || @config.org_id if user_id process_user(user_id) elsif org_id process_organization(org_id) elsif repo_id process_repo_with_id(repo_id) else process_all_repos end end |