Sha256: b9b7ee504030236dd1252d9f0328e304488e27b4df6b18748a9b6b4648794284
Contents?: true
Size: 1.9 KB
Versions: 8
Compression:
Stored size: 1.9 KB
Contents
# frozen_string_literal: true module Diffend # Diffend config object class Config attr_reader :project_id, :shareable_id, :shareable_key, :build_path, :env, :command # Build diffend config object # # @return [Diffend::Config] def initialize(command: nil, severity: nil, build_path: nil) @log_level = severity build(command, build_path) validate end def logger @logger ||= Diffend::Logger.new(@log_level) end def ignore_errors? @ignore_errors end def development? @development end # Provides diffend commands endpoint url # # @return [String] def commands_url return ENV['DIFFEND_COMMANDS_URL'] if ENV.key?('DIFFEND_COMMANDS_URL') "https://my.diffend.io/api/projects/#{project_id}/bundle/#{command}" end # Provides diffend errors endpoint url # # @return [String] def errors_url return ENV['DIFFEND_ERRORS_URL'] if ENV.key?('DIFFEND_ERRORS_URL') "https://my.diffend.io/api/projects/#{project_id}/errors" end # @param request_id [String] # # @return [String] def track_url(request_id) "https://my.diffend.io/api/projects/#{project_id}/bundle/#{request_id}/track" end private def build(command, build_path) build_path ||= File.expand_path('..', ::Bundler.bin_path) hash = Diffend::Configs::Fetcher.call(logger, plugin_path, build_path) hash['build_path'] = build_path hash['command'] = command || build_command hash.each { |key, value| instance_variable_set(:"@#{key}", value) } end def validate Diffend::Configs::Validator.call(self) end # Command that was run with bundle # # @return [String] def build_command ARGV.first || ::Bundler.feature_flag.default_cli_command.to_s end def plugin_path Pathname.new(File.expand_path('../..', __dir__)) end end end
Version data entries
8 entries across 8 versions & 2 rubygems