Module: Barruun::Managers::Utils
- Included in:
- Bigquery::Dataset, Logging::Sink, Storage::Bucket
- Defined in:
- lib/barruun/managers/utils.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #initialize(file_path, config_klass = Object.const_get("#{self.class.name.gsub("Managers", "Configurations")}")) ⇒ Object
- #options_string(options) ⇒ Object
Class Method Details
.included(obj) ⇒ Object
6 7 8 |
# File 'lib/barruun/managers/utils.rb', line 6 def self.included(obj) obj.const_set('ConfigFileLoadError', Class.new(RuntimeError)) end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/barruun/managers/utils.rb', line 18 def call if exist? puts "#{self.class.name} #{@config.name} already exists. Nothing to do." else puts "#{self.class.name} #{@config.name} not found." create end end |
#initialize(file_path, config_klass = Object.const_get("#{self.class.name.gsub("Managers", "Configurations")}")) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/barruun/managers/utils.rb', line 10 def initialize(file_path, config_klass = Object.const_get("#{self.class.name.gsub("Managers", "Configurations")}")) @file_path = file_path if !File.exists?(@file_path) raise self.class::ConfigFileLoadError, "Error loading config file: #{file_path}" end @config = config_klass.new(YAML.load_file(file_path)) end |
#options_string(options) ⇒ Object
27 28 29 |
# File 'lib/barruun/managers/utils.rb', line 27 def () .map { |k, v| "--#{k}=#{v}" }.compact.join(" ") end |