Class: Condux::Dsn
- Inherits:
-
Object
- Object
- Condux::Dsn
- Defined in:
- lib/condux/dsn.rb
Overview
A parsed DSN: the relay endpoint, the project id path segment, and the public key.
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#project_id ⇒ Object
readonly
Returns the value of attribute project_id.
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(endpoint, project_id, public_key) ⇒ Dsn
constructor
A new instance of Dsn.
-
#store_url ⇒ Object
The Sentry store endpoint an event is POSTed to.
Constructor Details
#initialize(endpoint, project_id, public_key) ⇒ Dsn
Returns a new instance of Dsn.
21 22 23 24 25 |
# File 'lib/condux/dsn.rb', line 21 def initialize(endpoint, project_id, public_key) @endpoint = endpoint @project_id = project_id @public_key = public_key end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
8 9 10 |
# File 'lib/condux/dsn.rb', line 8 def endpoint @endpoint end |
#project_id ⇒ Object (readonly)
Returns the value of attribute project_id.
8 9 10 |
# File 'lib/condux/dsn.rb', line 8 def project_id @project_id end |
#public_key ⇒ Object (readonly)
Returns the value of attribute public_key.
8 9 10 |
# File 'lib/condux/dsn.rb', line 8 def public_key @public_key end |
Class Method Details
.parse(dsn) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/condux/dsn.rb', line 10 def self.parse(dsn) uri = URI(dsn) if uri.user.nil? || uri.user.empty? || uri.host.nil? raise ArgumentError, "Condux: DSN must be scheme://<key>@<host>/<projectId>" end endpoint = "#{uri.scheme}://#{uri.host}" endpoint += ":#{uri.port}" if uri.port && ![80, 443].include?(uri.port) new(endpoint, uri.path.sub(%r{\A/}, ""), uri.user) end |
Instance Method Details
#store_url ⇒ Object
The Sentry store endpoint an event is POSTed to.
28 29 30 |
# File 'lib/condux/dsn.rb', line 28 def store_url "#{endpoint}/api/#{project_id}/store/" end |