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.
7 8 9 10 |
# File 'lib/trmnlp/config/app.rb', line 7 def initialize(paths) @paths = paths @config = read_config end |
Instance Method Details
#account_uri ⇒ Object
30 |
# File 'lib/trmnlp/config/app.rb', line 30 def account_uri = URI.join(base_uri, '/account') |
#api_key ⇒ Object
20 |
# File 'lib/trmnlp/config/app.rb', line 20 def api_key = @config['api_key'] |
#api_key=(key) ⇒ Object
22 23 24 |
# File 'lib/trmnlp/config/app.rb', line 22 def api_key=(key) @config['api_key'] = key end |
#api_uri ⇒ Object
28 |
# File 'lib/trmnlp/config/app.rb', line 28 def api_uri = URI.join(base_uri, '/api') |
#base_uri ⇒ Object
26 |
# File 'lib/trmnlp/config/app.rb', line 26 def base_uri = URI.parse(@config['base_url'] || 'https://usetrmnl.com') |
#edit_plugin_settings_uri(id) ⇒ Object
32 |
# File 'lib/trmnlp/config/app.rb', line 32 def edit_plugin_settings_uri(id) = URI.join(base_uri, "/plugin_settings/#{id.to_s}/edit") |
#logged_in? ⇒ Boolean
17 |
# File 'lib/trmnlp/config/app.rb', line 17 def logged_in? = api_key && !api_key.empty? |
#logged_out? ⇒ Boolean
18 |
# File 'lib/trmnlp/config/app.rb', line 18 def logged_out? = !logged_in? |
#playlists_uri ⇒ Object
34 |
# File 'lib/trmnlp/config/app.rb', line 34 def playlists_uri = URI.join(base_uri, '/playlists') |
#save ⇒ Object
12 13 14 15 |
# File 'lib/trmnlp/config/app.rb', line 12 def save paths.app_config_dir.mkpath paths.app_config.write(YAML.dump(@config)) end |