Class: Wordnik::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Defaults go in here..



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/wordnik/configuration.rb', line 37

def initialize
  @response_format = 'json'
  @scheme = 'http'
  @host = 'api.wordnik.com'
  @hosts = []
  @load_balancer = nil
  @base_path = '/v4'
  @user_agent = "ruby-#{Wordnik::VERSION}"
  # Build the default set of resource names from the filenames of the API documentation
  begin
    api_docs_path = File.join(File.dirname(__FILE__), "../../api_docs")
    @resource_names = `find #{api_docs_path} -name '*.json'`.split("\n").map {|f| f.split("/").last.sub('.json', '') }.sort
    true
  rescue
    raise "Problem loading the resource files in ./api_docs/"
  end
end

Instance Attribute Details

#api_keyObject

Wordnik credentials



7
8
9
# File 'lib/wordnik/configuration.rb', line 7

def api_key
  @api_key
end

#auth_tokenObject

TODO: Steal all the auth stuff from the old gem!



12
13
14
# File 'lib/wordnik/configuration.rb', line 12

def auth_token
  @auth_token
end

#base_pathObject

Returns the value of attribute base_path.



26
27
28
# File 'lib/wordnik/configuration.rb', line 26

def base_path
  @base_path
end

#hostObject

Returns the value of attribute host.



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

def host
  @host
end

#hostsObject

to do in process load balancing



24
25
26
# File 'lib/wordnik/configuration.rb', line 24

def hosts
  @hosts
end

#load_balancerObject

Returns the value of attribute load_balancer.



25
26
27
# File 'lib/wordnik/configuration.rb', line 25

def load_balancer
  @load_balancer
end

#loggerObject

Returns the value of attribute logger.



34
35
36
# File 'lib/wordnik/configuration.rb', line 34

def logger
  @logger
end

#passwordObject

Returns the value of attribute password.



9
10
11
# File 'lib/wordnik/configuration.rb', line 9

def password
  @password
end

#proxyObject

Returns the value of attribute proxy.



30
31
32
# File 'lib/wordnik/configuration.rb', line 30

def proxy
  @proxy
end

#proxy_passwordObject

Returns the value of attribute proxy_password.



32
33
34
# File 'lib/wordnik/configuration.rb', line 32

def proxy_password
  @proxy_password
end

#proxy_usernameObject

Returns the value of attribute proxy_username.



31
32
33
# File 'lib/wordnik/configuration.rb', line 31

def proxy_username
  @proxy_username
end

#resource_namesObject

A comma-delimited list of the API’s resources



19
20
21
# File 'lib/wordnik/configuration.rb', line 19

def resource_names
  @resource_names
end

#response_formatObject

Response format can be ‘json’ (default) or ‘xml’



16
17
18
# File 'lib/wordnik/configuration.rb', line 16

def response_format
  @response_format
end

#schemeObject

The URL of the API server



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

def scheme
  @scheme
end

#user_agentObject

Returns the value of attribute user_agent.



28
29
30
# File 'lib/wordnik/configuration.rb', line 28

def user_agent
  @user_agent
end

#user_idObject

Returns the value of attribute user_id.



13
14
15
# File 'lib/wordnik/configuration.rb', line 13

def user_id
  @user_id
end

#usernameObject

Returns the value of attribute username.



8
9
10
# File 'lib/wordnik/configuration.rb', line 8

def username
  @username
end

Instance Method Details

#base_urlObject



55
56
57
58
59
60
61
# File 'lib/wordnik/configuration.rb', line 55

def base_url
  Addressable::URI.new(
    :scheme => self.scheme,
    :host => self.host,
    :path => self.base_path
  )
end

#clearObject



63
64
65
# File 'lib/wordnik/configuration.rb', line 63

def clear
  initialize
end