Exception: Bundler::PermissionError

Inherits:
BundlerError
  • Object
show all
Defined in:
lib/bundler/errors.rb

Instance Method Summary collapse

Methods inherited from BundlerError

all_errors, status_code

Constructor Details

#initialize(path, permission_type = :write) ⇒ PermissionError

Returns a new instance of PermissionError.



95
96
97
98
# File 'lib/bundler/errors.rb', line 95

def initialize(path, permission_type = :write)
  @path = path
  @permission_type = permission_type
end

Instance Method Details

#actionObject



100
101
102
103
104
105
106
107
# File 'lib/bundler/errors.rb', line 100

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

#messageObject



122
123
124
125
# File 'lib/bundler/errors.rb', line 122

def message
  "There was an error while trying to #{action} `#{@path}`. " \
  "It is likely that you need to grant #{permission_type}."
end

#parent_folderObject



118
119
120
# File 'lib/bundler/errors.rb', line 118

def parent_folder
  File.dirname(@path)
end

#permission_typeObject



109
110
111
112
113
114
115
116
# File 'lib/bundler/errors.rb', line 109

def permission_type
  case @permission_type
  when :create
    "executable permissions for all parent directories and write permissions for `#{parent_folder}`"
  else
    "#{@permission_type} permissions for that path"
  end
end