Class: TRMNLP::Config::App
- Inherits:
-
Object
- Object
- TRMNLP::Config::App
- Defined in:
- lib/trmnlp/config/app.rb
Overview
Stores trmnlp-wide configuration (irrespective of the current plugin)
Instance Method Summary collapse
- #account_uri ⇒ Object
- #api_key ⇒ Object
- #api_key=(key) ⇒ Object
- #api_uri ⇒ Object
- #base_uri ⇒ Object
- #edit_plugin_settings_uri(id) ⇒ Object
-
#initialize(paths) ⇒ App
constructor
A new instance of App.
- #logged_in? ⇒ Boolean
- #logged_out? ⇒ Boolean
- #playlists_uri ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(paths) ⇒ App
Returns a new instance of App.
9 10 11 12 |
# File 'lib/trmnlp/config/app.rb', line 9 def initialize(paths) @paths = paths @config = read_config end |
Instance Method Details
#account_uri ⇒ Object
37 |
# File 'lib/trmnlp/config/app.rb', line 37 def account_uri = URI.join(base_uri, '/account') |
#api_key ⇒ Object
22 23 24 25 26 27 |
# File 'lib/trmnlp/config/app.rb', line 22 def api_key env_api_key = ENV.fetch('TRMNL_API_KEY', nil) return env_api_key if env_api_key && !env_api_key.empty? @config['api_key'] end |
#api_key=(key) ⇒ Object
29 30 31 |
# File 'lib/trmnlp/config/app.rb', line 29 def api_key=(key) @config['api_key'] = key end |
#api_uri ⇒ Object
35 |
# File 'lib/trmnlp/config/app.rb', line 35 def api_uri = URI.join(base_uri, '/api') |
#base_uri ⇒ Object
33 |
# File 'lib/trmnlp/config/app.rb', line 33 def base_uri = URI.parse(@config['base_url'] || 'https://trmnl.com') |
#edit_plugin_settings_uri(id) ⇒ Object
39 |
# File 'lib/trmnlp/config/app.rb', line 39 def edit_plugin_settings_uri(id) = URI.join(base_uri, "/plugin_settings/#{id}/edit") |
#logged_in? ⇒ Boolean
19 |
# File 'lib/trmnlp/config/app.rb', line 19 def logged_in? = api_key && !api_key.empty? |
#logged_out? ⇒ Boolean
20 |
# File 'lib/trmnlp/config/app.rb', line 20 def logged_out? = !logged_in? |
#playlists_uri ⇒ Object
41 |
# File 'lib/trmnlp/config/app.rb', line 41 def playlists_uri = URI.join(base_uri, '/playlists') |
#save ⇒ Object
14 15 16 17 |
# File 'lib/trmnlp/config/app.rb', line 14 def save paths.app_config_dir.mkpath paths.app_config.write(YAML.dump(@config)) end |