Sha256: 80aef00744be7b518a4113f4053d018f4599cd93510418f98a1f847157e4eff4

Contents?: true

Size: 973 Bytes

Versions: 16

Compression:

Stored size: 973 Bytes

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
        end

        def self.group_for_gid(gid)
          passwd_struct = Etc.getgrgid(gid)
          return unless passwd_struct
          passwd_struct.name
        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

16 entries across 16 versions & 1 rubygems

Version Path
appsignal-2.8.4 lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.4-java lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.4.beta.1 lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.4.beta.1-java lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.3 lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.3-java lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.3.beta.1 lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.3.beta.1-java lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.2 lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.2-java lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.1 lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.1-java lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.1.alpha.1-java lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.1.alpha.1 lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.0 lib/appsignal/cli/diagnose/utils.rb
appsignal-2.8.0-java lib/appsignal/cli/diagnose/utils.rb