Sha256: af1d0a71b6dd001c161929282436cdfb79b0efc8c50c9a6144780c24b8d433be

Contents?: true

Size: 1.39 KB

Versions: 659

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

659 entries across 659 versions & 1 rubygems

Version Path
files.com-1.1.8 lib/files.com/system_profiler.rb
files.com-1.1.7 lib/files.com/system_profiler.rb
files.com-1.1.6 lib/files.com/system_profiler.rb
files.com-1.1.5 lib/files.com/system_profiler.rb
files.com-1.1.4 lib/files.com/system_profiler.rb
files.com-1.1.3 lib/files.com/system_profiler.rb
files.com-1.1.2 lib/files.com/system_profiler.rb
files.com-1.1.1 lib/files.com/system_profiler.rb
files.com-1.1.0 lib/files.com/system_profiler.rb
files.com-1.0.495 lib/files.com/system_profiler.rb
files.com-1.0.494 lib/files.com/system_profiler.rb
files.com-1.0.493 lib/files.com/system_profiler.rb
files.com-1.0.492 lib/files.com/system_profiler.rb
files.com-1.0.491 lib/files.com/system_profiler.rb
files.com-1.0.490 lib/files.com/system_profiler.rb
files.com-1.0.489 lib/files.com/system_profiler.rb
files.com-1.0.488 lib/files.com/system_profiler.rb
files.com-1.0.487 lib/files.com/system_profiler.rb
files.com-1.0.486 lib/files.com/system_profiler.rb
files.com-1.0.485 lib/files.com/system_profiler.rb