Sha256: 721f464e6efad1edb6ff83b0dbe429d68433753559c152dc89d5474f08b66466

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

# encoding: utf-8
module Mutx
  module Routes
    module Api
      module Git
        class Routes < App
          define do

            on get do
              on "pull" do
                result = Mutx::Database::MongoConnector.last_commit_webhook
                result_parsed = result["log"]["commits"].join.gsub('=>', ':')
                last = JSON.parse result_parsed #hash

                result = Mutx::Database::MongoConnector.before_last_commit_webhook
                result_parsed = result["log"]["commits"].join.gsub('=>', ':')
                before_last = JSON.parse result_parsed #hash
                
                output = {:last_commit => last, :before_last_commit => before_last}
                res.write output.to_json
              end
            end

            on post do
              on "pull" do
                #Check for updates on the branch and make a pull if its outdated
                ##Mutx::Support::Git.pull unless Mutx::Support::Git.up_to_date?
                data_json = JSON.parse req.body.read
                Mutx::Support::ChangeInspector.is_there_a_change? data_json
                Mutx::Support::Log.debug "#{data_json}" if Mutx::Support::Log
                Mutx::Support::Bundle.new.bundle_update if data_json["repository"]["language"].eql? "Ruby"
                res.status = 200
                res.write "status 200"
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mutx-0.2.8 lib/mutx/routes/api_routes/git_routes.rb