Class: Fastlane::RamDisk::Manager
- Inherits:
-
Object
- Object
- Fastlane::RamDisk::Manager
- Defined in:
- lib/fastlane/plugin/ram_disk/manager.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(params) ⇒ Manager
constructor
A new instance of Manager.
- #mac? ⇒ Boolean
- #remove ⇒ Object
Constructor Details
Class Method Details
.run(params) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/fastlane/plugin/ram_disk/manager.rb', line 14 def self.run(params) instance = new(params) instance.create params[:use].call instance.remove end |
Instance Method Details
#create ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fastlane/plugin/ram_disk/manager.rb', line 26 def create name = @params[:name] path = @params[:mount_path] size = @params[:size] ram_disk_path = File.join(path, name) UI.user_error!('the name is empty') if name.to_s.empty? UI.user_error!('the disk size is zero or negative') if size.to_i <= 0 UI.user_error!("mount path existed: #{ram_disk_path}") if File.exist?(ram_disk_path) commands = [] commands << create_ram_disk(name, size) commands << spotlight_indexes(ram_disk_path, true) commands.each do |shell_command| if Helper.test? UI.("$ #{shell_command}") next end Actions.sh(shell_command) end UI.crash! "fail to create ram disk" unless Dir.exist?(ram_disk_path) UI.success "Successful on ram disk: #{ram_disk_path}" shared_value(Actions::SharedValues::RAM_DISK_PATH, ram_disk_path) end |
#mac? ⇒ Boolean
78 79 80 81 82 83 |
# File 'lib/fastlane/plugin/ram_disk/manager.rb', line 78 def mac? require 'rbconfig' platform = RbConfig::CONFIG['host_os'] platform.include?('darwin') end |
#remove ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fastlane/plugin/ram_disk/manager.rb', line 55 def remove path = @params[:path] UI.user_error!('ram path is empty') if path.to_s.empty? UI.user_error!("ram path is not exist: #{path}") unless Dir.exist?(path) UI.("Found ram disk: #{path}") commands = [] commands << spotlight_indexes(path, false) commands << remove_ram_disk(path) commands.each do |shell_command| if Helper.test? UI.("$ #{shell_command}") next end Actions.sh(shell_command) end UI.crash! "fail to remove ram disk" if Dir.exist?(path) end |