Class: DmSvn::Svn::Node
- Inherits:
-
Object
- Object
- DmSvn::Svn::Node
- 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
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#body ⇒ Object
Body of the node (nil for a directory).
-
#directory? ⇒ Boolean
Is the Node a directory?.
-
#file? ⇒ Boolean
Is the Node a file?.
-
#fs_path ⇒ Object
Shortened path (from Changeset#fs_path).
-
#initialize(changeset, path) ⇒ Node
constructor
A new instance of Node.
-
#properties ⇒ Object
Properties of the node.
-
#short_path ⇒ Object
Shortened path (from Changeset#short_path).
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
#path ⇒ Object (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
#body ⇒ Object
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?
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?
45 46 47 |
# File 'lib/dm-svn/svn/node.rb', line 45 def file? repos.stat(fs_path, revision).file? end |
#fs_path ⇒ Object
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 |
#properties ⇒ Object
Properties of the node. The properties are accessed from three sources, listed by order of precedence:
-
YAML properties, either in meta.yml (directories), or at the beginning of a file, between “—” and “…” lines.
-
Properties stored in subversion’s property mechanism.
-
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_path ⇒ Object
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 |