Sha256: 83dc7c5aaa758431eee8a08afb04cb4e550b58073a15ebfa86f57413c4afee93

Contents?: true

Size: 1.05 KB

Versions: 25

Compression:

Stored size: 1.05 KB

Contents

require 'rest-client'
require 'multi_json'
module DashingContrib
  module Kue
    class Client
      attr_reader :endpoint

      # Creates a new Kue Client
      # Arguments:
      # endpoint :: endpoint of Kue web interface
      #
      def initialize(options = {})
        @endpoint = options[:endpoint]
      end

      # Returns a stats summary of Kue status in following format
      #
      # Tries to transform from camalCase JSON key to ruby
      # friendly symbal underscore format
      #
      #    {
      #      :inactive_count: 235,
      #      :complete_count: 29426,
      #      :active_count: 4,
      #      :failed_count: 11,
      #      :delayed_count: 0,
      #      :work_time: 778205330
      #    }
      #
      def stats
        payload = {}
        get_request('stats').each do |key, value|
          payload[:"#{key.underscore}"] = value
        end
        payload
      end

      private
      def get_request(uri)
        response = RestClient.get("#{endpoint}/#{uri}")
        MultiJson.load(response.body)
      end

    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
dashing-contrib-0.2.9 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.2.8 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.2.7 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.2.6 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.2.5 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.2.4 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.2.3 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.2.2 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.2.1 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.2.0 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.1.14 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.1.12 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.1.11 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.1.10 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.1.9 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.1.8 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.1.7 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.1.6 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.1.5 lib/dashing-contrib/bottles/kue/client.rb
dashing-contrib-0.1.4 lib/dashing-contrib/bottles/kue/client.rb