Class: Mushy::Screenshot
- Defined in:
- lib/mushy/fluxs/screenshot.rb
Instance Attribute Summary
Attributes inherited from Flux
#config, #flow, #id, #masher, #parent_fluxs, #subscribed_to, #type
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Browser
#get_the_cookies_from, #get_the_headers_from, #process
Methods inherited from Flux
#convert_this_to_an_array, #convert_to_symbolized_hash, #execute, #execute_single_event, #group_these_results, #guard, #ignore_these_results, inherited, #initialize, #join_these_results, #limit_these_results, #merge_these_results, #model_these_results, #outgoing_split_these_results, #process, #shape_these, #sort_these_results, #standardize_these
Constructor Details
This class inherits a constructor from Mushy::Flux
Class Method Details
.details ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/mushy/fluxs/screenshot.rb', line 5 def self.details details = Browser.details details[:name] = 'Screenshot' details[:description] = 'Take a screenshot of the browser. This works the same as the Browser, but with a screenshot at the end.' details[:config].merge!(Mushy::WriteFile.file_saving_config.tap do |x| x[x.keys.first][:value] = 'file.jpg' end) details[:config][:quality] = { description: 'The quality of the image, a value beteen 0-100. Only applies to jpg.', type: 'integer', shrink: true, value: '', } details[:config][:full] = { description: 'Take a screenshot of the entire page. If false, the screenshot is limited to the viewport.', type: 'boolean', shrink: true, value: '', } details.tap do |config| config[:examples] = { "Screenshot of google.com" => { description: 'This will open https://www.google.com and take a screenshot.', config: { url: "https://www.google.com", file: 'file.jpg' }, result: { url: "https://www.google.com/", status: 200, title: "Google", cookies: [ { name: "1P_JAR", value: "2021-10-07-21", domain: ".google.com", path: "/", expires: 1636232420.005369, size: 19, httpOnly: false, secure: true, session: false, sameSite: "None", priority: "Medium" } ], headers: {}, time: 1.520785498, body: "...", options: { path: "file.jpg", full: true, quality: 100 }, file: { inode: "439545", hard_links: 1, owner: "pi", group: "pi", size: 54269, date: { year: 2021, month: 10, day: 7, hour: 16, minute: 0, second: 20, nanosecond: 444437482, utc_offset: -18000, weekday: 4, day_of_month: 7, day_of_year: 280, string: "2021-10-07 16:00:20 -0500", epoch_integer: 1633640420, epoch_float: 1633640420.4444375, seconds_ago: 0.016297478 }, name: "file.jpg", type: "-", owner_permission: "rw-", group_permission: "r--", other_permission: "r--", directory: "/home/pi/Desktop/mushy", path: "/home/pi/Desktop/mushy/file.jpg" } } }, } config[:fluxGroup] = { name: 'Export' } end end |
Instance Method Details
#adjust(input) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/mushy/fluxs/screenshot.rb', line 99 def adjust input the_browser = input[:browser] the_result = input[:result] the_config = input[:config] file = Mushy::WriteFile.get_file_from the_config = { path: file, full: ['true', ''].include?(the_config[:full].to_s), quality: (the_config[:quality].to_s == '' ? '100' : the_config[:quality]).to_i } the_browser.screenshot the_result[:options] = the_result[:file] = Mushy::Ls.new.process({}, { path: file })[0] the_result end |