Class: Ravelry::Configuration

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

Overview

Adds global configuration settings to the gem, including:

  • ‘config.access_key` - your Ravelry access key

  • ‘config.secret_key` - your Ravelry secret key

  • ‘config.personal_key` - your Ravelry personal key; primarily used for OAuth

  • ‘config.callback_url` - for OAuth, the callback url for your authentication requests

To request API keys for Ravelry, sign up for a free Ravelry account and visit this page for instructions: www.ravelry.com/discuss/ravelry-api/topics/1979523#1

# Required fields

The following fields are required to use the gem:

  • Access key

  • Secret key

  • Personal key

The gem will raise a ‘Errors::Configuration` if you fail to provide these keys.

# Configuring your gem

“‘ Ravelry.configure do |config|

config.access_key = ''
config.secret_key = ''
config.personal_key = ''
config.callback_url = ''

end “‘

# Accessing configuration settings

All settings are available on the ‘Ravelry.configuration` object:

“‘ Ravelry.configuration.access_key Ravelry.configuration.secret_key Ravelry.configuration.personal_key Ravelry.configuration.callback_url “` # Resetting configuration

To reset, simply call ‘Ravelry.reset`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



51
52
53
54
55
56
# File 'lib/ravelry/configuration.rb', line 51

def initialize
  @access_key = nil
  @secret_key = nil
  @personal_key = nil
  @callback_url = nil
end

Instance Attribute Details

#access_keyObject



58
59
60
61
# File 'lib/ravelry/configuration.rb', line 58

def access_key
  raise Errors::Configuration, "Ravelry access key missing! See the documentation for configuration settings." unless @access_key
  @access_key
end

#callback_urlObject



73
74
75
76
# File 'lib/ravelry/configuration.rb', line 73

def callback_url
  raise Errors::Configuration, "Oauth callback url missing! See the documentation for configuration settings." unless @callback_url
  @callback_url
end

#personal_keyObject



68
69
70
71
# File 'lib/ravelry/configuration.rb', line 68

def personal_key
  raise Errors::Configuration, "Ravelry personal key missing! See the documentation for configuration settings." unless @personal_key
  @personal_key
end

#secret_keyObject



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

def secret_key
  raise Errors::Configuration, "Ravelry secret key missing! See the documentation for configuration settings." unless @secret_key
  @secret_key
end