Class: ReaPack::Index::Version
Constant Summary
collapse
- AUTHOR =
'author'.freeze
- TIME =
'time'.freeze
Constants inherited
from NamedNode
NamedNode::NAME_ATTR
Instance Attribute Summary
Attributes inherited from NamedNode
#node
Instance Method Summary
collapse
Methods inherited from NamedNode
#children, create, #empty?, fetch, find_all, find_one, #is_new?, #name, #remove, tag
Constructor Details
#initialize(node) ⇒ Version
Returns a new instance of Version.
8
9
10
11
|
# File 'lib/reapack/index/version.rb', line 8
def initialize(node)
super
@changelog = Changelog.new @node
end
|
Instance Method Details
#add_source(src) ⇒ Object
68
69
70
71
72
|
# File 'lib/reapack/index/version.rb', line 68
def add_source(src)
src.make_node @node
@dirty = true
end
|
#author ⇒ Object
21
22
23
|
# File 'lib/reapack/index/version.rb', line 21
def author
@node[AUTHOR].to_s
end
|
#author=(new_author) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/reapack/index/version.rb', line 25
def author=(new_author)
new_author ||= String.new
return if author == new_author
if new_author.empty?
@node.remove_attribute AUTHOR
else
@node[AUTHOR] = new_author
end
@dirty = true
end
|
#changelog=(new_text) ⇒ Object
17
18
19
|
# File 'lib/reapack/index/version.rb', line 17
def changelog=(new_text)
@changelog.text = new_text
end
|
#modified? ⇒ Boolean
13
14
15
|
# File 'lib/reapack/index/version.rb', line 13
def modified?
super || @changelog.modified?
end
|
#replace_sources ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/reapack/index/version.rb', line 54
def replace_sources
was_dirty = @dirty
old_sources = hash_sources children(Source::TAG)
.each {|node| node.remove }
yield
new_sources = hash_sources children(Source::TAG)
@dirty = old_sources != new_sources unless was_dirty
raise Error, 'no files provided' if new_sources.empty?
end
|
#time ⇒ Object
39
40
41
|
# File 'lib/reapack/index/version.rb', line 39
def time
Time.parse @node[TIME] if @node.has_attribute? TIME
end
|
#time=(new_time) ⇒ Object
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/reapack/index/version.rb', line 43
def time=(new_time)
return if new_time == time
if new_time.nil?
@node.remove_attribute TIME
else
@node[TIME] = new_time.utc.iso8601
end
@dirty = true
end
|