Class: CIQuantum::Adater::Unfuddle::Changeset

Inherits:
Object
  • Object
show all
Defined in:
lib/ciquantum/adapter/unfuddle/changeset.rb

Constant Summary collapse

FIELDS =
%w(repository_id revision message committer_name committer_date).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Changeset

Returns a new instance of Changeset.

Raises:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ciquantum/adapter/unfuddle/changeset.rb', line 18

def initialize(xml)
  xml = xml.to_s.strip
  raise ChangesetError, 'Changeset XML required!' if xml.empty?

  begin
    @data = Hash.from_xml(xml)
  rescue REXML::ParseException
    raise ChangesetError, 'Invalid XML data!'
  end

  raise ChangesetError, 'Invalid changeset!' unless @data.key?('changeset')

  @xml  = xml
  @data = @data['changeset']

  unless (FIELDS & @data.keys).size == FIELDS.size
    raise ChangesetError, 'Invalid changeset!'
  end

  @commit  = @data['revision']
  @author  = @data['committer_name']
  @message = @data['message']
  @date    = @data['committer_date']
  @repo    = @data['repository_id']
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



11
12
13
# File 'lib/ciquantum/adapter/unfuddle/changeset.rb', line 11

def author
  @author
end

#commitObject (readonly)

Returns the value of attribute commit.



14
15
16
# File 'lib/ciquantum/adapter/unfuddle/changeset.rb', line 14

def commit
  @commit
end

#dateObject (readonly)

Returns the value of attribute date.



13
14
15
# File 'lib/ciquantum/adapter/unfuddle/changeset.rb', line 13

def date
  @date
end

#messageObject (readonly)

Returns the value of attribute message.



12
13
14
# File 'lib/ciquantum/adapter/unfuddle/changeset.rb', line 12

def message
  @message
end

#repoObject (readonly)

Returns the value of attribute repo.



15
16
17
# File 'lib/ciquantum/adapter/unfuddle/changeset.rb', line 15

def repo
  @repo
end

#xmlObject (readonly)

Returns the value of attribute xml.



16
17
18
# File 'lib/ciquantum/adapter/unfuddle/changeset.rb', line 16

def xml
  @xml
end