Class: Vman::Menu
- Inherits:
-
Object
- Object
- Vman::Menu
- Defined in:
- lib/vman/menu.rb
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(config) ⇒ Menu
constructor
A new instance of Menu.
- #list ⇒ Object
- #retrieve ⇒ Object
- #show ⇒ Object
- #store ⇒ Object
- #version ⇒ Object
- #versions ⇒ Object
Constructor Details
Instance Method Details
#delete ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'lib/vman/menu.rb', line 79 def delete obj_versions = get_versions @prompt.select("Select a version to delete") do |prompt| obj_versions.each do |v| prompt.choice "#{v.id} (#{v.get.last_modified})", -> { prompt_delete(v) } end end end |
#list ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/vman/menu.rb', line 70 def list objects = @s3.list @prompt.ok("All current objects in bucket:") objects.each_with_index do |obj, i| @prompt.say("#{i+1}. #{obj.key}") end end |
#retrieve ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/vman/menu.rb', line 26 def retrieve obj_versions = get_versions @prompt.select("Select a version to retrieve") do |prompt| obj_versions.each do |v| prompt.choice "#{v.id} (#{v.get.last_modified})", -> { name = v.object_key + '_' + v.id download(v, name) @prompt.ok("#{name} downloaded to working directory") } end end end |
#show ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vman/menu.rb', line 15 def show @prompt.select('Select an action') do |p| p.choice "Retrieve an object", -> { retrieve } p.choice "Store an object", -> { store } p.choice "List all versions of an object", -> { versions } p.choice "Show current version of an object", -> { version } p.choice "List all objects", -> { list } p.choice "Delete a version of an object", -> { delete } end end |
#store ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/vman/menu.rb', line 40 def store file = prompt_file key = File.basename(file) stored_file = @s3.store(file, key) if stored_file && stored_file.class == Aws::S3::Object @prompt.ok("Successfully uploaded \"#{key}\" to S3") else @prompt.error("Error uploading \"#{key}\" to S3") end end |
#version ⇒ Object
63 64 65 66 67 68 |
# File 'lib/vman/menu.rb', line 63 def version obj_version = get_version @prompt.ok("Current version for #{obj_version.object_key}:") @prompt.say("#{obj_version.get.version_id} (#{obj_version.get.last_modified})") end |
#versions ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/vman/menu.rb', line 52 def versions obj_versions = get_versions @prompt.ok("Total number of versions: #{obj_versions.count}") obj_versions.each do |v| msg = " " + v.id + " (#{v.last_modified})" msg[0] = "•" if v.is_latest @prompt.say("#{msg}") end end |