Spec-Zone.ru › Ruby 2.6

класс Bundler::Dsl::DSLError

Родитель:
GemfileError

Атрибуты

backtrace[R]

@return [Исключение] стек вызовов исключения, поднятого

evaluation of the dsl file.
description[R]

@return [Строка] описание, которое должно быть представлено пользователю.

dsl_path[R]

@return [Строка] путь к файлу dsl, вызвавшему исключение.

Публичные методы класса

new(description, dsl_path, backtrace, contents = nil) Показать исходный код
# File lib/bundler/dsl.rb, line 526
def initialize(description, dsl_path, backtrace, contents = nil)
  @status_code = $!.respond_to?(:status_code) && $!.status_code

  @description = description
  @dsl_path    = dsl_path
  @backtrace   = backtrace
  @contents    = contents
end

@param [Исключение] стек вызовов @см backtrace @param [Строка] dsl_path @см dsl_path

Публичные методы экземпляра

contents() Показать исходный код
# File lib/bundler/dsl.rb, line 542
def contents
  @contents ||= begin
    dsl_path && File.exist?(dsl_path) && File.read(dsl_path)
  end
end

@return [Строка] содержимое DSL, вызвавшее исключение

be raised.
status_code() Показать исходный код
# File lib/bundler/dsl.rb, line 535
def status_code
  @status_code || super
end
Вызов метода суперкласса
to_s() Показать исходный код
# File lib/bundler/dsl.rb, line 566
def to_s
  @to_s ||= begin
    trace_line, description = parse_line_number_from_description

    m = String.new("\n[!] ")
    m << description
    m << ". Bundler cannot continue.\n"

    return m unless backtrace && dsl_path && contents

    trace_line = backtrace.find {|l| l.include?(dsl_path.to_s) } || trace_line
    return m unless trace_line
    line_numer = trace_line.split(":")[1].to_i - 1
    return m unless line_numer

    lines      = contents.lines.to_a
    indent     = " #  "
    indicator  = indent.tr("#", ">")
    first_line = line_numer.zero?
    last_line  = (line_numer == (lines.count - 1))

    m << "\n"
    m << "#{indent}from #{trace_line.gsub(/:in.*$/, "")}\n"
    m << "#{indent}-------------------------------------------\n"
    m << "#{indent}#{lines[line_numer - 1]}" unless first_line
    m << "#{indicator}#{lines[line_numer]}"
    m << "#{indent}#{lines[line_numer + 1]}" unless last_line
    m << "\n" unless m.end_with?("\n")
    m << "#{indent}-------------------------------------------\n"
  end
end

Сообщение об исключении содержит содержимое podspec для строки, которая сгенерировала исходное исключение.

@пример Вывод

Invalid podspec at `RestKit.podspec` - undefined method
`exclude_header_search_paths=' for #<Pod::Specification for
`RestKit/Network (0.9.3)`>

    from spec-repos/master/RestKit/0.9.3/RestKit.podspec:36
    -------------------------------------------
        # because it would break: #import <CoreData/CoreData.h>
 >      ns.exclude_header_search_paths = 'Code/RestKit.h'
      end
    -------------------------------------------

@return [Строка] сообщение об исключении.

Приватные методы экземпляра

parse_line_number_from_description() Показать исходный код
# File lib/bundler/dsl.rb, line 600
def parse_line_number_from_description
  description = self.description
  if dsl_path && description =~ /((#{Regexp.quote File.expand_path(dsl_path)}|#{Regexp.quote dsl_path.to_s}):\d+)/
    trace_line = Regexp.last_match[1]
    description = description.sub(/#{Regexp.quote trace_line}:\s*/, "").sub("\n", " - ")
  end
  [trace_line, description]
end

Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API