Module: Slodd::Config
- Defined in:
- lib/slodd/config.rb
Class Method Summary collapse
- .attributes ⇒ Object
- .database_settings ⇒ Object
- .databases ⇒ Object
- .defaults ⇒ Object
- .fetcher ⇒ Object
- .owner ⇒ Object
- .repo ⇒ Object
- .validate_github ⇒ Object
Class Method Details
.attributes ⇒ Object
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_settings ⇒ Object
25 26 27 |
# File 'lib/slodd/config.rb', line 25 def self.database_settings settings_from_url || settings_from_args end |
.databases ⇒ Object
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 |
.defaults ⇒ Object
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 |
.fetcher ⇒ Object
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 |
.owner ⇒ Object
29 30 31 |
# File 'lib/slodd/config.rb', line 29 def self.owner github.split('/')[0] if github end |
.repo ⇒ Object
33 34 35 |
# File 'lib/slodd/config.rb', line 33 def self.repo github.split('/')[1] if github end |
.validate_github ⇒ Object
48 49 50 |
# File 'lib/slodd/config.rb', line 48 def self.validate_github fail ArgumentError unless owner && repo && token end |