Sha256: af1d0a71b6dd001c161929282436cdfb79b0efc8c50c9a6144780c24b8d433be

Contents?: true

Size: 1.39 KB

Versions: 655

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

655 entries across 655 versions & 1 rubygems

Version Path
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
files.com-1.1.41 lib/files.com/system_profiler.rb
files.com-1.1.40 lib/files.com/system_profiler.rb
files.com-1.1.39 lib/files.com/system_profiler.rb
files.com-1.1.38 lib/files.com/system_profiler.rb
files.com-1.1.37 lib/files.com/system_profiler.rb
files.com-1.1.36 lib/files.com/system_profiler.rb
files.com-1.1.35 lib/files.com/system_profiler.rb
files.com-1.1.34 lib/files.com/system_profiler.rb
files.com-1.1.33 lib/files.com/system_profiler.rb
files.com-1.1.32 lib/files.com/system_profiler.rb
files.com-1.1.31 lib/files.com/system_profiler.rb
files.com-1.1.30 lib/files.com/system_profiler.rb
files.com-1.1.29 lib/files.com/system_profiler.rb
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