summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel E. Giddins <segiddins@segiddins.me>2015-07-22 17:32:37 -0700
committerSamuel E. Giddins <segiddins@segiddins.me>2015-07-22 17:32:37 -0700
commit36ca3f33919c86e98de0b47fd69f84cb8f94b9f1 (patch)
treeae2853954b2bc12045d5360fdf0c7c501279bbcf
parentc784ea3ade399fd487184493f7e8c0e340e7d6d7 (diff)
downloadbundler-36ca3f33919c86e98de0b47fd69f84cb8f94b9f1.tar.gz
Make the PermissionsError configurable by needed permission
-rw-r--r--lib/bundler.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 109cf287e6..c5cf1a11dd 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -86,14 +86,20 @@ module Bundler
class MarshalError < StandardError; end
class PermissionError < BundlerError
- def initialize(file)
+ def initialize(file, permission_type = :write)
@file = file
end
def message
- "There was an error while trying to write to `#{File.basename(@file)}`. It is likely that \n" \
- "you need to allow write permissions for the file at path: \n" \
- "#{File.expand_path(@file)}"
+ action = case permission_type
+ when :read then "read from"
+ when :write then "write to"
+ when :executable then "execute"
+ else permission_type.to_s
+ end
+ "There was an error while trying to #{action} `#{File.basename(@file)}`. " \
+ "It is likely that you need to grant #{permission_type} permissions for " \
+ "the file at path: `#{File.expand_path(@file)}`."
end
status_code(23)