Reimplemented entries data-structure to Hash.
This commit is contained in:
parent
2125a2f9d5
commit
db3e99e1c9
22
bucket-tool
22
bucket-tool
@ -220,7 +220,7 @@ class Bucket
|
||||
def initialize (clientbucketdir)
|
||||
log "Bucket is being created from #{clientbucketdir}"
|
||||
@bucketdir = clientbucketdir
|
||||
@entries = Array.new
|
||||
@entries = Hash.new
|
||||
load_bucket
|
||||
end
|
||||
|
||||
@ -229,7 +229,7 @@ class Bucket
|
||||
Dir["#{@bucketdir}/**/paths"].each.map{|path| File.dirname(path)}.each do |directory|
|
||||
log "\"#{directory}\" was grabbed from bucket directory. Making new BucketEntry"
|
||||
entry = BucketEntry.new(directory)
|
||||
@entries.push(entry)
|
||||
@entries[entry.hash]=entry
|
||||
log "BucketEntry[#{entry.hash}] was added to @entries Size=#{@entries.count()}"
|
||||
end
|
||||
log "Bucket[#{@bucketdir}] was loaded"
|
||||
@ -244,7 +244,7 @@ end
|
||||
|
||||
def search_entries_paths (bucket)
|
||||
log "user entered"
|
||||
bucket.entries.each do |entry|
|
||||
bucket.entries.each_value do |entry|
|
||||
log "checking Entry[#{entry.hash}]"
|
||||
if entry.path_include? $CONFIG[:search_term]
|
||||
puts entry.inline_info
|
||||
@ -254,23 +254,21 @@ end
|
||||
|
||||
def get_content_of_entry_hash (bucket)
|
||||
log "user entered"
|
||||
bucket.entries.each do |entry|
|
||||
log "checking Entry[#{entry.hash}]"
|
||||
if entry.hash == $CONFIG[:search_term]
|
||||
log "BucketEntry[#{entry.hash}] Matched. Getting contents"
|
||||
puts entry.content
|
||||
exit
|
||||
end
|
||||
if bucket.entries.has_key? $CONFIG[:search_term]
|
||||
puts bucket.entries[$CONFIG[:search_term]].content
|
||||
else
|
||||
puts "There were no entries corresponding to #{$CONFIG[:search_term]}"
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
def list_all_entries (bucket)
|
||||
puts bucket.entries.each.map{|entry| entry.inline_info}.sort.join("\n")
|
||||
puts bucket.entries.each_value.each.map{|entry| entry.inline_info}.sort.join("\n")
|
||||
end
|
||||
|
||||
def list_entry_files (bucket)
|
||||
filenames = Array.new
|
||||
bucket.entries.each do |entry|
|
||||
bucket.entries.each_value do |entry|
|
||||
entry.filepaths.each do |path|
|
||||
if not filenames.include? path
|
||||
filenames.push(path)
|
||||
|
Loading…
Reference in New Issue
Block a user