diff options
author | Robert Speicher <rspeicher@gmail.com> | 2012-09-20 13:55:14 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2012-09-26 16:32:22 -0400 |
commit | a1e68a91205186287f21fb5fd1669acebcd7e79e (patch) | |
tree | 2c21dc00900ad12fd6376fc6a119c5e5e3d7caf6 /lib | |
parent | a8ea8d98a4f88a292289ddfedef4358033b68ec0 (diff) | |
download | gitlab-ce-a1e68a91205186287f21fb5fd1669acebcd7e79e.tar.gz |
Rename RefExtractor to ExtractsPath
Update docs a bit
Diffstat (limited to 'lib')
-rw-r--r-- | lib/extracts_path.rb (renamed from lib/ref_extractor.rb) | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/ref_extractor.rb b/lib/extracts_path.rb index 1db74b9513e..6648ffdc9a3 100644 --- a/lib/ref_extractor.rb +++ b/lib/extracts_path.rb @@ -1,14 +1,22 @@ -# Module providing an extract_ref method for controllers working with Git -# tree-ish + path params -module RefExtractor - # Raised when given an invalid path +# Module providing methods for dealing with separating a tree-ish string and a +# file path string when combined in a request parameter +module ExtractsPath + extend ActiveSupport::Concern + + # Raised when given an invalid file path class InvalidPathError < StandardError; end - # Given a string containing both a Git ref - such as a branch or tag - and a - # filesystem path joined by forward slashes, attempts to separate the two. + included do + if respond_to?(:before_filter) + before_filter :assign_ref_vars + end + end + + # Given a string containing both a Git tree-ish, such as a branch or tag, and + # a filesystem path joined by forward slashes, attempts to separate the two. # - # Expects a @project instance variable to contain the active project. Used to - # check the input against a list of valid repository refs. + # Expects a @project instance variable to contain the active project. This is + # used to check the input against a list of valid repository refs. # # Examples # @@ -78,8 +86,11 @@ module RefExtractor # - @commit - A CommitDecorator representing the commit from the given ref # - @tree - A TreeDecorator representing the tree at the given ref/path # - # Automatically renders `not_found!` if a valid tree could not be resolved - # (e.g., when a user inserts an invalid path or ref). + # If the :id parameter appears to be requesting a specific response format, + # that will be handled as well. + # + # Automatically renders `not_found!` if a valid tree path could not be + # resolved (e.g., when a user inserts an invalid path or ref). def assign_ref_vars # Handle formats embedded in the id if params[:id].ends_with?('.atom') |