Sha256: b8a681e45f10218996730a13e9bd358d1e7b2a9a9c5ce90b82f03cb01ea92f55

Contents?: true

Size: 1.69 KB

Versions: 3

Compression:

Stored size: 1.69 KB

Contents

# encoding: utf-8
#--
#   Copyright (C) 2012-2013 Gitorious AS
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Affero General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Affero General Public License for more details.
#
#   You should have received a copy of the GNU Affero General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#++
require "json"
require "time"
require "cgi"
require "libdolt/controller_actions"

module Dolt
  module Sinatra
    class Actions
      def initialize(app, lookup, renderer)
        @app = app
        @dolt = Dolt::ControllerActions.new(app, lookup, renderer)
      end

      def resolve_repository(repo)
        dolt.resolve_repository(repo)
      end

      def lookup_ref_oid(repo, ref)
        dolt.lookup_ref_oid(repo, ref)
      end

      def respond_to?(method)
        dolt.respond_to?(method)
      end

      def method_missing(method, *args, &block)
        if dolt.respond_to?(method)
          return respond(dolt.send(method, *args, &block))
        end
        super
      end

      private
      attr_reader :app, :dolt

      def respond(response)
        app.response.status = response[0]
        response[1].keys.each do |header|
          app.response[header] = response[1][header]
        end
        app.body(response[2].join("\n"))
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dolt-0.30.0 ./lib/dolt/sinatra/actions.rb
dolt-0.29.0 ./lib/dolt/sinatra/actions.rb
dolt-0.28.1 ./lib/dolt/sinatra/actions.rb