Class: Match::Storage::Interface
- Inherits:
-
Object
- Object
- Match::Storage::Interface
- Defined in:
- match/lib/match/storage/interface.rb
Direct Known Subclasses
GitLabSecureFiles, GitStorage, GoogleCloudStorage, S3Storage
Constant Summary collapse
- MATCH_VERSION_FILE_NAME =
"match_version.txt"
Instance Attribute Summary collapse
-
#working_directory ⇒ Object
To make debugging easier, we have a custom exception here.
Instance Method Summary collapse
-
#clear_changes ⇒ Object
Call this method to reset any changes made locally to the files.
-
#configure ⇒ Object
Call this method after creating a new object to configure the given Storage object.
- #delete_files(files_to_delete: [], custom_message: nil) ⇒ Object
-
#download ⇒ Object
Call this method for the initial clone/download of the user’s certificates & profiles As part of this method, the ‘self.working_directory` attribute will be set.
-
#generate_matchfile_content(template: nil) ⇒ Object
Implement this for the ‘fastlane match init` command This method must return the content of the Matchfile that should be generated.
-
#human_readable_description ⇒ Object
Returns a short string describing + identifing the current storage backend.
- #list_files(file_name: "", file_ext: "") ⇒ Object
-
#prefixed_working_directory ⇒ Object
To make debugging easier, we have a custom exception here.
-
#save_changes!(files_to_commit: nil, files_to_delete: nil, custom_message: nil) ⇒ Object
Call this method after locally modifying the files This will commit the changes and push it back to the given remote server This method is blocking, meaning it might take multiple seconds or longer to run.
- #skip_docs ⇒ Object
- #upload_files(files_to_upload: [], custom_message: nil) ⇒ Object
Instance Attribute Details
#working_directory ⇒ Object
To make debugging easier, we have a custom exception here
9 10 11 |
# File 'match/lib/match/storage/interface.rb', line 9 def working_directory @working_directory end |
Instance Method Details
#clear_changes ⇒ Object
Call this method to reset any changes made locally to the files
111 112 113 114 115 116 |
# File 'match/lib/match/storage/interface.rb', line 111 def clear_changes return unless @working_directory FileUtils.rm_rf(self.working_directory) self.working_directory = nil end |
#configure ⇒ Object
Call this method after creating a new object to configure the given Storage object. This method will take different parameters depending on specific class being used
27 28 29 |
# File 'match/lib/match/storage/interface.rb', line 27 def configure not_implemented(__method__) end |
#delete_files(files_to_delete: [], custom_message: nil) ⇒ Object
91 92 93 |
# File 'match/lib/match/storage/interface.rb', line 91 def delete_files(files_to_delete: [], custom_message: nil) not_implemented(__method__) end |
#download ⇒ Object
Call this method for the initial clone/download of the user’s certificates & profiles As part of this method, the ‘self.working_directory` attribute will be set
35 36 37 |
# File 'match/lib/match/storage/interface.rb', line 35 def download not_implemented(__method__) end |
#generate_matchfile_content(template: nil) ⇒ Object
Implement this for the ‘fastlane match init` command This method must return the content of the Matchfile that should be generated
106 107 108 |
# File 'match/lib/match/storage/interface.rb', line 106 def generate_matchfile_content(template: nil) not_implemented(__method__) end |
#human_readable_description ⇒ Object
Returns a short string describing + identifing the current storage backend. This will be printed when nuking a storage
41 42 43 |
# File 'match/lib/match/storage/interface.rb', line 41 def human_readable_description not_implemented(__method__) end |
#list_files(file_name: "", file_ext: "") ⇒ Object
99 100 101 |
# File 'match/lib/match/storage/interface.rb', line 99 def list_files(file_name: "", file_ext: "") not_implemented(__method__) end |
#prefixed_working_directory ⇒ Object
To make debugging easier, we have a custom exception here
12 13 14 |
# File 'match/lib/match/storage/interface.rb', line 12 def prefixed_working_directory not_implemented(__method__) end |
#save_changes!(files_to_commit: nil, files_to_delete: nil, custom_message: nil) ⇒ Object
Call this method after locally modifying the files This will commit the changes and push it back to the given remote server This method is blocking, meaning it might take multiple seconds or longer to run
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'match/lib/match/storage/interface.rb', line 54 def save_changes!(files_to_commit: nil, files_to_delete: nil, custom_message: nil) # Custom init to `[]` in case `nil` is passed files_to_commit ||= [] files_to_delete ||= [] Dir.chdir(File.(self.working_directory)) do if files_to_commit.count > 0 # everything that isn't `match nuke` UI.user_error!("You can't provide both `files_to_delete` and `files_to_commit` right now") if files_to_delete.count > 0 if !File.exist?(MATCH_VERSION_FILE_NAME) || File.read(MATCH_VERSION_FILE_NAME) != Fastlane::VERSION.to_s files_to_commit << MATCH_VERSION_FILE_NAME File.write(MATCH_VERSION_FILE_NAME, Fastlane::VERSION) # stored unencrypted end template = File.read("#{Match::ROOT}/lib/assets/READMETemplate.md") readme_path = "README.md" if (!File.exist?(readme_path) || File.read(readme_path) != template) && !self.skip_docs files_to_commit << readme_path File.write(readme_path, template) end self.upload_files(files_to_upload: files_to_commit, custom_message: ) UI.("Finished uploading files to #{self.human_readable_description}") elsif files_to_delete.count > 0 self.delete_files(files_to_delete: files_to_delete, custom_message: ) UI.("Finished deleting files from #{self.human_readable_description}") else UI.user_error!("Neither `files_to_commit` nor `files_to_delete` were provided to the `save_changes!` method call") end end self.clear_changes end |
#skip_docs ⇒ Object
95 96 97 |
# File 'match/lib/match/storage/interface.rb', line 95 def skip_docs not_implemented(__method__) end |
#upload_files(files_to_upload: [], custom_message: nil) ⇒ Object
87 88 89 |
# File 'match/lib/match/storage/interface.rb', line 87 def upload_files(files_to_upload: [], custom_message: nil) not_implemented(__method__) end |