| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | require "rubygems" | 
					
						
							| 
									
										
										
										
											2016-10-08 13:25:38 +02:00
										 |  |  | require "hbc/cask_loader" | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  | module Hbc | 
					
						
							|  |  |  |   module Source | 
					
						
							|  |  |  |     class PathBase | 
					
						
							|  |  |  |       # derived classes must define method self.me? | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       def self.path_for_query(query) | 
					
						
							| 
									
										
										
										
											2016-10-14 20:03:34 +02:00
										 |  |  |         Pathname.new(query).sub(/(\.rb)?$/, ".rb") | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       attr_reader :path | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       def initialize(path) | 
					
						
							| 
									
										
										
										
											2016-10-08 13:25:38 +02:00
										 |  |  |         @path = Pathname.new(path).expand_path | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       def load | 
					
						
							| 
									
										
										
										
											2016-10-08 13:25:38 +02:00
										 |  |  |         CaskLoader.load_from_file(@path) | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       def to_s | 
					
						
							|  |  |  |         # stringify to fully-resolved location | 
					
						
							| 
									
										
										
										
											2016-10-08 13:25:38 +02:00
										 |  |  |         @path.to_s | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | end |