Sha256: a49df1ab34725b8378f6f2ead95dace9a0e9c362ecbef5fd31948f0dea91d7d1
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
module ActiveScripts class OperatingSystem # INFO: ActiveScripts::OperatingSystem contains code that is # for retrieving and validating operating systems. OPERATING_SYSTEMS = Dir.entries("#{File.dirname(__FILE__)}/preparations") .drop(2) .reject { |f| ["base.rb"].include?(f) } .map { |f| File.basename(f, ".rb").to_sym } attr_accessor :operating_system def initialize @operating_system = :unknown end def self.find new.find end def find generate_operating_system! assert_valid_operating_system! return(@operating_system) end private def assert_valid_operating_system! unless OPERATING_SYSTEMS.include?(@operating_system) raise ArgumentError, "Unknown operating system: #{@operating_system.inspect}. Valid operating systems are: #{OPERATING_SYSTEMS.map(&:inspect).join(', ')}" end end def generate_operating_system! host_os = RbConfig::CONFIG['host_os'] @operating_system = case host_os when /freebsd/ :freebsd when /linux/ :linux when /darwin|mac os|mac os x/ :macosx when /solaris|bsd/ :unix when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ :windows else ask("== Which operating system? ", lambda { |str| str.strip.downcase.to_sym }) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_scripts-0.1.0 | lib/active_scripts/operating_system.rb |