Sha256: d5c951edec6d84ac126ab3d9bf67e9e79ebcdcb9810fdd0ffe15b6412853d467

Contents?: true

Size: 1.08 KB

Versions: 66

Compression:

Stored size: 1.08 KB

Contents

module Appsignal
  class CLI
    class Diagnose
      class Utils
        def self.username_for_uid(uid)
          passwd_struct = Etc.getpwuid(uid)
          return unless passwd_struct
          passwd_struct.name
        rescue ArgumentError # rubocop:disable Lint/HandleExceptions
        end

        def self.group_for_gid(gid)
          passwd_struct = Etc.getgrgid(gid)
          return unless passwd_struct
          passwd_struct.name
        rescue ArgumentError # rubocop:disable Lint/HandleExceptions
        end

        def self.read_file_content(path, bytes_to_read)
          file_size = File.size(path)
          if bytes_to_read > file_size
            # When the file is smaller than the bytes_to_read
            # Read the whole file
            offset = 0
            length = file_size
          else
            # When the file is smaller than the bytes_to_read
            # Read the last X bytes_to_read
            length = bytes_to_read
            offset = file_size - bytes_to_read
          end

          IO.binread(path, length, offset)
        end
      end
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
appsignal-3.1.2-java lib/appsignal/cli/diagnose/utils.rb
appsignal-3.1.2 lib/appsignal/cli/diagnose/utils.rb
appsignal-3.1.1-java lib/appsignal/cli/diagnose/utils.rb
appsignal-3.1.1 lib/appsignal/cli/diagnose/utils.rb
appsignal-3.1.0-java lib/appsignal/cli/diagnose/utils.rb
appsignal-3.1.0 lib/appsignal/cli/diagnose/utils.rb
appsignal-3.0.27-java lib/appsignal/cli/diagnose/utils.rb
appsignal-3.0.27 lib/appsignal/cli/diagnose/utils.rb
appsignal-3.0.26-java lib/appsignal/cli/diagnose/utils.rb
appsignal-3.0.26 lib/appsignal/cli/diagnose/utils.rb
appsignal-3.0.25-java lib/appsignal/cli/diagnose/utils.rb
appsignal-3.0.25 lib/appsignal/cli/diagnose/utils.rb
appsignal-3.0.24-java lib/appsignal/cli/diagnose/utils.rb
appsignal-3.0.24 lib/appsignal/cli/diagnose/utils.rb
appsignal-3.0.23-java lib/appsignal/cli/diagnose/utils.rb
appsignal-3.0.23 lib/appsignal/cli/diagnose/utils.rb
appsignal-3.0.22-java lib/appsignal/cli/diagnose/utils.rb
appsignal-3.0.22 lib/appsignal/cli/diagnose/utils.rb
appsignal-3.0.21-java lib/appsignal/cli/diagnose/utils.rb
appsignal-3.0.21 lib/appsignal/cli/diagnose/utils.rb