Sha256: 58f9c6d209d5b409c9a87f9c0ad057952fb0916a2b0b7751ce4027a72a68b44c

Contents?: true

Size: 742 Bytes

Versions: 8

Compression:

Stored size: 742 Bytes

Contents

require 'rbconfig'

module Dirwatch
  module OsFetcher
    AVAILABLE = [
      WINDOWS = :windows,
      MAC     = :mac,
      LINUX   = :linux,
    ].sort.freeze

    class << self
      def operating_system
        case host_os
        when /mswin|msys|mingw|cygwin|bccwin|wince|emc|win32|dos/
          WINDOWS
        when /darwin|mac os/
          MAC
        when /linux/
          LINUX
        else
          raise OsNotSupportedError.new host_os, AVAILABLE
        end
      end

      alias fetch operating_system

      AVAILABLE.each do |os|
        define_method("#{os}?") do
          operating_system == os
        end
      end

      private

      def host_os
        RbConfig::CONFIG['host_os']
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dirwatch-0.0.9 lib/dirwatch/os_fetcher.rb
dirwatch-0.0.8 lib/dirwatch/os_fetcher.rb
dirwatch-0.0.7 lib/dirwatch/os_fetcher.rb
dirwatch-0.0.6 lib/dirwatch/os_fetcher.rb
dirwatch-0.0.5 lib/dirwatch/os_fetcher.rb
dirwatch-0.0.4 lib/dirwatch/os_fetcher.rb
dirwatch-0.0.3 lib/dirwatch/os_fetcher.rb
dirwatch-0.0.2 lib/dirwatch/os_fetcher.rb