Class: Medusa::Repository

Inherits:
Object
  • Object
show all
Includes:
Resource
Defined in:
lib/medusa/repository.rb

Overview

Represents a Medusa repository node.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource

#exists?, #id, #uuid

Methods included from Uuidable

#uuid_url

Constructor Details

#initializeRepository

Returns a new instance of Repository.



38
39
40
41
42
43
44
# File 'lib/medusa/repository.rb', line 38

def initialize
  @loading     = false
  @loaded      = false
  @collections = Set.new
  @id          = nil
  @uuid        = nil
end

Class Method Details

.with_id(id) ⇒ Medusa::Repository

Returns a new instance with the given ID. Existence is not checked, so an instance is returned regardless of whether the ID is valid.

Parameters:

  • id (Integer)

    Medusa database ID.

Returns:



19
20
21
22
23
# File 'lib/medusa/repository.rb', line 19

def self.with_id(id)
  repo = Repository.new
  repo.instance_variable_set('@id', id)
  repo
end

.with_uuid(uuid) ⇒ Medusa::Repository

Returns a new instance with the given UUID. Existence is not checked, so an instance is returned regardless of whether the UUID is valid.

Parameters:

  • uuid (String)

    Medusa UUID.

Returns:



32
33
34
35
36
# File 'lib/medusa/repository.rb', line 32

def self.with_uuid(uuid)
  repo = Repository.new
  repo.instance_variable_set('@uuid', uuid)
  repo
end

Instance Method Details

#collectionsEnumerable<Medusa::Collection>

Returns:



49
50
51
52
# File 'lib/medusa/repository.rb', line 49

def collections
  load
  @collections
end

#contact_emailString

Returns:

  • (String)


57
58
59
60
# File 'lib/medusa/repository.rb', line 57

def contact_email
  load
  @contact_email
end

#emailString

Returns:

  • (String)


65
66
67
68
# File 'lib/medusa/repository.rb', line 65

def email
  load
  @email
end

#home_urlString

Returns:

  • (String)


73
74
75
76
# File 'lib/medusa/repository.rb', line 73

def home_url
  load
  @home_url
end

#ldap_admin_domainString

Returns:

  • (String)


81
82
83
84
# File 'lib/medusa/repository.rb', line 81

def ldap_admin_domain
  load
  @ldap_admin_domain
end

#ldap_admin_groupString

Returns:

  • (String)


89
90
91
92
# File 'lib/medusa/repository.rb', line 89

def ldap_admin_group
  load
  @ldap_admin_group
end

#loadObject

Updates the instance with current properties from Medusa.

It should not typically be necessary to use this method publicly.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/medusa/repository.rb', line 107

def load
  return if @loading || @loaded
  @loading           = true
  struct             = fetch_body
  @contact_email     = struct['contact_email']
  @email             = struct['email']
  @home_url          = struct['url']
  @id                = struct['id']
  @ldap_admin_domain = struct['ldap_admin_domain']
  @ldap_admin_group  = struct['ldap_admin_group']
  @title             = struct['title']
  @uuid              = struct['uuid']
  struct['collections'].each do |col_struct|
    @collections << Collection.with_id(col_struct['id'])
  end
  @loaded = true
ensure
  @loading = false
end

#titleString

Returns:

  • (String)


97
98
99
100
# File 'lib/medusa/repository.rb', line 97

def title
  load
  @title
end

#urlString

Returns Absolute URI of the corresponding Medusa resource.

Returns:

  • (String)

    Absolute URI of the corresponding Medusa resource.



130
131
132
133
134
# File 'lib/medusa/repository.rb', line 130

def url
  [Client.configuration[:medusa_base_url].chomp('/'),
   'repositories',
   self.id].join('/')
end