Skip to content

Commit

Permalink
Read createdBy and authoredBy from the manifest.
Browse files Browse the repository at this point in the history
Return the Agent and list of Agents, respectively.
  • Loading branch information
hainesr committed Jun 28, 2014
1 parent 244100a commit dcf205f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/ro-bundle/file.rb
Expand Up @@ -64,6 +64,14 @@ def created_on
parse_time(:createdOn)
end

# :call-seq:
# created_by -> Agent
#
# Return the Agent that created this Research Object.
def created_by
@created_by ||= Agent.new(manifest["createdBy"])
end

# :call-seq:
# authored_on -> Time
#
Expand All @@ -72,6 +80,16 @@ def authored_on
parse_time(:authoredOn)
end

# :call-seq:
# authored_by -> Agents
#
# Return the list of Agents that authored this Research Object.
def authored_by
@authored_by ||= (manifest["authoredBy"] || []).map do |agent|
Agent.new(agent)
end
end

protected

def manifest
Expand Down
7 changes: 7 additions & 0 deletions test/tc_read.rb
Expand Up @@ -22,8 +22,15 @@ def test_verify
def test_manifest
ROBundle::File.open($hello) do |b|
assert_equal("/", b.id)

assert b.created_on.instance_of?(Time)
assert_nil b.authored_on

creator = b.created_by
assert creator.instance_of?(ROBundle::Agent)

author = b.authored_by
assert author.instance_of?(Array)
end
end

Expand Down

0 comments on commit dcf205f

Please sign in to comment.