Sha256: 94976c2a657aa54a20661c235b252a88a5442fe64b95e453af8012bdbcb74a2c

Contents?: true

Size: 1.7 KB

Versions: 15

Compression:

Stored size: 1.7 KB

Contents

# -*- encoding: UTF-8 -*-

module CSD
  module Extensions
    # This namespace is given to all extensions made to third-party Gems.
    #
    module Gem
      # This module comprises extensions to the Array object.
      #
      module Platform
  
        # This method returns a human-readable string for the current OS and CPU architecture.
        #
        def humanize
          version_string = version ? ", version #{version}" : ''
          "#{os} (#{cpu}#{version_string})"
        end
        
        # Determines whether the OS is Debian or Ubuntu. Returns +true+ or +false+.
        #
        def debian?
          kernel_version and kernel_version =~ /Debian|Ubuntu/
        end
        
        # Determines whether the OS is Ubuntu. Returns +true+ or +false+.
        #
        def ubuntu?
          kernel_version and kernel_version =~ /Ubuntu/
        end
        
        # Determines whether the OS is Ubuntu 10. Returns +true+ or +false+.
        #
        def ubuntu_10?
          ubuntu? and %w{ 2.6.32-21-generic 2.6.32-22-generic }.include?(kernel_release)
        end
        
        # On linux systems, this method returns the current kernel version.
        #
        def kernel_version
          Cmd.run('uname --kernel-version', :internal => true, :force_in_reveal => true).output.to_s.chop if os == 'linux'
        end
        
        # On linux systems, this method returns the current kernel release.
        #
        def kernel_release
          Cmd.run('uname --kernel-release', :internal => true, :force_in_reveal => true).output.to_s.chop if os == 'linux'
        end
  
      end
    end
  end
end

module Gem #:nodoc:
  class Platform #:nodoc:
    include CSD::Extensions::Gem::Platform
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
csd-0.4.3 lib/csd/extensions/gem/platform.rb
csd-0.4.2 lib/csd/extensions/gem/platform.rb
csd-0.4.1 lib/csd/extensions/gem/platform.rb
csd-0.4.0 lib/csd/extensions/gem/platform.rb
csd-0.3.7 lib/csd/extensions/gem/platform.rb
csd-0.3.6 lib/csd/extensions/gem/platform.rb
csd-0.3.5 lib/csd/extensions/gem/platform.rb
csd-0.3.4 lib/csd/extensions/gem/platform.rb
csd-0.3.3 lib/csd/extensions/gem/platform.rb
csd-0.3.2 lib/csd/extensions/gem/platform.rb
csd-0.3.1 lib/csd/extensions/gem/platform.rb
csd-0.3.0 lib/csd/extensions/gem/platform.rb
csd-0.2.2 lib/csd/extensions/gem/platform.rb
csd-0.2.1 lib/csd/extensions/gem/platform.rb
csd-0.2.0 lib/csd/extensions/gem/platform.rb