Class: DmSvn::Svn::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/dm-svn/svn/node.rb

Overview

A Node (file or directory) at a path and revision [Changeset]. In particular, this class exists to determine the type (file or directory) of the node and retrieve the body of a node (for files), and other properties, either stored in yaml or a Subversion properties

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(changeset, path) ⇒ Node

Returns a new instance of Node.



12
13
14
# File 'lib/dm-svn/svn/node.rb', line 12

def initialize(changeset, path)
  @changeset, @path = changeset, path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/dm-svn/svn/node.rb', line 10

def path
  @path
end

Instance Method Details

#bodyObject

Body of the node (nil for a directory)



27
28
29
30
31
32
# File 'lib/dm-svn/svn/node.rb', line 27

def body
  return nil unless file?
  has_yaml_props? ?
    yaml_split[1] :
    data[0]
end

#directory?Boolean

Is the Node a directory?

Returns:

  • (Boolean)


50
51
52
# File 'lib/dm-svn/svn/node.rb', line 50

def directory?
  repos.stat(fs_path, revision).directory?
end

#file?Boolean

Is the Node a file?

Returns:

  • (Boolean)


45
46
47
# File 'lib/dm-svn/svn/node.rb', line 45

def file?
  repos.stat(fs_path, revision).file?
end

#fs_pathObject

Shortened path (from Changeset#fs_path)



22
23
24
# File 'lib/dm-svn/svn/node.rb', line 22

def fs_path
  @changeset.fs_path(@path)
end

#propertiesObject

Properties of the node. The properties are accessed from three sources, listed by order of precedence:

  1. YAML properties, either in meta.yml (directories), or at the beginning of a file, between “—” and “…” lines.

  2. Properties stored in subversion’s property mechanism.

  3. svn_updated_ as determined by revision properties.



40
41
42
# File 'lib/dm-svn/svn/node.rb', line 40

def properties
  rev_properties.merge(svn_properties).merge(yaml_properties)
end

#short_pathObject

Shortened path (from Changeset#short_path)



17
18
19
# File 'lib/dm-svn/svn/node.rb', line 17

def short_path
  @changeset.short_path(@path)
end