Class: SSC::Handler::Repository
- Inherits:
-
Base
- Object
- Thor
- Base
- SSC::Handler::Repository
show all
- Defined in:
- lib/handlers/repository.rb
Constant Summary
Constants inherited
from Base
Base::API_URL
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Methods included from Helper
included
Instance Method Details
#add(*repo_ids) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/handlers/repository.rb', line 73
def add(*repo_ids)
if options.remote?
require_appliance do |appliance|
response= appliance.add_repository(repo_ids)
say "Added "+( response.collect{|repos| repos.name} ).join(", ")
end
else
repo_file= RepositoryFile.new
repo_ids.each {|id| repo_file.push('add', id)}
repo_file.save
say "Marked the following for addition #{repo_ids.join(", ")}"
end
end
|
#import(url, name) ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/handlers/repository.rb', line 107
def import(url, name)
if options.remote?
repository= StudioApi::Repository.import(url, name)
say "Added #{repository.name} at #{url}"
else
repo_file= RepositoryFile.new
repo_file.push('import', {"name" => name, "url" => url})
repo_file.save
say "Marked #{name} for import"
end
end
|
#list ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/handlers/repository.rb', line 53
def list
repo_file= RepositoryFile.new
list= if options.remote? || repo_file.empty_list?
require_appliance do |appliance|
appliance.repositories.collect do |repo|
repo_file.push('list', { repo.id => { 'name' => repo.name,
'type' => repo.type,
'base_system' => repo.base_system}})
end
repo_file.save
end
else
repo_file['list']
end
say list.to_yaml
end
|
#remove(*repo_ids) ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/handlers/repository.rb', line 90
def remove(*repo_ids)
if options.remote?
require_appliance do |appliance|
response= appliance.remove_repository(repo_ids)
say "Removed #{repo_ids.join(", ")}"
end
else
repo_file= RepositoryFile.new
repo_ids.each {|id| repo_file.push('remove', id)}
repo_file.save
say "Marked the following for removal #{repo_ids.join(", ")}"
end
end
|
#search(search_string) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/handlers/repository.rb', line 37
def search(search_string)
params= {:filter => search_string}
params= params.merge({:base_system => options.base_system}) if options.base_system
repos= StudioApi::Repository.find(:all, :params => params)
repos.collect do |repo|
if repo.respond_to?('base_url')
say "#{repo.id}.) #{repo.name}: #{repo.base_url}
#{[repo.matches.attributes["software_name"]].flatten.join(', ')}\n"
end
end
end
|