Class: ChatNotifier::App

Inherits:
Object
  • Object
show all
Defined in:
lib/chat_notifier/app.rb

Overview

The application under test: its name plus the source control context (branch and sha), resolved from CI-standard settings with git fallbacks.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, settings:, runner: method(:capture)) ⇒ App

Returns a new instance of App.



7
8
9
10
11
# File 'lib/chat_notifier/app.rb', line 7

def initialize(name:, settings:, runner: method(:capture))
  @name = name
  @settings = settings
  @runner = runner
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/chat_notifier/app.rb', line 13

def name
  @name
end

#runnerObject (readonly)

Returns the value of attribute runner.



13
14
15
# File 'lib/chat_notifier/app.rb', line 13

def runner
  @runner
end

#settingsObject (readonly)

Returns the value of attribute settings.



13
14
15
# File 'lib/chat_notifier/app.rb', line 13

def settings
  @settings
end

Instance Method Details

#branchObject



17
18
19
20
21
22
# File 'lib/chat_notifier/app.rb', line 17

def branch
  return @branch if defined?(@branch)

  @branch = from_settings("NOTIFY_BRANCH", "GITHUB_HEAD_REF", "GITHUB_REF_NAME") ||
    git("branch --show-current")
end

#shaObject



24
25
26
27
28
29
# File 'lib/chat_notifier/app.rb', line 24

def sha
  return @sha if defined?(@sha)

  @sha = from_settings("NOTIFY_SHA", "GITHUB_SHA") ||
    git("rev-parse --short HEAD")
end

#to_sObject



15
# File 'lib/chat_notifier/app.rb', line 15

def to_s = name