Sha256: 3ac737be97b0f4b5167bc28ab1f58ee0de5d296b20f9376912f039645ce0a6b6

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

module SurveyGizmo
  class << self
    attr_writer :configuration

    def configuration
      fail 'Not configured!' unless @configuration
      @configuration
    end

    def configure
      reset!
      yield(@configuration) if block_given?
    end

    def reset!
      @configuration = Configuration.new
      Connection.reset!
    end
  end

  class Configuration
    DEFAULT_REST_API_URL = 'https://restapi.surveygizmo.com'
    DEFAULT_API_VERSION = 'v4'
    DEFAULT_RESULTS_PER_PAGE = 50
    DEFAULT_TIMEOUT_SECONDS = 300
    DEFAULT_RETRIES = 3
    DEFAULT_RETRY_INTERVAL = 60

    attr_accessor :api_token
    attr_accessor :api_token_secret

    attr_accessor :api_debug
    attr_accessor :api_url
    attr_accessor :api_version
    attr_accessor :logger
    attr_accessor :results_per_page

    attr_accessor :timeout_seconds
    attr_accessor :retry_attempts
    attr_accessor :retry_interval


    def initialize
      @api_token = ENV['SURVEYGIZMO_API_TOKEN'] || nil
      @api_token_secret = ENV['SURVEYGIZMO_API_TOKEN_SECRET'] || nil

      @api_url = DEFAULT_REST_API_URL
      @api_version = DEFAULT_API_VERSION
      @results_per_page = DEFAULT_RESULTS_PER_PAGE

      @timeout_seconds = DEFAULT_TIMEOUT_SECONDS
      @retry_attempts = DEFAULT_RETRIES
      @retry_interval = DEFAULT_RETRY_INTERVAL

      @logger = SurveyGizmo::Logger.new(STDOUT)
      @api_debug = ENV['GIZMO_DEBUG'].to_s =~ /^(true|t|yes|y|1)$/i
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
survey-gizmo-ruby-6.1.0 lib/survey_gizmo/configuration.rb
survey-gizmo-ruby-6.0.3 lib/survey_gizmo/configuration.rb