Class: BotConfig

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/bot_config.rb

Instance Method Summary collapse

Constructor Details

#initializeBotConfig

Returns a new instance of BotConfig.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bot_config.rb', line 7

def initialize
  @filename = File.expand_path('~/.bot-sync-github.cfg')
  if (!File.exists? @filename)
    $stderr.puts "Missing configuration file #{@filename}"
    exit 1
  end

  @config = ParseConfig.new(@filename)

  # Make sure every param is configured properly since param will throw an error for a missing key
  [:xcode_server, :github_url, :github_repo, :github_access_token, :xcode_devices, :xcode_scheme, :xcode_project_or_workspace].each do |key|
    param key
  end
end

Instance Method Details

#github_access_tokenObject



26
27
28
# File 'lib/bot_config.rb', line 26

def github_access_token
  param :github_access_token
end

#github_repoObject



34
35
36
# File 'lib/bot_config.rb', line 34

def github_repo
  param :github_repo
end

#param(key) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/bot_config.rb', line 50

def param(key)
  value = @config[key.to_s]
  if (value.nil?)
    $stderr.puts "Missing configuration key #{key} in #{@filename}"
    exit 1
  end
  value
end

#scm_pathObject



30
31
32
# File 'lib/bot_config.rb', line 30

def scm_path
  param :github_url
end

#xcode_devicesObject



38
39
40
# File 'lib/bot_config.rb', line 38

def xcode_devices
  param(:xcode_devices).split('|')
end

#xcode_project_or_workspaceObject



46
47
48
# File 'lib/bot_config.rb', line 46

def xcode_project_or_workspace
  param :xcode_project_or_workspace
end

#xcode_schemeObject



42
43
44
# File 'lib/bot_config.rb', line 42

def xcode_scheme
  param :xcode_scheme
end

#xcode_server_hostnameObject



22
23
24
# File 'lib/bot_config.rb', line 22

def xcode_server_hostname
  param :xcode_server
end