Class: Geordi::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/geordi/settings.rb

Constant Summary collapse

GLOBAL_SETTINGS_FILE_NAME =
Util.testing? ? './tmp/global_settings.yml'.freeze : File.join(ENV['HOME'], '.config/geordi/global.yml').freeze
LOCAL_SETTINGS_FILE_NAME =
Util.testing? ? './tmp/local_settings.yml'.freeze : './.geordi.yml'.freeze
ALLOWED_GLOBAL_SETTINGS =
%w[ pivotal_tracker_api_key auto_update_chromedriver pivotal_tracker_project_ids ].freeze
ALLOWED_LOCAL_SETTINGS =
%w[ pivotal_tracker_project_ids ].freeze
SETTINGS_WARNED =
'GEORDI_INVALID_SETTINGS_WARNED'

Instance Method Summary collapse

Constructor Details

#initializeSettings

Returns a new instance of Settings.



16
17
18
# File 'lib/geordi/settings.rb', line 16

def initialize
  read_settings
end

Instance Method Details

#auto_update_chromedriverObject



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

def auto_update_chromedriver
  @global_settings["auto_update_chromedriver"] || false
end

#auto_update_chromedriver=(value) ⇒ Object



34
35
36
37
# File 'lib/geordi/settings.rb', line 34

def auto_update_chromedriver=(value)
  @global_settings['auto_update_chromedriver'] = value
  save_global_settings
end

#pivotal_tracker_api_keyObject

Global settings



21
22
23
# File 'lib/geordi/settings.rb', line 21

def pivotal_tracker_api_key
  @global_settings['pivotal_tracker_api_key'] || gitpt_api_key_old || inquire_pt_api_key
end

#pivotal_tracker_api_key=(value) ⇒ Object



25
26
27
28
# File 'lib/geordi/settings.rb', line 25

def pivotal_tracker_api_key=(value)
  @global_settings['pivotal_tracker_api_key'] = value
  save_global_settings
end

#pivotal_tracker_project_idsObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/geordi/settings.rb', line 39

def pivotal_tracker_project_ids
  local_project_ids = @local_settings['pivotal_tracker_project_ids'] || pt_project_ids_old
  global_project_ids = @global_settings['pivotal_tracker_project_ids']

  local_project_ids = array_wrap_project_ids(local_project_ids)
  global_project_ids = array_wrap_project_ids(global_project_ids)

  project_ids = local_project_ids | global_project_ids

  if project_ids.empty?
    puts
    Geordi::Interaction.warn "Sorry, I could not find a project ID in .geordi.yml :("
    puts

    puts "Please put at least one Pivotal Tracker project id into the .geordi.yml file in this directory, e.g."
    puts
    puts "pivotal_tracker_project_ids:"
    puts "- 123456"
    puts
    puts 'You may add multiple IDs.'
    exit 1
  end

  project_ids
end