Sha256: af1d0a71b6dd001c161929282436cdfb79b0efc8c50c9a6144780c24b8d433be

Contents?: true

Size: 1.39 KB

Versions: 652

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

module Files
  class SystemProfiler
    def self.uname
      if ::File.exist?("/proc/version")
        ::File.read("/proc/version").strip
      else
        case RbConfig::CONFIG["host_os"]
        when /linux|darwin|bsd|sunos|solaris|cygwin/i
          uname_from_system
        when /mswin|mingw/i
          uname_from_system_ver
        else
          "unknown platform"
        end
      end
    end

    def self.uname_from_system
      (`uname -a 2>/dev/null` || "").strip
    rescue Errno::ENOENT
      "uname executable not found"
    rescue Errno::ENOMEM # couldn't create subprocess
      "uname lookup failed"
    end

    def self.uname_from_system_ver
      (`ver` || "").strip
    rescue Errno::ENOENT
      "ver executable not found"
    rescue Errno::ENOMEM # couldn't create subprocess
      "uname lookup failed"
    end

    def initialize
      @uname = self.class.uname
    end

    def user_agent
      lang_version = "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"

      {
        application: Files.app_info,
        bindings_version: Files::VERSION,
        lang: "ruby",
        lang_version: lang_version,
        platform: RUBY_PLATFORM,
        engine: defined?(RUBY_ENGINE) ? RUBY_ENGINE : "",
        publisher: "Action Verb LLC",
        uname: @uname,
        hostname: Socket.gethostname,
      }.delete_if { |_k, v| v.nil? }
    end
  end
end

Version data entries

652 entries across 652 versions & 1 rubygems

Version Path
files.com-1.1.61 lib/files.com/system_profiler.rb
files.com-1.1.60 lib/files.com/system_profiler.rb
files.com-1.1.59 lib/files.com/system_profiler.rb
files.com-1.1.58 lib/files.com/system_profiler.rb
files.com-1.1.57 lib/files.com/system_profiler.rb
files.com-1.1.56 lib/files.com/system_profiler.rb
files.com-1.1.55 lib/files.com/system_profiler.rb
files.com-1.1.54 lib/files.com/system_profiler.rb
files.com-1.1.53 lib/files.com/system_profiler.rb
files.com-1.1.52 lib/files.com/system_profiler.rb
files.com-1.1.51 lib/files.com/system_profiler.rb
files.com-1.1.50 lib/files.com/system_profiler.rb
files.com-1.1.49 lib/files.com/system_profiler.rb
files.com-1.1.48 lib/files.com/system_profiler.rb
files.com-1.1.47 lib/files.com/system_profiler.rb
files.com-1.1.46 lib/files.com/system_profiler.rb
files.com-1.1.45 lib/files.com/system_profiler.rb
files.com-1.1.44 lib/files.com/system_profiler.rb
files.com-1.1.43 lib/files.com/system_profiler.rb
files.com-1.1.42 lib/files.com/system_profiler.rb