Module: Sinatra::AmpExtension
- Defined in:
- lib/amp/server/extension/amp_extension.rb
Overview
AmpExtension
This module adds a single DSL method to the sinatra base class: amp_repository. This method allows you to specify an HTTP path for an amp repo. You can call this method multiple times to specify multiple repositories for your server.
Constant Summary collapse
- ACCEPTABLE_COMMANDS =
All the commands we are capable of accepting
[ 'branches', 'heads', 'lookup', 'capabilities', 'between', 'changegroup', 'changegroupsubset', 'unbundle' ]
- READABLE_COMMANDS =
[ 'branches', 'heads', 'lookup', 'capabilities', 'between', 'changegroup', 'changegroupsubset' ]
Instance Method Summary collapse
- #amp_repositories ⇒ Object
-
#amp_repository(http_path, repo) ⇒ Object
This method will specify that the sinatra application should serve the repository
repo
using Mercurial’s HTTP(S) protocol athttp_path
.
Instance Method Details
#amp_repositories ⇒ Object
27 |
# File 'lib/amp/server/extension/amp_extension.rb', line 27 def amp_repositories; @@amp_repositories ||= {}; end |
#amp_repository(http_path, repo) ⇒ Object
This method will specify that the sinatra application should serve the repository repo
using Mercurial’s HTTP(S) protocol at http_path
. You can call this method multiple times for multiple repositories on different paths.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/amp/server/extension/amp_extension.rb', line 45 def amp_repository(http_path, repo) amp_repositories[http_path] = repo get http_path do if ACCEPTABLE_COMMANDS.include?(params[:cmd]) send("amp_get_#{params[:cmd]}".to_sym, repo) else pass end end end |