Class: AirTest::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/air_test/configuration.rb

Overview

Handles configuration for AirTest, including API tokens and environment variables.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/air_test/configuration.rb', line 9

def initialize
  @tool = ENV.fetch("AIRTEST_TOOL", "notion")
  @notion = {
    token: ENV.fetch("NOTION_TOKEN", nil),
    database_id: ENV.fetch("NOTION_DATABASE_ID", nil)
  }
  @jira = {
    token: ENV.fetch("JIRA_TOKEN", nil),
    project_id: ENV.fetch("JIRA_PROJECT_ID", nil),
    domain: ENV.fetch("JIRA_DOMAIN", nil),
    email: ENV.fetch("JIRA_EMAIL", nil)
  }
  @monday = {
    token: ENV.fetch("MONDAY_TOKEN", nil),
    board_id: ENV.fetch("MONDAY_BOARD_ID", nil),
    domain: ENV.fetch("MONDAY_DOMAIN", nil)
  }
  @github = {
    token: ENV["GITHUB_BOT_TOKEN"] || ENV.fetch("GITHUB_TOKEN", nil)
  }
  @repo = ENV.fetch("REPO", nil)
  @status_filter = ENV.fetch("AIRTEST_STATUS_FILTER", "Not started")
end

Instance Attribute Details

#githubObject

Returns the value of attribute github.



7
8
9
# File 'lib/air_test/configuration.rb', line 7

def github
  @github
end

#jiraObject

Returns the value of attribute jira.



7
8
9
# File 'lib/air_test/configuration.rb', line 7

def jira
  @jira
end

#mondayObject

Returns the value of attribute monday.



7
8
9
# File 'lib/air_test/configuration.rb', line 7

def monday
  @monday
end

#notionObject

Returns the value of attribute notion.



7
8
9
# File 'lib/air_test/configuration.rb', line 7

def notion
  @notion
end

#repoObject

Returns the value of attribute repo.



7
8
9
# File 'lib/air_test/configuration.rb', line 7

def repo
  @repo
end

#status_filterObject

Returns the value of attribute status_filter.



7
8
9
# File 'lib/air_test/configuration.rb', line 7

def status_filter
  @status_filter
end

#toolObject

Returns the value of attribute tool.



7
8
9
# File 'lib/air_test/configuration.rb', line 7

def tool
  @tool
end

Instance Method Details

#validate!Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/air_test/configuration.rb', line 33

def validate!
  case tool.to_s.downcase
  when "notion"
    raise "Missing NOTION_TOKEN" unless notion[:token]
    raise "Missing NOTION_DATABASE_ID" unless notion[:database_id]
  when "jira"
    raise "Missing JIRA_TOKEN" unless jira[:token]
    raise "Missing JIRA_PROJECT_ID" unless jira[:project_id]
    raise "Missing JIRA_DOMAIN" unless jira[:domain]
    raise "Missing JIRA_EMAIL" unless jira[:email]
  when "monday"
    raise "Missing MONDAY_TOKEN" unless monday[:token]
    raise "Missing MONDAY_BOARD_ID" unless monday[:board_id]
    raise "Missing MONDAY_DOMAIN" unless monday[:domain]
  end
end