Class: Rack::GitUp
- Inherits:
-
Object
- Object
- Rack::GitUp
- Defined in:
- lib/rack-git-up.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ GitUp
constructor
A new instance of GitUp.
- #pull_from_git(path) ⇒ Object
Constructor Details
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rack-git-up.rb', line 15 def call(env) path = env["PATH_INFO"] can_serve = @urls.any? { |url| path.index(url) == 0 } if can_serve pull_from_git path result = @file_server.call(env) return result if result[0] == 200 end @app.call(env) end |
#pull_from_git(path) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/rack-git-up.rb', line 28 def pull_from_git path blob = (@repo.tree/path[1..-1]) #remove leading slash return unless blob f = ::File.new(::File.join(@root, path), "w") f.syswrite(blob.data) f.close end |