Class: Geordi::Settings
- Inherits:
-
Object
- Object
- Geordi::Settings
- 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[ auto_update_chromedriver hint_probability irb_flags linear_api_key linear_team_ids ].freeze
- ALLOWED_LOCAL_SETTINGS =
%w[ linear_team_ids linear_state_after_deploy irb_flags].freeze
- SETTINGS_WARNED =
'GEORDI_INVALID_SETTINGS_WARNED'
Instance Method Summary collapse
- #auto_update_chromedriver ⇒ Object
- #auto_update_chromedriver=(value) ⇒ Object
- #hint_probability ⇒ Object
-
#initialize ⇒ Settings
constructor
A new instance of Settings.
-
#irb_flags ⇒ Object
Global settings.
- #linear_api_key ⇒ Object
- #linear_api_key=(value) ⇒ Object
- #linear_integration_set_up? ⇒ Boolean
- #linear_state_after_deploy(stage) ⇒ Object
- #linear_team_ids ⇒ Object
- #persist_linear_state_after_deploy(stage, target_state) ⇒ Object
Constructor Details
#initialize ⇒ Settings
Returns a new instance of Settings.
23 24 25 |
# File 'lib/geordi/settings.rb', line 23 def initialize read_settings end |
Instance Method Details
#auto_update_chromedriver ⇒ Object
52 53 54 |
# File 'lib/geordi/settings.rb', line 52 def auto_update_chromedriver @global_settings["auto_update_chromedriver"] || false end |
#auto_update_chromedriver=(value) ⇒ Object
56 57 58 59 |
# File 'lib/geordi/settings.rb', line 56 def auto_update_chromedriver=(value) @global_settings['auto_update_chromedriver'] = value save_global_settings end |
#hint_probability ⇒ Object
48 49 50 |
# File 'lib/geordi/settings.rb', line 48 def hint_probability @global_settings['hint_probability'] end |
#irb_flags ⇒ Object
Global settings
28 29 30 31 32 33 34 |
# File 'lib/geordi/settings.rb', line 28 def irb_flags if @local_settings.key? 'irb_flags' [@local_settings['irb_flags'].to_s, :local] elsif @global_settings.key? 'irb_flags' [@global_settings['irb_flags'].to_s, :global] end end |
#linear_api_key ⇒ Object
36 37 38 39 40 41 |
# File 'lib/geordi/settings.rb', line 36 def linear_api_key @global_settings['linear_api_key'] || begin Interaction.warn 'Linear API key not found' inquire_linear_api_key end end |
#linear_api_key=(value) ⇒ Object
43 44 45 46 |
# File 'lib/geordi/settings.rb', line 43 def linear_api_key=(value) @global_settings['linear_api_key'] = value save_global_settings end |
#linear_integration_set_up? ⇒ Boolean
78 79 80 81 |
# File 'lib/geordi/settings.rb', line 78 def linear_integration_set_up? team_ids = get_linear_team_ids !team_ids.empty? end |
#linear_state_after_deploy(stage) ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/geordi/settings.rb', line 83 def linear_state_after_deploy(stage) config_state = @local_settings['linear_state_after_deploy'] if config_state && config_state[stage] config_state[stage] else '' end end |
#linear_team_ids ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/geordi/settings.rb', line 61 def linear_team_ids local_team_ids = normalize_team_ids(@local_settings['linear_team_ids']) global_team_ids = normalize_team_ids(@global_settings['linear_team_ids']) team_ids = local_team_ids | global_team_ids if team_ids.empty? Geordi::Interaction.warn 'No team id found.' puts 'Please open a team in Linear, open the command menu with CTRL + K and choose' puts "\"Copy model UUID\". Store that team id in #{LOCAL_SETTINGS_FILE_NAME}:" puts 'linear_team_ids: abc-123-123-abc, def-456-456-def' exit 1 end team_ids end |
#persist_linear_state_after_deploy(stage, target_state) ⇒ Object
93 94 95 96 97 98 99 100 101 |
# File 'lib/geordi/settings.rb', line 93 def persist_linear_state_after_deploy(stage, target_state) config_state = @local_settings.dig('linear_state_after_deploy', stage) unless target_state.eql?(config_state) @local_settings['linear_state_after_deploy'] ||= Hash.new @local_settings['linear_state_after_deploy'][stage] = target_state save_local_settings end end |