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.28 lib/files.com/system_profiler.rb
files.com-1.1.27 lib/files.com/system_profiler.rb
files.com-1.1.26 lib/files.com/system_profiler.rb
files.com-1.1.25 lib/files.com/system_profiler.rb
files.com-1.1.24 lib/files.com/system_profiler.rb
files.com-1.1.23 lib/files.com/system_profiler.rb
files.com-1.1.22 lib/files.com/system_profiler.rb
files.com-1.1.21 lib/files.com/system_profiler.rb
files.com-1.1.20 lib/files.com/system_profiler.rb
files.com-1.1.19 lib/files.com/system_profiler.rb
files.com-1.1.18 lib/files.com/system_profiler.rb
files.com-1.1.17 lib/files.com/system_profiler.rb
files.com-1.1.16 lib/files.com/system_profiler.rb
files.com-1.1.15 lib/files.com/system_profiler.rb
files.com-1.1.14 lib/files.com/system_profiler.rb
files.com-1.1.13 lib/files.com/system_profiler.rb
files.com-1.1.12 lib/files.com/system_profiler.rb
files.com-1.1.11 lib/files.com/system_profiler.rb
files.com-1.1.10 lib/files.com/system_profiler.rb
files.com-1.1.9 lib/files.com/system_profiler.rb