Class: Underway::Settings::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/underway/settings.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



9
10
11
# File 'lib/underway/settings.rb', line 9

def initialize
  @logger = Underway::Logger.new
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/underway/settings.rb', line 7

def config
  @config
end

#loggerObject

Returns the value of attribute logger.



7
8
9
# File 'lib/underway/settings.rb', line 7

def logger
  @logger
end

Instance Method Details

#app_issuerObject

The Integration ID From “About -> ID” at github.com/settings/apps/<app-name>



46
47
48
# File 'lib/underway/settings.rb', line 46

def app_issuer
  @app_issuer ||= config["app_id"]
end

#app_root=(directory) ⇒ Object



24
25
26
# File 'lib/underway/settings.rb', line 24

def app_root=(directory)
  @app_root = Pathname.new(directory).dirname
end

#config_filename=(filename) ⇒ Object



28
29
30
# File 'lib/underway/settings.rb', line 28

def config_filename=(filename)
  @config_filename = filename
end

#dbObject



36
37
38
39
40
41
42
# File 'lib/underway/settings.rb', line 36

def db
  @db ||=
    begin
      Underway::DB.configure(config["database_url"])
      Underway::DB.instance.database
    end
end

#load!Object



13
14
15
16
17
# File 'lib/underway/settings.rb', line 13

def load!
  @config = JSON.parse(
    @app_root.join(@config_filename).read
  )
end

#private_keyObject

Private Key for the App, generated based on the PEM file



66
67
68
# File 'lib/underway/settings.rb', line 66

def private_key
  @private_key ||= OpenSSL::PKey::RSA.new(private_pem)
end

#private_key_filenameObject



55
56
57
# File 'lib/underway/settings.rb', line 55

def private_key_filename
  @app_root.join(config["private_key_filename"])
end

#private_pemObject

PEM file for request signing (PKCS#1 RSAPrivateKey format) (Download from github.com/settings/apps/<app-name> “Private key”)



61
62
63
# File 'lib/underway/settings.rb', line 61

def private_pem
  @private_pem ||= File.read(private_key_filename)
end

#rawObject

TODO: deprecate



20
21
22
# File 'lib/underway/settings.rb', line 20

def raw
  @config
end

#token_cacheObject



74
75
76
# File 'lib/underway/settings.rb', line 74

def token_cache
  @token_cache ||= Underway::TokenCache.new(db)
end

#verbose_loggingObject



70
71
72
# File 'lib/underway/settings.rb', line 70

def verbose_logging
  @verbose ||= config["verbose_logging"]
end

#webhook_secretObject

Integration webhook secret (for validating that webhooks come from GitHub)



51
52
53
# File 'lib/underway/settings.rb', line 51

def webhook_secret
  @webhook_secret ||= config["webhook_secret"]
end