Class: Vx::Aptly::Repo
- Inherits:
-
Object
- Object
- Vx::Aptly::Repo
- Extended by:
- Mixin::Capture
- Includes:
- Mixin::Capture
- Defined in:
- lib/vx/aptly/repo.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#error ⇒ Object
Returns the value of attribute error.
-
#notice ⇒ Object
Returns the value of attribute notice.
Class Method Summary collapse
Instance Method Summary collapse
- #build_publish(options = {}) ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
-
#initialize(params = {}) ⇒ Repo
constructor
A new instance of Repo.
- #new_record? ⇒ Boolean
- #packages(reload = false) ⇒ Object
- #persisted! ⇒ Object
- #publishes(reload = false) ⇒ Object
- #update ⇒ Object
- #valid? ⇒ Boolean
Methods included from Mixin::Capture
Constructor Details
#initialize(params = {}) ⇒ Repo
Returns a new instance of Repo.
10 11 12 13 14 15 16 17 |
# File 'lib/vx/aptly/repo.rb', line 10 def initialize(params = {}) @attributes = {} params.each do |k,v| if self.respond_to?(:"#{k}=") self.public_send(:"#{k}=", v) end end end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/vx/aptly/repo.rb', line 8 def attributes @attributes end |
#error ⇒ Object
Returns the value of attribute error.
8 9 10 |
# File 'lib/vx/aptly/repo.rb', line 8 def error @error end |
#notice ⇒ Object
Returns the value of attribute notice.
8 9 10 |
# File 'lib/vx/aptly/repo.rb', line 8 def notice @notice end |
Class Method Details
.all ⇒ Object
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/vx/aptly/repo.rb', line 147 def all capture "aptly repo list" do |re| re.lines.inject([]) do |a, line| if line =~ / \* \[(.*)\]/ a << find($1) end a end end end |
.find(name) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/vx/aptly/repo.rb', line 124 def find(name) capture "aptly repo show #{name}" do |re| repo = new(name: name) repo.persisted! re.lines.each do |line| key, value = line.split(":").map(&:strip) case key when 'Comment' repo.comment = value when 'Default Distribution' repo.default_distribution = value when 'Default Component' repo.default_component = value when 'Number of packages' repo.number_of_packages = value.to_i end end repo end end |
Instance Method Details
#build_publish(options = {}) ⇒ Object
112 113 114 115 116 117 118 119 120 |
# File 'lib/vx/aptly/repo.rb', line 112 def build_publish( = {}) [:repo_name] = self.name = { component: default_component, distribution: default_distribution }.merge() RepoPublish.new() end |
#create ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/vx/aptly/repo.rb', line 59 def create line = "aptly repo create" line << " -comment=\"#{comment}\"" if comment line << " -component=\"#{default_component}\"" if default_component line << " -distribution=\"#{default_distribution}\"" if default_distribution line << " #{name}" if name begin capture line do |re| @notice = "The command '#{line}' was successfuly finished with output:\n" @notice << re end persisted! rescue AptlyCommandError => e @error = e end valid? end |
#destroy ⇒ Object
98 99 100 101 102 103 104 105 |
# File 'lib/vx/aptly/repo.rb', line 98 def destroy cmd = "aptly repo drop" cmd << " #{name}" if name capture cmd do |re| @notice = "The command '#{cmd}' was successfuly finished with output:\n" @notice << re end end |
#new_record? ⇒ Boolean
23 24 25 |
# File 'lib/vx/aptly/repo.rb', line 23 def new_record? !@persisted end |
#packages(reload = false) ⇒ Object
31 32 33 34 |
# File 'lib/vx/aptly/repo.rb', line 31 def packages(reload = false) @packages = nil if reload @packages ||= Package.all(self) end |
#persisted! ⇒ Object
19 20 21 |
# File 'lib/vx/aptly/repo.rb', line 19 def persisted! @persisted = true end |
#publishes(reload = false) ⇒ Object
107 108 109 110 |
# File 'lib/vx/aptly/repo.rb', line 107 def publishes(reload = false) @publishes = nil if reload @publishes ||= RepoPublish.for_repo(self) end |
#update ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/vx/aptly/repo.rb', line 79 def update line = "aptly repo edit" line << " -comment=\"#{comment}\"" if comment line << " -component=\"#{default_component}\"" if default_component line << " -distribution=\"#{default_distribution}\"" if default_distribution line << " #{name}" if name begin capture line do |re| @notice = "The command '#{line}' was successfuly finished with output:\n" @notice << re end rescue AptlyCommandError => e @error = e end valid? end |
#valid? ⇒ Boolean
27 28 29 |
# File 'lib/vx/aptly/repo.rb', line 27 def valid? !@error end |