module Citrus
  module Web
    class GithubPushResource < Resource

      def allowed_methods
        %w(POST)
      end

      def process_post
        _, data = URI.decode_www_form(request.body.to_s).first
        queue.push(create_build_service.create_from_github_push(data))
        true
      end

      def resource_exists?
        true
      end

      def create_build_service
        Citrus::Core::CreateBuildService.new
      end

    end
  end
end

module Citrus
  module Web
    class GithubPushResource < Resource

      def allowed_methods
        %w(POST)
      end

      def process_post
        _, data = URI.decode_www_form(request.body.to_s).first
        changeset = github_adapter.create_changeset_from_push_data(data)
        build = Core::Build.new(changeset)
        queue.push(build)
        true
      end

      def resource_exists?
        true
      end

      def github_adapter
        Core::GithubAdapter.new
      end

    end
  end
end

Revert "Use recently introduced CreateBuildService."
Revert "Use recently introduced CreateBuildService."

This reverts commit 7d2a4f3f867e5c323a4bbddfc3b9c209b4ad9cba.
