Class: OmgPullRequest::Configuration
- Inherits:
-
Object
- Object
- OmgPullRequest::Configuration
- Defined in:
- lib/omg_pull_request/configuration.rb
Defined Under Namespace
Modules: Helpers
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#local_repo ⇒ Object
Returns the value of attribute local_repo.
Instance Method Summary collapse
- #config_file ⇒ Object
- #database_yml ⇒ Object
-
#initialize(attributes = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #omg_dir ⇒ Object
- #runner_class ⇒ Object
- #storage_class ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Configuration
Returns a new instance of Configuration.
5 6 7 8 9 10 11 12 13 |
# File 'lib/omg_pull_request/configuration.rb', line 5 def initialize(attributes={}) attributes.each do |attr, value| self.send("#{attr}=", value) end if config.blank? && File.exists?(self.config_file) @config = YAML.load(File.open(self.config_file)) end end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
3 4 5 |
# File 'lib/omg_pull_request/configuration.rb', line 3 def config @config end |
#local_repo ⇒ Object
Returns the value of attribute local_repo.
3 4 5 |
# File 'lib/omg_pull_request/configuration.rb', line 3 def local_repo @local_repo end |
Instance Method Details
#config_file ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/omg_pull_request/configuration.rb', line 31 def config_file file = ENV['yml'] || File.join(omg_dir, 'config.yml') unless File.exist?(file) raise "Configuration file does not exist: #{file}" end file end |
#database_yml ⇒ Object
27 28 29 |
# File 'lib/omg_pull_request/configuration.rb', line 27 def database_yml self.config['database_yml'] || File.join(omg_dir, 'database.yml') end |
#omg_dir ⇒ Object
40 41 42 |
# File 'lib/omg_pull_request/configuration.rb', line 40 def omg_dir File.join(local_repo, '.omgprrc') end |
#runner_class ⇒ Object
44 45 46 |
# File 'lib/omg_pull_request/configuration.rb', line 44 def runner_class "OmgPullRequest::TestRunner::#{config['runner'] || 'Rails'}".constantize end |
#storage_class ⇒ Object
48 49 50 |
# File 'lib/omg_pull_request/configuration.rb', line 48 def storage_class "OmgPullRequest::Storage::#{(config['storage'] || Hash.new)['provider'] || 'Gist'}".constantize end |