Module: Webstract::ScreenshotBackend
- Defined in:
- lib/webstract/screenshot_backend.rb
Constant Summary collapse
- USER_AGENTS =
{ web: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31', android: 'Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 4 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19', ios: 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3' }
- @@width =
1024- @@height =
768- @@accept_language =
'en-us,en;q=0.5'- @@basic_auth =
nil
Class Method Summary collapse
-
.capybara_setup! ⇒ Object
Capibara setup.
-
.setup {|_self| ... } ⇒ Object
Customize settings.
- .user_agent ⇒ Object
- .user_agent=(ua) ⇒ Object
Instance Method Summary collapse
-
#width ⇒ Object
Browser settings Width.
Class Method Details
.capybara_setup! ⇒ Object
Capibara setup
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/webstract/screenshot_backend.rb', line 51 def self. # By default Capybara will try to boot a rack application # automatically. You might want to switch off Capybara's # rack server if you are running against a remote application .run_server = false .register_driver :poltergeist do |app| ::Poltergeist::Driver.new(app, { # Raise JavaScript errors to Ruby js_errors: false, debug: ENV['WEBSTRACT_DEBUG'] || false, # Additional command line options for PhantomJS phantomjs_options: ['--ignore-ssl-errors=yes'], }) end .current_driver = :poltergeist end |
.setup {|_self| ... } ⇒ Object
Customize settings
46 47 48 |
# File 'lib/webstract/screenshot_backend.rb', line 46 def self.setup yield(self) end |
.user_agent ⇒ Object
34 35 36 |
# File 'lib/webstract/screenshot_backend.rb', line 34 def user_agent @user_agent ||= USER_AGENTS[:web] end |
.user_agent=(ua) ⇒ Object
37 38 39 40 41 |
# File 'lib/webstract/screenshot_backend.rb', line 37 def user_agent=(ua) agent_string = USER_AGENTS[ua] raise(ArgumentError.new('must be one of #{USER_AGENTS.inspect}')) unless agent_string @user_agent = agent_string end |
Instance Method Details
#width ⇒ Object
Browser settings Width
17 |
# File 'lib/webstract/screenshot_backend.rb', line 17 mattr_accessor :width |