class GreyscaleRails::Railtie
Constants
- DRIVER_TYPES
Private Instance Methods
config_path( app )
click to toggle source
# File lib/greyscale_rails/railtie.rb, line 44 def config_path( app ) File.expand_path(config.greyscale.config_path, app.root) end
data_driver( yaml )
click to toggle source
# File lib/greyscale_rails/railtie.rb, line 48 def data_driver( yaml ) type = yaml[ :driver ].to_sym root = yaml[ :data_root ] driver_class = DRIVER_TYPES[type] raise "Greyscale Rails error: #{type} is not a valid driver. Please choose from: #{DRIVER_TYPES.keys.join(", ")}" unless driver_class driver = driver_class.new root if driver.respond_to?( :api_key ) && driver.respond_to?( :api_id ) driver.api_id = yaml[:api_id] driver.api_key = yaml[:api_key] end driver end
load_config!( app )
click to toggle source
# File lib/greyscale_rails/railtie.rb, line 26 def load_config!( app ) path = config_path( app ) yaml = YAML.load_file( path ).with_indifferent_access[Rails.env.to_s] config.greyscale.data_driver = data_driver yaml if yaml[:revision_root].present? config.greyscale.patch_driver = data_driver yaml.merge( data_root: yaml[ :revision_root ] ) end config.greyscale.live_reload = yaml[ :live_reload ] || false rescue => e raise "Failed to process #{config.greyscale.config_path}. Make sure the file exists and is not malformed. Error: \"#{e}\"" end