class Bundler::PermissionError

Public Class Methods

new(path, permission_type = :write) click to toggle source
# File bundler/errors.rb, line 64
def initialize(path, permission_type = :write)
  @path = path
  @permission_type = permission_type
end

Public Instance Methods

action() click to toggle source
# File bundler/errors.rb, line 69
def action
  case @permission_type
  when :read then "read from"
  when :write then "write to"
  when :executable, :exec then "execute"
  else @permission_type.to_s
  end
end
message() click to toggle source
# File bundler/errors.rb, line 95
def message
  "There was an error while trying to #{action} `#{@path}`. " \
  "It is likely that you need to grant #{permission_type}."
end
parent_folder() click to toggle source
# File bundler/errors.rb, line 91
def parent_folder
  File.dirname(@path)
end
permission_type() click to toggle source
# File bundler/errors.rb, line 78
def permission_type
  case @permission_type
  when :create
    "executable permissions for all parent directories and write permissions for `#{parent_folder}`"
  when :delete
    permissions = "executable permissions for all parent directories and write permissions for `#{parent_folder}`"
    permissions += ", and the same thing for all subdirectories inside #{@path}" if File.directory?(@path)
    permissions
  else
    "#{@permission_type} permissions for that path"
  end
end