Class: Yt::Models::Configuration
- Inherits:
-
Object
- Object
- Yt::Models::Configuration
- Defined in:
- lib/yt/models/configuration.rb
Overview
Provides an object to store global configuration settings.
This class is typically not used directly, but by calling Yt.configure, which creates and updates a single instance of Configuration.
An alternative way to set global configuration settings is by storing them in the following environment variables:
-
YT_CLIENT_ID
to store the Client ID for web/device apps -
YT_CLIENT_SECRET
to store the Client Secret for web/device apps -
YT_API_KEY
to store the API key for server/browser apps -
YT_LOG_LEVEL
to store the verbosity level of the logs
In case both methods are used together, Yt.configure takes precedence.
Instance Attribute Summary collapse
-
#api_key ⇒ String
The API key for server/browser YouTube applications.
-
#client_id ⇒ String
The Client ID for web/device YouTube applications.
-
#client_secret ⇒ String
The Client Secret for web/device YouTube applications.
-
#log_level ⇒ String
The level of output to print for debugging purposes.
Instance Method Summary collapse
-
#debugging? ⇒ Boolean
Whether the logging output is verbose.
-
#developing? ⇒ Boolean
Whether the logging output is extra-verbose.
-
#initialize ⇒ Configuration
constructor
Initialize the global configuration settings, using the values of the specified following environment variables by default.
Constructor Details
#initialize ⇒ Configuration
Initialize the global configuration settings, using the values of the specified following environment variables by default.
50 51 52 53 54 55 |
# File 'lib/yt/models/configuration.rb', line 50 def initialize @client_id = ENV['YT_CLIENT_ID'] @client_secret = ENV['YT_CLIENT_SECRET'] @api_key = ENV['YT_API_KEY'] @log_level = ENV['YT_LOG_LEVEL'] end |
Instance Attribute Details
#api_key ⇒ String
Returns the API key for server/browser YouTube applications.
43 44 45 |
# File 'lib/yt/models/configuration.rb', line 43 def api_key @api_key end |
#client_id ⇒ String
Returns the Client ID for web/device YouTube applications.
35 36 37 |
# File 'lib/yt/models/configuration.rb', line 35 def client_id @client_id end |
#client_secret ⇒ String
Returns the Client Secret for web/device YouTube applications.
39 40 41 |
# File 'lib/yt/models/configuration.rb', line 39 def client_secret @client_secret end |
#log_level ⇒ String
Returns the level of output to print for debugging purposes.
46 47 48 |
# File 'lib/yt/models/configuration.rb', line 46 def log_level @log_level end |
Instance Method Details
#debugging? ⇒ Boolean
Returns whether the logging output is verbose. Useful when debugging (e.g., to print the curl of failing requests).
65 66 67 |
# File 'lib/yt/models/configuration.rb', line 65 def debugging? log_level.to_s.in? %w(devel debug) end |
#developing? ⇒ Boolean
Returns whether the logging output is extra-verbose. Useful when developing (e.g., to print the curl of every request).
59 60 61 |
# File 'lib/yt/models/configuration.rb', line 59 def developing? log_level.to_s.in? %w(devel) end |