Class: RightPublish::RepoManager

Inherits:
Object
  • Object
show all
Defined in:
lib/right_publish/repo.rb

Constant Summary collapse

@@repository_type_regex =
/\A(\w+)_repo/
@@repository_table =
{}

Class Method Summary collapse

Class Method Details

.get_repository(type) ⇒ Object



11
12
13
# File 'lib/right_publish/repo.rb', line 11

def self.get_repository(type)
  @@repository_table[type].new(type) if @@repository_table[type]
end

.register_repo(repo_type) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/right_publish/repo.rb', line 21

def self.register_repo(repo_type)
  repo_key = repo_type::REPO_KEY

  if repo_type.respond_to?(:new) && @@repository_type_regex.match(repo_key.to_s)
    @@repository_table[repo_key] = repo_type
    RightPublish::Profile.instance.register_section(repo_key, repo_type::REPO_OPTIONS)
  else
    raise TypeError
  end

  nil
end

.repo_typesObject



15
16
17
18
19
# File 'lib/right_publish/repo.rb', line 15

def self.repo_types()
  type_hash = {}
  @@repository_table.each_key { |k| type_hash[@@repository_type_regex.match(k.to_s)[1]] = k }
  type_hash
end