Sha256: 3ee12bde39604bcdf85ac6aed89423a60ceb033278dec3808724db30cac2d711

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

require 'footrest/connection'
require 'footrest/request'
require 'active_support/configurable'

module Footrest
  class Client
    include Footrest::Connection
    include Footrest::Request
    include ActiveSupport::Configurable

    config_accessor :token
    config_accessor :prefix
    config_accessor :logging

    def initialize(options={}, &block)
      self.config.merge!(options)
      yield self if block_given?
      set_connection(config)
    end

    def connection(&block)
      @connection.tap do |conn|
        yield conn if block_given?
      end
    end

    def fullpath(path)
      prefix ? join(prefix, path) : path
    end

  protected
    def join(*parts)
      joined = parts.map{ |p| p.gsub(%r{^/|/$}, '') }.join('/')
      joined = '/' + joined if parts.first[0] == '/'
      joined
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
footrest-0.2.0 lib/footrest/client.rb