lib/gumdrop/data.rb in gumdrop-1.1.1 vs lib/gumdrop/data.rb in gumdrop-1.1.2

- old
+ new

@@ -52,10 +52,22 @@ end base_path= opts.fetch(:base_path, 'page') page_size= opts.fetch(:page_size, 5) Util::Pager.new( data, base_path, page_size ) end + + # Not used internally, but useful for external usage + def parse_file(path, target_ext=nil) + return nil if path.nil? + return nil if File.directory? path + _load_from_file path, target_ext + # if File.directory? path + # _load_from_directory path + # else + # _load_from_file path, target_ext + # end + end private def _cache_dataset(hash, key) hash[key]= load_data(key) #unless @cache.has_key? key @@ -69,11 +81,11 @@ else _load_from_file path end end - def _load_from_file( filename ) - ext=File.extname(filename)[1..-1] + def _load_from_file( filename, target_ext=nil ) + ext= target_ext || File.extname(filename)[1..-1] provider= Data::Provider.for ext case when provider.nil? raise "Unknown data type (#{ext}) for #{filename}" when provider.available? \ No newline at end of file