Class: Underway::Settings::Configuration
- Inherits:
-
Object
- Object
- Underway::Settings::Configuration
- Defined in:
- lib/underway/settings.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
-
#app_issuer ⇒ Object
The Integration ID From “About -> ID” at github.com/settings/apps/<app-name>.
- #app_root=(directory) ⇒ Object
- #config_filename=(filename) ⇒ Object
- #db ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #load! ⇒ Object
- #oauth_access_token_url(code) ⇒ Object
- #oauth_authorize_url ⇒ Object
-
#private_key ⇒ Object
Private Key for the App, generated based on the PEM file.
- #private_key_filename ⇒ Object
-
#private_pem ⇒ Object
PEM file for request signing (PKCS#1 RSAPrivateKey format) (Download from github.com/settings/apps/<app-name> “Private key”).
-
#raw ⇒ Object
TODO: deprecate.
- #token_cache ⇒ Object
- #verbose_logging ⇒ Object
-
#webhook_secret ⇒ Object
Integration webhook secret (for validating that webhooks come from GitHub).
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 |
# File 'lib/underway/settings.rb', line 10 def initialize @logger = Underway::Logger.new end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/underway/settings.rb', line 8 def config @config end |
#logger ⇒ Object
Returns the value of attribute logger.
8 9 10 |
# File 'lib/underway/settings.rb', line 8 def logger @logger end |
Instance Method Details
#app_issuer ⇒ Object
The Integration ID From “About -> ID” at github.com/settings/apps/<app-name>
47 48 49 |
# File 'lib/underway/settings.rb', line 47 def app_issuer @app_issuer ||= config["app_id"] end |
#app_root=(directory) ⇒ Object
25 26 27 |
# File 'lib/underway/settings.rb', line 25 def app_root=(directory) @app_root = Pathname.new(directory).dirname end |
#config_filename=(filename) ⇒ Object
29 30 31 |
# File 'lib/underway/settings.rb', line 29 def config_filename=(filename) @config_filename = filename end |
#db ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/underway/settings.rb', line 37 def db @db ||= begin Underway::DB.configure(config["database_url"]) Underway::DB.instance.database end end |
#load! ⇒ Object
14 15 16 17 18 |
# File 'lib/underway/settings.rb', line 14 def load! @config = JSON.parse( @app_root.join(@config_filename).read ) end |
#oauth_access_token_url(code) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/underway/settings.rb', line 84 def oauth_access_token_url(code) api_host = Addressable::URI.parse(config["github_api_host"]) template = Addressable::Template.new( "{scheme}://{host}/login/oauth/access_token{?code,client_id,client_secret}" ) template.( "scheme" => api_host.scheme, "host" => api_host.domain, "code" => code, "client_id" => config["client_id"], "client_secret" => config["client_secret"] ) end |
#oauth_authorize_url ⇒ Object
79 80 81 82 |
# File 'lib/underway/settings.rb', line 79 def uri = Addressable::URI.parse(config["github_api_host"]) "#{uri.scheme}://#{uri.domain}/login/oauth/authorize?client_id=#{config["client_id"]}" end |
#private_key ⇒ Object
Private Key for the App, generated based on the PEM file
67 68 69 |
# File 'lib/underway/settings.rb', line 67 def private_key @private_key ||= OpenSSL::PKey::RSA.new(private_pem) end |
#private_key_filename ⇒ Object
56 57 58 |
# File 'lib/underway/settings.rb', line 56 def private_key_filename @app_root.join(config["private_key_filename"]) end |
#private_pem ⇒ Object
PEM file for request signing (PKCS#1 RSAPrivateKey format) (Download from github.com/settings/apps/<app-name> “Private key”)
62 63 64 |
# File 'lib/underway/settings.rb', line 62 def private_pem @private_pem ||= File.read(private_key_filename) end |
#raw ⇒ Object
TODO: deprecate
21 22 23 |
# File 'lib/underway/settings.rb', line 21 def raw @config end |
#token_cache ⇒ Object
75 76 77 |
# File 'lib/underway/settings.rb', line 75 def token_cache @token_cache ||= Underway::TokenCache.new(db) end |
#verbose_logging ⇒ Object
71 72 73 |
# File 'lib/underway/settings.rb', line 71 def verbose_logging @verbose ||= config["verbose_logging"] end |
#webhook_secret ⇒ Object
Integration webhook secret (for validating that webhooks come from GitHub)
52 53 54 |
# File 'lib/underway/settings.rb', line 52 def webhook_secret @webhook_secret ||= config["webhook_secret"] end |