Class: Jirafe::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/jirafe/configuration.rb

Constant Summary collapse

DEFAULT_URL =
"https://api.jirafe.com/v1"
DEFAULT_CALLBACK_URL =
"https://data.jirafe.com"
DEFAULT_ASSETS_URL =
"https://jirafe.com"
DEFAULT_TRACKING_URL =
"https://c.jirafe.com"
TEST_URL =
"https://test-api.jirafe.com/v1"
TEST_CALLBACK_URL =
"https://test-data.jirafe.com"
TEST_ASSETS_URL =
"https://test.jirafe.com"
TEST_TRACKING_URL =
"https://test-c.jirafe.com"
DEFAULT_CONTENT_TYPE =
"application/json"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



17
18
19
20
21
22
23
24
25
# File 'lib/jirafe/configuration.rb', line 17

def initialize
  @url = DEFAULT_URL
  @callback_url = DEFAULT_CALLBACK_URL
  @assets_url = DEFAULT_ASSETS_URL
  @tracking_url = DEFAULT_TRACKING_URL
  @content_type = DEFAULT_CONTENT_TYPE
  @token = nil
  @test = false
end

Instance Attribute Details

#assets_urlObject

Returns the value of attribute assets_url.



15
16
17
# File 'lib/jirafe/configuration.rb', line 15

def assets_url
  @assets_url
end

#callback_urlObject

Returns the value of attribute callback_url.



15
16
17
# File 'lib/jirafe/configuration.rb', line 15

def callback_url
  @callback_url
end

#content_typeObject

Returns the value of attribute content_type.



15
16
17
# File 'lib/jirafe/configuration.rb', line 15

def content_type
  @content_type
end

#loggerObject

Returns the value of attribute logger.



15
16
17
# File 'lib/jirafe/configuration.rb', line 15

def logger
  @logger
end

#testObject

Returns the value of attribute test.



15
16
17
# File 'lib/jirafe/configuration.rb', line 15

def test
  @test
end

#tokenObject

Returns the value of attribute token.



15
16
17
# File 'lib/jirafe/configuration.rb', line 15

def token
  @token
end

#tracking_urlObject

Returns the value of attribute tracking_url.



15
16
17
# File 'lib/jirafe/configuration.rb', line 15

def tracking_url
  @tracking_url
end

#urlObject

Returns the value of attribute url.



15
16
17
# File 'lib/jirafe/configuration.rb', line 15

def url
  @url
end

Instance Method Details

#data_pathObject



46
47
48
49
# File 'lib/jirafe/configuration.rb', line 46

def data_path
  uri = URI.parse(callback_url)
  [uri.host, uri.path].join("")
end

#default?Boolean

Returns:

  • (Boolean)


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

def default?
  self.url == DEFAULT_URL &&
    self.callback_url == DEFAULT_CALLBACK_URL &&
    self.assets_url == DEFAULT_ASSETS_URL &&
    self.tracking_url == DEFAULT_TRACKING_URL
end

#reset!Object



58
59
60
61
62
63
64
65
66
67
# File 'lib/jirafe/configuration.rb', line 58

def reset!
  self.url = DEFAULT_URL
  self.callback_url = DEFAULT_CALLBACK_URL
  self.assets_url = DEFAULT_ASSETS_URL
  self.tracking_url = DEFAULT_TRACKING_URL
  self.content_type = DEFAULT_CONTENT_TYPE
  self.token = nil
  self.test = false
  self.logger = nil
end

#tracking_pathObject



41
42
43
44
# File 'lib/jirafe/configuration.rb', line 41

def tracking_path
  uri = URI.parse(tracking_url)
  [uri.host, uri.path].join("")
end