Sha256: 1ca759df3b79bd69fde9e46e10f53bfa3cc5ef15201e1fa742c6c9226b26785b

Contents?: true

Size: 1.18 KB

Versions: 37

Compression:

Stored size: 1.18 KB

Contents

module Kubes::Compiler::Shared::Helpers
  class Deprecated
    def built_image
      puts "DEPRECATED: built_image is deprecated, use docker_image helper instead.".color(:yellow)
      print_source
    end

    def error_info
      error_info = caller.find { |l| l.include?('.kubes/resources') }
      path, line_number, _ = error_info.split(':')
      {path: path, line_number: line_number}
    end

    def print_source
      info = error_info
      path = info[:path]
      line_number = info[:line_number].to_i

      pretty_path = path.sub("#{Kubes.root}/",'')
      puts "Here's the line in #{pretty_path} that calls built_image:\n\n"

      contents = IO.read(path)
      content_lines = contents.split("\n")
      context = 5 # lines of context
      top, bottom = [line_number-context-1, 0].max, line_number+context-1
      lpad = content_lines.size.to_s.size
      content_lines[top..bottom].each_with_index do |line_content, index|
        current_line = top+index+1
        if current_line == line_number
          printf("%#{lpad}d %s\n".color(:red), current_line, line_content)
        else
          printf("%#{lpad}d %s\n", current_line, line_content)
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
kubes-0.7.5 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.7.4 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.7.3 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.7.2 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.7.1 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.7.0 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.6.8 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.6.7 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.6.6 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.6.5 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.6.4 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.6.3 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.6.2 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.6.1 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.6.0 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.5.1 lib/kubes/compiler/shared/helpers/deprecated.rb
kubes-0.5.0 lib/kubes/compiler/shared/helpers/deprecated.rb