lib/rvc/fs.rb in rvc-1.3.6 vs lib/rvc/fs.rb in rvc-1.4.0
- old
+ new
@@ -19,30 +19,29 @@
# THE SOFTWARE.
module RVC
class FS
- attr_reader :root, :cur, :marks
+ attr_reader :root, :cur
MARK_PATTERN = /^~(?:([\d\w]*|~|@))$/
REGEX_PATTERN = /^%/
GLOB_PATTERN = /\*/
def initialize root
fail unless root.is_a? RVC::InventoryObject
@root = root
@cur = root
- @marks = {}
end
def display_path
@cur.rvc_path.map { |arc,obj| arc } * '/'
end
def cd dst
fail unless dst.is_a? RVC::InventoryObject
- mark '~', [@cur]
+ $shell.session.set_mark '~', [@cur]
@cur = dst
end
def lookup path
arcs, absolute, trailing_slash = Path.parse path
@@ -69,11 +68,11 @@
[cur.rvc_parent ? cur.rvc_parent : cur]
when '...'
# XXX shouldnt be nil
[(cur.respond_to?(:parent) && cur.parent) ? cur.parent : (cur.rvc_parent || cur)]
when MARK_PATTERN
- if first and objs = @marks[$1]
+ if first and objs = $shell.session.get_mark($1)
objs
else
[]
end
when REGEX_PATTERN
@@ -82,25 +81,20 @@
when GLOB_PATTERN
regex = glob_to_regex arc
cur.children.select { |k,v| k =~ regex }.map { |k,v| v.rvc_link(cur, k); v }
else
# XXX check for ambiguous child
- if first and arc =~ /^\d+$/ and objs = @marks[arc]
+ if first and arc =~ /^\d+$/ and objs = $shell.session.get_mark(arc)
objs
else
if child = cur.traverse_one(arc)
child.rvc_link cur, arc
[child]
else
[]
end
end
end
- end
-
- def mark key, objs
- fail "not an array" unless objs.is_a? Array
- @marks[key] = objs
end
private
def glob_to_regex str