Class: Mushy::Screenshot

Inherits:
Browser show all
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

.detailsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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.'

  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
end

Instance Method Details

#adjust(input) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/mushy/fluxs/screenshot.rb', line 29

def adjust input

  the_browser = input[:browser]
  the_result  = input[:result]
  the_config  = input[:config]

  file = Mushy::WriteFile.get_file_from the_config
  options = {
      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 options

  the_result[:options] = options
  the_result[:file] = Mushy::Ls.new.process({}, { path: file })[0]

  the_result

end