| 
									
										
										
										
											2013-02-06 22:49:43 -06:00
										 |  |  | require 'version' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  | module OS | 
					
						
							|  |  |  |   module Mac | 
					
						
							|  |  |  |     class Version < ::Version | 
					
						
							|  |  |  |       SYMBOLS = { | 
					
						
							| 
									
										
										
										
											2014-06-03 13:27:57 -04:00
										 |  |  |         :yosemite      => '10.10', | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         :mavericks     => '10.9', | 
					
						
							|  |  |  |         :mountain_lion => '10.8', | 
					
						
							|  |  |  |         :lion          => '10.7', | 
					
						
							|  |  |  |         :snow_leopard  => '10.6', | 
					
						
							|  |  |  |         :leopard       => '10.5', | 
					
						
							|  |  |  |         :tiger         => '10.4', | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2013-06-15 19:39:27 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |       def self.from_symbol(sym) | 
					
						
							|  |  |  |         new(SYMBOLS.fetch(sym)) | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2013-06-15 19:39:27 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-02 20:29:20 -05:00
										 |  |  |       def initialize(*args) | 
					
						
							|  |  |  |         super | 
					
						
							|  |  |  |         @comparison_cache = {} | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |       def <=>(other) | 
					
						
							| 
									
										
										
										
											2014-04-02 20:29:20 -05:00
										 |  |  |         @comparison_cache.fetch(other) do | 
					
						
							| 
									
										
										
										
											2014-06-03 11:32:26 -05:00
										 |  |  |           v = SYMBOLS.fetch(other) { other.to_s } | 
					
						
							| 
									
										
										
										
											2014-04-02 20:29:20 -05:00
										 |  |  |           @comparison_cache[other] = super(Version.new(v)) | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2013-06-14 11:56:33 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |       def to_sym | 
					
						
							| 
									
										
										
										
											2014-06-03 11:32:26 -05:00
										 |  |  |         SYMBOLS.invert.fetch(@version) { :dunno } | 
					
						
							| 
									
										
										
										
											2013-06-14 14:47:16 -07:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2013-06-15 19:40:42 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |       def pretty_name | 
					
						
							|  |  |  |         to_sym.to_s.split('_').map(&:capitalize).join(' ') | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2013-06-15 19:40:42 -05:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2013-02-06 22:49:43 -06:00
										 |  |  |   end | 
					
						
							|  |  |  | end |