Class: Fastlane::Helper::FilesystemHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::FilesystemHelper
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb
Class Method Summary collapse
-
.absolute_project_path(relative_path) ⇒ Object
Transforms a relative path within the project to an absolute path on disk.
-
.absolute_secret_store_path(relative_path) ⇒ Object
Transforms a relative path within the secret store to an absolute path on disk.
-
.configure_file ⇒ Object
Returns the path to the project's
.configurefile. -
.configure_files_dir ⇒ Object
Returns the path to the project's
.configure-filesdirectory. - .encrypted_file_path(file) ⇒ Object
-
.file_hash(absolute_path) ⇒ Object
Returns the
sha1hash of a file, given the absolute path. - .plugin_root ⇒ Object
-
.project_path ⇒ Object
Traverse the file system to find the root project directory.
-
.secret_store_dir ⇒ Object
Returns the path to the
~/.mobile-secretsdirectory. -
.secret_store_keys_path ⇒ Object
Path to keys.json in the secrets repository.
Class Method Details
.absolute_project_path(relative_path) ⇒ Object
Transforms a relative path within the project to an absolute path on disk.
85 86 87 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 85 def self.absolute_project_path(relative_path) File.join(project_path, relative_path) end |
.absolute_secret_store_path(relative_path) ⇒ Object
Transforms a relative path within the secret store to an absolute path on disk.
75 76 77 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 75 def self.absolute_secret_store_path(relative_path) File.join(secret_store_dir, relative_path) end |
.configure_file ⇒ Object
Returns the path to the project's .configure file.
56 57 58 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 56 def self.configure_file Pathname.new(project_path) + '.configure' end |
.configure_files_dir ⇒ Object
Returns the path to the project's .configure-files directory.
61 62 63 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 61 def self.configure_files_dir Pathname.new(project_path) + '.configure-files' end |
.encrypted_file_path(file) ⇒ Object
65 66 67 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 65 def self.encrypted_file_path(file) File.join(configure_files_dir, "#{File.basename(file)}.enc") end |
.file_hash(absolute_path) ⇒ Object
Returns the sha1 hash of a file, given the absolute path.
90 91 92 93 94 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 90 def self.file_hash(absolute_path) UI.user_error!("Unable to hash #{absolute_path} – the file does not exist") unless File.file?(absolute_path) Digest::SHA1.file absolute_path end |
.plugin_root ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 34 def self.plugin_root continue = true dir = Pathname.new(__FILE__).dirname while continue child_filenames = dir.children.map! { |x| File.basename(x) } # The first case is for development – where the `.gemspec` is present in the project root # The second case is for production – where there's no `.gemspec`, but the root dir of the plugin is named `fastlane-plugin-wpmreleasetoolkit-{version}`. if child_filenames.include?('fastlane-plugin-wpmreleasetoolkit.gemspec') || File.basename(dir).start_with?('fastlane-plugin-wpmreleasetoolkit-') continue = false else dir = dir.parent end UI.user_error!('Unable to determine the plugin root directory.') if dir.root? end dir end |
.project_path ⇒ Object
Traverse the file system to find the root project directory.
For the purposes of this function, we're assuming the root project
directory is the one with the .git file in it.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 15 def self.project_path continue = true dir = Pathname.new(Dir.pwd) while continue child_filenames = dir.children.map! { |x| File.basename(x) } if child_filenames.include? '.git' continue = false else dir = dir.parent end UI.user_error!("Unable to determine the project root directory – #{Dir.pwd} doesn't appear to reside within a git repository.") if dir.root? end dir end |
.secret_store_dir ⇒ Object
Returns the path to the ~/.mobile-secrets directory.
70 71 72 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 70 def self.secret_store_dir "#{Dir.home}/.mobile-secrets" end |
.secret_store_keys_path ⇒ Object
Path to keys.json in the secrets repository
80 81 82 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 80 def self.secret_store_keys_path File.join(secret_store_dir, 'keys.json') end |