Class: FallCli::Middleware::UploaderBrowser
- Defined in:
- lib/fallcli/middleware/upload_browser.rb
Overview
Check if the client has set-up configuration yet.
Constant Summary collapse
- SPLASH =
%{ '; .' ,':'' :','' '',,.:' '',,,:', '',,,,..,' '',,,,,.'' .':,,,,,....'` ';,,,,,,,..'' '',,,,,,,.....', ':,,,,,,,,...:'. ;',,,,,,,,,......''',,,,,,,,,,.....'' `';,,,,,,,,,,.......',,,,,,,,,,,.......'; ':,,,,,,,,,,,......```,,,,,,,,,,........' '',,,,,,,,,,.....`````,,,,,,,,,......,'` '',,,,,,,,,...`````````,,,,,,,.....:' :',,,,,,,,..```````````.,,,,,....'' `',,,,,,,```````````````,,,,...'; ':,,,.``````````````````,,..'. '',`````````````````````.,'` '::`````````````````````,.', `',,::,``````````````````:,..'' :',,,::::```````````````:::,...'' '',,,,::::,,```````````,::::,....:' ';,,,,,::::,,,.````````::::::,......'` ':,,,,,,::::,,,,,`` ``::::::::,.......': ':,,,,,,,::::,,,,,,. .;;:::::::,........' '',,,,,,::::,,,,,,.`;;::::::::,......;'` .';,,,,::::,,,,,,``,:::::::::,.....'; '',,,::::,,,,,```,,::::::::,...'' `';,:::,,,,,````,,,,::::::,.,': ;':::,,,..````,,,,,::::,,'' '..:,,...````,,,,,,:::,.' '...,....````,,,,,,.:...' ;'.......````,,,,,,....'' ''.....````,,,,,,..;'` :',...````,,,,,,,'; ''`.````,,,,,'' .':````,,,:', ''```,,'' `';`;'. :'' ______ ___ _ _ _____ _ _____ | ___/ _ \\ | | | | / __ \\| | |_ _| | |_ / /_\\ \\| | | | | / \\/| | | | | _|| _ || | | | | | | | | | | | | | | || |____| |___| \\__/\\| |_____| |_ \\_| \\_| |_/\\_____/\\_____/\\____/\\_____/\\___/ V.#{FallCli::VERSION} }
Constants inherited from Base
Base::CLEAR, Base::GREEN, Base::RED, Base::YELLOW
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from FallCli::Middleware::Base
Instance Method Details
#call(env) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/fallcli/middleware/upload_browser.rb', line 77 def call(env) config = env["config"] say SPLASH sleep(2) files = get_files upload_browser = FallCli::UploaderBrowserHelper.new(files) Dispel::Screen.open do |screen| screen.draw show_ui(upload_browser) Dispel::Keyboard.output do |key| case key when :up then upload_browser.position_up when :down then upload_browser.position_down when :enter then file = upload_browser.get_current_file file_name = File.basename(file) filepath = Pathname.new(file).realpath.to_s total_size = File.size(filepath) contents = File.read(filepath) if total_size < 5*1024*1024 env['dropbox-client'].upload file_name, contents else say "Larger than 5MB: Progress Upload" = ::ProgressBar.create(:title => "Upload progress", :format => '%a <%B> %p%% %t', :starting_at => 0, :total => total_size) response = env['dropbox-client'].chunked_upload file_name, File.open(filepath), :chunk_size => 0.1*1024*1024 do |offset, upload| .progress = offset end end say "File uploaded successfully!" when "q" then break end screen.draw show_ui(upload_browser) end end @app.call(env) end |
#get_files ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fallcli/middleware/upload_browser.rb', line 15 def get_files require 'find' files = [] Find.find('.') do |e| if !File.directory?(e) files << e unless e.match /.git/ end end files end |
#show_ui(filelist_obj) ⇒ Object
11 12 13 |
# File 'lib/fallcli/middleware/upload_browser.rb', line 11 def show_ui filelist_obj ["\n", filelist_obj.show_files, "\nCurrent position: #{filelist_obj.position + 1} "].join("\n") end |