Sha256: f114cf647d2b8ab9f744df60cdceabc466a6efb92539f10e56960ee5900579fd
Contents?: true
Size: 986 Bytes
Versions: 2
Compression:
Stored size: 986 Bytes
Contents
require 'logger' require 'uri' require 'voltron/config/js' module Voltron class Config include ::ActiveSupport::Callbacks define_callbacks :generate_voltron_config attr_accessor :logger, :debug, :log_level attr_writer :base_url def initialize @logger ||= ::Logger.new(::Rails.root.join('log', 'voltron.log')) @debug ||= false @log_level ||= Rails.application.config.log_level @base_url ||= (Rails.application.config.action_controller.default_url_options.try(:[], :host) || 'http://localhost:3000') end def to_h run_callbacks :generate_voltron_config js.to_h.merge(debug: @debug, log_level: @log_level) end def merge(data) js.custom.merge! data end def base_url @base_url = "http://#{@base_url}" unless @base_url.strip.start_with?('http') url = URI.parse(@base_url) port = url.port == 80 ? '' : ":#{url.port}" "#{url.scheme}://#{url.host}#{port}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
voltron-0.3.1 | lib/voltron/config.rb |
voltron-0.2.10 | lib/voltron/config.rb |