Class: Upfluence::Peer
- Inherits:
-
Object
- Object
- Upfluence::Peer
- Defined in:
- lib/upfluence/peer.rb
Defined Under Namespace
Classes: Version
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#authority ⇒ Object
readonly
Returns the value of attribute authority.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#instance_name ⇒ Object
readonly
Returns the value of attribute instance_name.
-
#project_name ⇒ Object
readonly
Returns the value of attribute project_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(authority:, instance_name:, app_name:, project_name:, environment:, version: nil) ⇒ Peer
constructor
A new instance of Peer.
- #to_url ⇒ Object
Constructor Details
#initialize(authority:, instance_name:, app_name:, project_name:, environment:, version: nil) ⇒ Peer
Returns a new instance of Peer.
77 78 79 80 81 82 83 84 85 |
# File 'lib/upfluence/peer.rb', line 77 def initialize(authority:, instance_name:, app_name:, project_name:, environment:, version: nil) @authority = || 'local' @instance_name = instance_name || 'unknown-server' @app_name = app_name || 'unknown-app' @project_name = project_name || 'unknown-app' @environment = environment || 'development' @version = version end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
74 75 76 |
# File 'lib/upfluence/peer.rb', line 74 def app_name @app_name end |
#authority ⇒ Object (readonly)
Returns the value of attribute authority.
74 75 76 |
# File 'lib/upfluence/peer.rb', line 74 def @authority end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
74 75 76 |
# File 'lib/upfluence/peer.rb', line 74 def environment @environment end |
#instance_name ⇒ Object (readonly)
Returns the value of attribute instance_name.
74 75 76 |
# File 'lib/upfluence/peer.rb', line 74 def instance_name @instance_name end |
#project_name ⇒ Object (readonly)
Returns the value of attribute project_name.
74 75 76 |
# File 'lib/upfluence/peer.rb', line 74 def project_name @project_name end |
Class Method Details
.from_env ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/upfluence/peer.rb', line 99 def from_env Peer.new( authority: ENV['AUTHORITY'], instance_name: ENV['UNIT_NAME'], app_name: ENV['APP_NAME'], project_name: ENV['PROJECT_NAME'], environment: ENV['ENV'], version: Version.new( build_git_version, Version::SemanticVersion.parse(ENV['VERSION']) ) ) end |
Instance Method Details
#to_url ⇒ Object
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/upfluence/peer.rb', line 87 def to_url query = { 'app-name' => @app_name, 'project-name' => @project_name, 'git-version' => @version.git&.commit, 'semantic-version' => @version.semantic&.to_s }.compact.map { |k, v| "#{k}=#{CGI.escape(v)}" }.join('&') "peer://#{@environment}@#{@authority}/#{@instance_name}?#{query}" end |