Class: Upfluence::Peer

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Peer

Returns a new instance of Peer.



6
7
8
9
10
11
12
# File 'lib/upfluence/peer.rb', line 6

def initialize(opts = {})
  @authority = opts[:authority] || 'local'
  @instance_name = opts[:instance_name] || 'unknown-server'
  @app_name = opts[:app_name] || 'unknown-name'
  @project_name = opts[:project_name] || 'unknown-app'
  @environment = opts[:environment] || 'development'
end

Instance Attribute Details

#app_name ⇒ Object (readonly)

Returns the value of attribute app_name.



3
4
5
# File 'lib/upfluence/peer.rb', line 3

def app_name
  @app_name
end

#authority ⇒ Object (readonly)

Returns the value of attribute authority.



3
4
5
# File 'lib/upfluence/peer.rb', line 3

def authority
  @authority
end

#environment ⇒ Object (readonly)

Returns the value of attribute environment.



3
4
5
# File 'lib/upfluence/peer.rb', line 3

def environment
  @environment
end

#instance_name ⇒ Object (readonly)

Returns the value of attribute instance_name.



3
4
5
# File 'lib/upfluence/peer.rb', line 3

def instance_name
  @instance_name
end

#project_name ⇒ Object (readonly)

Returns the value of attribute project_name.



3
4
5
# File 'lib/upfluence/peer.rb', line 3

def project_name
  @project_name
end

Class Method Details

.from_env ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/upfluence/peer.rb', line 19

def from_env
  Peer.new(
    authority:     ENV['AUTHORITY'],
    instance_name: ENV['INSTANCE_NAME'],
    app_name:      ENV['APP_NAME'],
    project_name:  ENV['PROJECT_NAME'],
    environment:   ENV['ENV']
  )
end

Instance Method Details

#to_url ⇒ Object



14
15
16
# File 'lib/upfluence/peer.rb', line 14

def to_url
  "peer://#{@environment}@#{@authority}/#{@instance_name}"
end