module Path
Public Class Methods
Source
# File lib/rbbt/resource/path/refactor.rb, line 122 def self.get_extension(path) path.match(/\.([^\.\/]{1,5})$/)[1] end
Public Instance Methods
Source
# File lib/rbbt/resource/path/refactor.rb, line 90 def all_fields self.open do |stream| TSV.parse_header(stream)["all_fields"] end end
Source
# File lib/rbbt/resource/path/refactor.rb, line 33 def basename Path.setup(File.basename(self), self.resource, self.pkgdir) end
def index(options = {})
TSV.index(self.produce, **options)
end
Source
# File lib/rbbt/resource/path/refactor.rb, line 138 def doc_file(relative_to = 'lib') if located? lib_dir = Path.caller_lib_dir(self, relative_to) relative_file = File.join( 'doc', self.sub(lib_dir,'')) Path.setup File.join(lib_dir, relative_file) , @pkgdir, @resource else Path.setup File.join('doc', self) , @pkgdir, @resource end end
Source
# File lib/rbbt/resource/path/refactor.rb, line 86 def fields TSV.parse_header(self.open).fields end
Source
# File lib/rbbt/resource/path/refactor.rb, line 96 def identifier_file_path if self.dirname.identifiers.exists? self.dirname.identifiers else nil end end
Source
# File lib/rbbt/resource/path/refactor.rb, line 104 def identifier_files if identifier_file_path.nil? [] else [identifier_file_path] end end
Source
# File lib/rbbt/resource/path/refactor.rb, line 60 def keys(field = 0, sep = "\t") Open.read(self.produce.find).split("\n").collect{|l| next if l =~ /^#/; l.split(sep, -1)[field]}.compact end
Source
# File lib/rbbt/resource/path/refactor.rb, line 70 def pipe_to(cmd, options = {}) CMD.cmd(cmd, {:in => self.open, :pipe => true}.merge(options)) end
Source
# File lib/rbbt/resource/path/refactor.rb, line 78 def pos_index(pos, options = {}) TSV.pos_index(self.produce, pos, options) end
Source
# File lib/rbbt/resource/path/refactor.rb, line 74 def range_index(start, eend, options = {}) TSV.range_index(self.produce, start, eend, options) end
Source
# File lib/rbbt/resource/path/refactor.rb, line 117 def remove_extension(new_extension = nil) self.sub(/\.[^\.\/]{1,5}$/,'') end
Source
# File lib/rbbt/resource/path/refactor.rb, line 126 def replace_extension(new_extension = nil, multiple = false) if String === multiple new_path = self.sub(/(\.[^\.\/]{1,5})(.#{multiple})?$/,'') elsif multiple new_path = self.sub(/(\.[^\.\/]{1,5})+$/,'') else new_path = self.sub(/\.[^\.\/]{1,5}$/,'') end new_path = new_path + "." + new_extension.to_s self.annotate(new_path) end
Source
# File lib/rbbt/resource/path/refactor.rb, line 112 def set_extension(new_extension = nil) new_path = self + "." + new_extension.to_s self.annotate(new_path) end
Source
# File lib/rbbt/resource/path/refactor.rb, line 148 def source_for_doc_file(relative_to = 'lib') if located? lib_dir = Path.caller_lib_dir(Path.caller_lib_dir(self, 'doc'), relative_to) relative_file = self.sub(/(.*\/)doc\//, '\1').sub(lib_dir + "/",'') file = File.join(lib_dir, relative_file) if not File.exist?(file) file= Dir.glob(file.sub(/\.[^\.\/]+$/, '.*')).first end Path.setup file, @pkgdir, @resource else relative_file = self.sub(/^doc\//, '\1') if not File.exist?(relative_file) relative_file = Dir.glob(relative_file.sub(/\.[^\.\/]+$/, '.*')).first end Path.setup relative_file , @pkgdir, @resource end end
Source
# File lib/rbbt/resource/path/refactor.rb, line 82 def to_yaml(*args) self.to_s.to_yaml(*args) end
Source
# File lib/rbbt/resource/path/refactor.rb, line 56 def traverse(options = {}, &block) TSV::Parser.traverse(self.open, options, &block) end
def tsv_options(options = {})
self.open do |stream| TSV::Parser.new(stream, options).options end
end
Source
# File lib/rbbt/resource/path/refactor.rb, line 64 def yaml self.open do |f| YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(f) : YAML.load(f) end end