Module: Slodd::Config

Defined in:
lib/slodd/config.rb

Class Method Summary collapse

Class Method Details

.attributesObject



52
53
54
55
56
57
58
59
60
61
# File 'lib/slodd/config.rb', line 52

def self.attributes
  {
    owner: owner,
    repo: repo,
    token: token,
    path: path,
    ref: ref,
    url: url,
  }.delete_if { |_, v| v.nil? }
end

.database_settingsObject



25
26
27
# File 'lib/slodd/config.rb', line 25

def self.database_settings
  settings_from_url || settings_from_args
end

.databasesObject



20
21
22
23
# File 'lib/slodd/config.rb', line 20

def self.databases
  self.databases = database_uri.path[1..-1] if database_uri
  @@databases ? @@databases.split : []
end

.defaultsObject



11
12
13
14
15
16
# File 'lib/slodd/config.rb', line 11

def self.defaults
  self.path = 'db/schema.rb'
  self.username = 'root'
  self.host = 'localhost'
  self.databases = nil
end

.fetcherObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/slodd/config.rb', line 37

def self.fetcher
  if github
    validate_github
    Github.new(attributes)
  elsif url
    Http.new(attributes)
  elsif path
    Local.new(attributes)
  end
end

.ownerObject



29
30
31
# File 'lib/slodd/config.rb', line 29

def self.owner
  github.split('/')[0] if github
end

.repoObject



33
34
35
# File 'lib/slodd/config.rb', line 33

def self.repo
  github.split('/')[1] if github
end

.validate_githubObject



48
49
50
# File 'lib/slodd/config.rb', line 48

def self.validate_github
  fail ArgumentError unless owner && repo && token
end