Sha256: e429203867fbdf90a03db98c61de1b08c2a966360e39dbcf0d5b8cc65a932718

Contents?: true

Size: 600 Bytes

Versions: 4

Compression:

Stored size: 600 Bytes

Contents

module Headsail
  class API
    attr_reader :name, :timer, :method, :uri, :oauth

    def initialize(config)
      @name = config['name']
      @timer = config['timer'].to_i
      @oauth = config['oauth']
      @method = config['request']['method']
      @uri = build_uri(config['request'])
    rescue
      Headsail.err('Improper API YAML format.')
      exit 1
    end

    private

    def build_uri(request)
      return false if request.nil?
      uri_full = URI(request['uri'])
      uri_full.query = URI.encode_www_form(request['params']) if request['params']
      uri_full
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
headsail-0.1.15 lib/headsail/api.rb
headsail-0.1.14 lib/headsail/api.rb
headsail-0.1.13 lib/headsail/api.rb
headsail-0.1.12 lib/headsail/api.rb