Sha256: af1d0a71b6dd001c161929282436cdfb79b0efc8c50c9a6144780c24b8d433be

Contents?: true

Size: 1.39 KB

Versions: 651

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

651 entries across 651 versions & 1 rubygems

Version Path
files.com-1.0.17 lib/files.com/system_profiler.rb
files.com-1.0.16 lib/files.com/system_profiler.rb
files.com-1.0.15 lib/files.com/system_profiler.rb
files.com-1.0.14 lib/files.com/system_profiler.rb
files.com-1.0.13 lib/files.com/system_profiler.rb
files.com-1.0.12 lib/files.com/system_profiler.rb
files.com-1.0.11 lib/files.com/system_profiler.rb
files.com-1.0.10 lib/files.com/system_profiler.rb
files.com-1.0.9 lib/files.com/system_profiler.rb
files.com-1.0.8 lib/files.com/system_profiler.rb
files.com-1.0.7 lib/files.com/system_profiler.rb