Class: OmgPullRequest::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/omg_pull_request/configuration.rb

Defined Under Namespace

Modules: Helpers

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#configObject

Returns the value of attribute config.



3
4
5
# File 'lib/omg_pull_request/configuration.rb', line 3

def config
  @config
end

#local_repoObject

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_fileObject



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_ymlObject



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_dirObject



40
41
42
# File 'lib/omg_pull_request/configuration.rb', line 40

def omg_dir
  File.join(local_repo, '.omgprrc')
end

#runner_classObject



44
45
46
# File 'lib/omg_pull_request/configuration.rb', line 44

def runner_class
  "OmgPullRequest::TestRunner::#{config['runner'] || 'Rails'}".constantize
end

#storage_classObject



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