Class: Georeferencer::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/georeferencer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



25
26
27
28
29
30
31
32
33
# File 'lib/georeferencer.rb', line 25

def initialize
  @connection ||= Her::API.new
  @ssl_options = {}
  @proxy = nil
  @user_agent = "Georeferencer Ruby Client #{Georeferencer::VERSION} (https://github.com/layersoflondon/georeferencer-ruby)"
  @cache = ActiveSupport::Cache.lookup_store(:memory_store)
  @perform_caching = false
  @logger = Logger.new(STDOUT)
end

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



22
23
24
# File 'lib/georeferencer.rb', line 22

def cache
  @cache
end

#connectionObject (readonly)

Returns the value of attribute connection.



23
24
25
# File 'lib/georeferencer.rb', line 23

def connection
  @connection
end

#loggerObject

Returns the value of attribute logger.



22
23
24
# File 'lib/georeferencer.rb', line 22

def logger
  @logger
end

#perform_cachingObject

Returns the value of attribute perform_caching.



22
23
24
# File 'lib/georeferencer.rb', line 22

def perform_caching
  @perform_caching
end

#proxyObject

Returns the value of attribute proxy.



22
23
24
# File 'lib/georeferencer.rb', line 22

def proxy
  @proxy
end

#ssl_optionsObject

Returns the value of attribute ssl_options.



22
23
24
# File 'lib/georeferencer.rb', line 22

def ssl_options
  @ssl_options
end

#subdomainObject

Returns the value of attribute subdomain.



22
23
24
# File 'lib/georeferencer.rb', line 22

def subdomain
  @subdomain
end

#user_agentObject

Returns the value of attribute user_agent.



22
23
24
# File 'lib/georeferencer.rb', line 22

def user_agent
  @user_agent
end

Instance Method Details

#configure_connectionObject

Raises:

  • (ArgumentError)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/georeferencer.rb', line 35

def configure_connection
  raise ArgumentError, "you need to specify a georeferencer subdomain" unless @subdomain.present?
  @connection.setup url: "https://#{@subdomain}.georeferencer.com/#{Georeferencer::API_PATH}", ssl: @ssl_options, proxy: @proxy do |c|

    # Request
    c.use Georeferencer::Headers
    
    c.use Faraday::Request::UrlEncoded

    # Response
    c.use Georeferencer::Parser

    # Adapter
    c.use Faraday::Adapter::NetHttp
  end
end