lib/d3/puppytime/puppy_queue.rb in depot3-3.0.8 vs lib/d3/puppytime/puppy_queue.rb in depot3-3.0.9
- old
+ new
@@ -21,13 +21,16 @@
### language governing permissions and limitations under the Apache License.
###
###
+###
module D3
module PuppyTime
+
### PuppyQ - the current queue of pending puppy installs.
+ ###
### This class only has one real value: A hash of
### PendingPuppy objects, keyed by basename.
### But, PendingPuppies can be added and removed
### and the queue can be read and written to disk
###
@@ -43,10 +46,11 @@
DFT_NOTIFICATION_FREQUENCY = 7
################# Class Methods #################
+
################# Attributes #################
# the queue of PendingPuppy objects
# A hash, keyed by basename.
attr_reader :q
@@ -75,21 +79,25 @@
end
end # read_q
### Save the current q out to disk
###
+ ### @return [void]
+ ###
def save_q
D3.log "Saving puppy queue", :debug
if @q.empty?
D3.log "Puppy queue is empty, deleting from disk", :debug
- QUEUE_FILE.delete
+ QUEUE_FILE.delete if QUEUE_FILE.exist?
else
QUEUE_FILE.jss_save YAML.dump(@q)
D3.log "Puppy queue saved to disk", :debug
end
end # save_q
+ ### An array of basenames for all pending puppies.
+ ###
### @return [Array<String>] the basenames of the pending puppies
###
def pups
@q.keys
end